babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175
  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. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21426. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21427. */
  21428. increaseVertices(numberPerEdge: number): void;
  21429. /**
  21430. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21431. * This will undo any application of covertToFlatShadedMesh
  21432. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21433. */
  21434. forceSharedVertices(): void;
  21435. /** @hidden */
  21436. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21437. /** @hidden */
  21438. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21439. /**
  21440. * Creates a new InstancedMesh object from the mesh model.
  21441. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21442. * @param name defines the name of the new instance
  21443. * @returns a new InstancedMesh
  21444. */
  21445. createInstance(name: string): InstancedMesh;
  21446. /**
  21447. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21448. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21449. * @returns the current mesh
  21450. */
  21451. synchronizeInstances(): Mesh;
  21452. /**
  21453. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21454. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21455. * This should be used together with the simplification to avoid disappearing triangles.
  21456. * @param successCallback an optional success callback to be called after the optimization finished.
  21457. * @returns the current mesh
  21458. */
  21459. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21460. /**
  21461. * Serialize current mesh
  21462. * @param serializationObject defines the object which will receive the serialization data
  21463. */
  21464. serialize(serializationObject: any): void;
  21465. /** @hidden */
  21466. _syncGeometryWithMorphTargetManager(): void;
  21467. /** @hidden */
  21468. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21469. /**
  21470. * Returns a new Mesh object parsed from the source provided.
  21471. * @param parsedMesh is the source
  21472. * @param scene defines the hosting scene
  21473. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21474. * @returns a new Mesh
  21475. */
  21476. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21477. /**
  21478. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21479. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21480. * @param name defines the name of the mesh to create
  21481. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21482. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21483. * @param closePath creates a seam between the first and the last points of each path of the path array
  21484. * @param offset is taken in account only if the `pathArray` is containing a single path
  21485. * @param scene defines the hosting scene
  21486. * @param updatable defines if the mesh must be flagged as updatable
  21487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21488. * @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)
  21489. * @returns a new Mesh
  21490. */
  21491. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21492. /**
  21493. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21494. * @param name defines the name of the mesh to create
  21495. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21496. * @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
  21497. * @param scene defines the hosting scene
  21498. * @param updatable defines if the mesh must be flagged as updatable
  21499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21500. * @returns a new Mesh
  21501. */
  21502. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21503. /**
  21504. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21505. * @param name defines the name of the mesh to create
  21506. * @param size sets the size (float) of each box side (default 1)
  21507. * @param scene defines the hosting scene
  21508. * @param updatable defines if the mesh must be flagged as updatable
  21509. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21510. * @returns a new Mesh
  21511. */
  21512. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21513. /**
  21514. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21515. * @param name defines the name of the mesh to create
  21516. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21517. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21518. * @param scene defines the hosting scene
  21519. * @param updatable defines if the mesh must be flagged as updatable
  21520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21521. * @returns a new Mesh
  21522. */
  21523. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21524. /**
  21525. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21526. * @param name defines the name of the mesh to create
  21527. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21528. * @param diameterTop set the top cap diameter (floats, default 1)
  21529. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21530. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21531. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21532. * @param scene defines the hosting scene
  21533. * @param updatable defines if the mesh must be flagged as updatable
  21534. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21535. * @returns a new Mesh
  21536. */
  21537. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21538. /**
  21539. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21540. * @param name defines the name of the mesh to create
  21541. * @param diameter sets the diameter size (float) of the torus (default 1)
  21542. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21543. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21544. * @param scene defines the hosting scene
  21545. * @param updatable defines if the mesh must be flagged as updatable
  21546. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21547. * @returns a new Mesh
  21548. */
  21549. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21550. /**
  21551. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21552. * @param name defines the name of the mesh to create
  21553. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21554. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21555. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21556. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21557. * @param p the number of windings on X axis (positive integers, default 2)
  21558. * @param q the number of windings on Y axis (positive integers, default 3)
  21559. * @param scene defines the hosting scene
  21560. * @param updatable defines if the mesh must be flagged as updatable
  21561. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21562. * @returns a new Mesh
  21563. */
  21564. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21565. /**
  21566. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21567. * @param name defines the name of the mesh to create
  21568. * @param points is an array successive Vector3
  21569. * @param scene defines the hosting scene
  21570. * @param updatable defines if the mesh must be flagged as updatable
  21571. * @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).
  21572. * @returns a new Mesh
  21573. */
  21574. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21575. /**
  21576. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21577. * @param name defines the name of the mesh to create
  21578. * @param points is an array successive Vector3
  21579. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21580. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21581. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21582. * @param scene defines the hosting scene
  21583. * @param updatable defines if the mesh must be flagged as updatable
  21584. * @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)
  21585. * @returns a new Mesh
  21586. */
  21587. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21588. /**
  21589. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21590. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21591. * 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.
  21592. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21593. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21594. * Remember you can only change the shape positions, not their number when updating a polygon.
  21595. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21596. * @param name defines the name of the mesh to create
  21597. * @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
  21598. * @param scene defines the hosting scene
  21599. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21600. * @param updatable defines if the mesh must be flagged as updatable
  21601. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21602. * @param earcutInjection can be used to inject your own earcut reference
  21603. * @returns a new Mesh
  21604. */
  21605. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21606. /**
  21607. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21608. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21609. * @param name defines the name of the mesh to create
  21610. * @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
  21611. * @param depth defines the height of extrusion
  21612. * @param scene defines the hosting scene
  21613. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21614. * @param updatable defines if the mesh must be flagged as updatable
  21615. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21616. * @param earcutInjection can be used to inject your own earcut reference
  21617. * @returns a new Mesh
  21618. */
  21619. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21620. /**
  21621. * Creates an extruded shape mesh.
  21622. * 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
  21623. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21624. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21625. * @param name defines the name of the mesh to create
  21626. * @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
  21627. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21628. * @param scale is the value to scale the shape
  21629. * @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
  21630. * @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
  21631. * @param scene defines the hosting scene
  21632. * @param updatable defines if the mesh must be flagged as updatable
  21633. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21634. * @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)
  21635. * @returns a new Mesh
  21636. */
  21637. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21638. /**
  21639. * Creates an custom extruded shape mesh.
  21640. * The custom extrusion is a parametric shape.
  21641. * It has no predefined shape. Its final shape will depend on the input parameters.
  21642. * Please consider using the same method from the MeshBuilder class instead
  21643. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21644. * @param name defines the name of the mesh to create
  21645. * @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
  21646. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21647. * @param scaleFunction is a custom Javascript function called on each path point
  21648. * @param rotationFunction is a custom Javascript function called on each path point
  21649. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21650. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21651. * @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
  21652. * @param scene defines the hosting scene
  21653. * @param updatable defines if the mesh must be flagged as updatable
  21654. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21655. * @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)
  21656. * @returns a new Mesh
  21657. */
  21658. 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;
  21659. /**
  21660. * Creates lathe mesh.
  21661. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21662. * Please consider using the same method from the MeshBuilder class instead
  21663. * @param name defines the name of the mesh to create
  21664. * @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
  21665. * @param radius is the radius value of the lathe
  21666. * @param tessellation is the side number of the lathe.
  21667. * @param scene defines the hosting scene
  21668. * @param updatable defines if the mesh must be flagged as updatable
  21669. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21670. * @returns a new Mesh
  21671. */
  21672. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21673. /**
  21674. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21675. * @param name defines the name of the mesh to create
  21676. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21677. * @param scene defines the hosting scene
  21678. * @param updatable defines if the mesh must be flagged as updatable
  21679. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21680. * @returns a new Mesh
  21681. */
  21682. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21683. /**
  21684. * Creates a ground mesh.
  21685. * Please consider using the same method from the MeshBuilder class instead
  21686. * @param name defines the name of the mesh to create
  21687. * @param width set the width of the ground
  21688. * @param height set the height of the ground
  21689. * @param subdivisions sets the number of subdivisions per side
  21690. * @param scene defines the hosting scene
  21691. * @param updatable defines if the mesh must be flagged as updatable
  21692. * @returns a new Mesh
  21693. */
  21694. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21695. /**
  21696. * Creates a tiled ground mesh.
  21697. * Please consider using the same method from the MeshBuilder class instead
  21698. * @param name defines the name of the mesh to create
  21699. * @param xmin set the ground minimum X coordinate
  21700. * @param zmin set the ground minimum Y coordinate
  21701. * @param xmax set the ground maximum X coordinate
  21702. * @param zmax set the ground maximum Z coordinate
  21703. * @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
  21704. * @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
  21705. * @param scene defines the hosting scene
  21706. * @param updatable defines if the mesh must be flagged as updatable
  21707. * @returns a new Mesh
  21708. */
  21709. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21710. w: number;
  21711. h: number;
  21712. }, precision: {
  21713. w: number;
  21714. h: number;
  21715. }, scene: Scene, updatable?: boolean): Mesh;
  21716. /**
  21717. * Creates a ground mesh from a height map.
  21718. * Please consider using the same method from the MeshBuilder class instead
  21719. * @see http://doc.babylonjs.com/babylon101/height_map
  21720. * @param name defines the name of the mesh to create
  21721. * @param url sets the URL of the height map image resource
  21722. * @param width set the ground width size
  21723. * @param height set the ground height size
  21724. * @param subdivisions sets the number of subdivision per side
  21725. * @param minHeight is the minimum altitude on the ground
  21726. * @param maxHeight is the maximum altitude on the ground
  21727. * @param scene defines the hosting scene
  21728. * @param updatable defines if the mesh must be flagged as updatable
  21729. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21730. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21731. * @returns a new Mesh
  21732. */
  21733. 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;
  21734. /**
  21735. * Creates a tube mesh.
  21736. * The tube is a parametric shape.
  21737. * It has no predefined shape. Its final shape will depend on the input parameters.
  21738. * Please consider using the same method from the MeshBuilder class instead
  21739. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21740. * @param name defines the name of the mesh to create
  21741. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21742. * @param radius sets the tube radius size
  21743. * @param tessellation is the number of sides on the tubular surface
  21744. * @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
  21745. * @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
  21746. * @param scene defines the hosting scene
  21747. * @param updatable defines if the mesh must be flagged as updatable
  21748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21749. * @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)
  21750. * @returns a new Mesh
  21751. */
  21752. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21753. (i: number, distance: number): number;
  21754. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21755. /**
  21756. * Creates a polyhedron mesh.
  21757. * Please consider using the same method from the MeshBuilder class instead.
  21758. * * 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
  21759. * * The parameter `size` (positive float, default 1) sets the polygon size
  21760. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21761. * * 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`
  21762. * * 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
  21763. * * 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)`)
  21764. * * 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
  21765. * * 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
  21766. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21767. * * If you create a double-sided mesh, you can choose what parts of 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
  21768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21769. * @param name defines the name of the mesh to create
  21770. * @param options defines the options used to create the mesh
  21771. * @param scene defines the hosting scene
  21772. * @returns a new Mesh
  21773. */
  21774. static CreatePolyhedron(name: string, options: {
  21775. type?: number;
  21776. size?: number;
  21777. sizeX?: number;
  21778. sizeY?: number;
  21779. sizeZ?: number;
  21780. custom?: any;
  21781. faceUV?: Vector4[];
  21782. faceColors?: Color4[];
  21783. updatable?: boolean;
  21784. sideOrientation?: number;
  21785. }, scene: Scene): Mesh;
  21786. /**
  21787. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21788. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21789. * * 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`)
  21790. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21791. * * 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
  21792. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21793. * * If you create a double-sided mesh, you can choose what parts of 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
  21794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21795. * @param name defines the name of the mesh
  21796. * @param options defines the options used to create the mesh
  21797. * @param scene defines the hosting scene
  21798. * @returns a new Mesh
  21799. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21800. */
  21801. static CreateIcoSphere(name: string, options: {
  21802. radius?: number;
  21803. flat?: boolean;
  21804. subdivisions?: number;
  21805. sideOrientation?: number;
  21806. updatable?: boolean;
  21807. }, scene: Scene): Mesh;
  21808. /**
  21809. * Creates a decal mesh.
  21810. * Please consider using the same method from the MeshBuilder class instead.
  21811. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21812. * @param name defines the name of the mesh
  21813. * @param sourceMesh defines the mesh receiving the decal
  21814. * @param position sets the position of the decal in world coordinates
  21815. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21816. * @param size sets the decal scaling
  21817. * @param angle sets the angle to rotate the decal
  21818. * @returns a new Mesh
  21819. */
  21820. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21821. /**
  21822. * Prepare internal position array for software CPU skinning
  21823. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21824. */
  21825. setPositionsForCPUSkinning(): Float32Array;
  21826. /**
  21827. * Prepare internal normal array for software CPU skinning
  21828. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21829. */
  21830. setNormalsForCPUSkinning(): Float32Array;
  21831. /**
  21832. * Updates the vertex buffer by applying transformation from the bones
  21833. * @param skeleton defines the skeleton to apply to current mesh
  21834. * @returns the current mesh
  21835. */
  21836. applySkeleton(skeleton: Skeleton): Mesh;
  21837. /**
  21838. * 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
  21839. * @param meshes defines the list of meshes to scan
  21840. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21841. */
  21842. static MinMax(meshes: AbstractMesh[]): {
  21843. min: Vector3;
  21844. max: Vector3;
  21845. };
  21846. /**
  21847. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21848. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21849. * @returns a vector3
  21850. */
  21851. static Center(meshesOrMinMaxVector: {
  21852. min: Vector3;
  21853. max: Vector3;
  21854. } | AbstractMesh[]): Vector3;
  21855. /**
  21856. * Merge the array of meshes into a single mesh for performance reasons.
  21857. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21858. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21859. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21860. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21861. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21862. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21863. * @returns a new mesh
  21864. */
  21865. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21866. /** @hidden */
  21867. addInstance(instance: InstancedMesh): void;
  21868. /** @hidden */
  21869. removeInstance(instance: InstancedMesh): void;
  21870. }
  21871. }
  21872. declare module "babylonjs/Materials/material" {
  21873. import { IAnimatable } from "babylonjs/Misc/tools";
  21874. import { SmartArray } from "babylonjs/Misc/smartArray";
  21875. import { Observable } from "babylonjs/Misc/observable";
  21876. import { Nullable } from "babylonjs/types";
  21877. import { Scene } from "babylonjs/scene";
  21878. import { Matrix } from "babylonjs/Maths/math";
  21879. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21881. import { Mesh } from "babylonjs/Meshes/mesh";
  21882. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21883. import { Effect } from "babylonjs/Materials/effect";
  21884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21885. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21886. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21887. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21888. import { Animation } from "babylonjs/Animations/animation";
  21889. /**
  21890. * Base class for the main features of a material in Babylon.js
  21891. */
  21892. export class Material implements IAnimatable {
  21893. /**
  21894. * Returns the triangle fill mode
  21895. */
  21896. static readonly TriangleFillMode: number;
  21897. /**
  21898. * Returns the wireframe mode
  21899. */
  21900. static readonly WireFrameFillMode: number;
  21901. /**
  21902. * Returns the point fill mode
  21903. */
  21904. static readonly PointFillMode: number;
  21905. /**
  21906. * Returns the point list draw mode
  21907. */
  21908. static readonly PointListDrawMode: number;
  21909. /**
  21910. * Returns the line list draw mode
  21911. */
  21912. static readonly LineListDrawMode: number;
  21913. /**
  21914. * Returns the line loop draw mode
  21915. */
  21916. static readonly LineLoopDrawMode: number;
  21917. /**
  21918. * Returns the line strip draw mode
  21919. */
  21920. static readonly LineStripDrawMode: number;
  21921. /**
  21922. * Returns the triangle strip draw mode
  21923. */
  21924. static readonly TriangleStripDrawMode: number;
  21925. /**
  21926. * Returns the triangle fan draw mode
  21927. */
  21928. static readonly TriangleFanDrawMode: number;
  21929. /**
  21930. * Stores the clock-wise side orientation
  21931. */
  21932. static readonly ClockWiseSideOrientation: number;
  21933. /**
  21934. * Stores the counter clock-wise side orientation
  21935. */
  21936. static readonly CounterClockWiseSideOrientation: number;
  21937. /**
  21938. * The dirty texture flag value
  21939. */
  21940. static readonly TextureDirtyFlag: number;
  21941. /**
  21942. * The dirty light flag value
  21943. */
  21944. static readonly LightDirtyFlag: number;
  21945. /**
  21946. * The dirty fresnel flag value
  21947. */
  21948. static readonly FresnelDirtyFlag: number;
  21949. /**
  21950. * The dirty attribute flag value
  21951. */
  21952. static readonly AttributesDirtyFlag: number;
  21953. /**
  21954. * The dirty misc flag value
  21955. */
  21956. static readonly MiscDirtyFlag: number;
  21957. /**
  21958. * The all dirty flag value
  21959. */
  21960. static readonly AllDirtyFlag: number;
  21961. /**
  21962. * The ID of the material
  21963. */
  21964. id: string;
  21965. /**
  21966. * Gets or sets the unique id of the material
  21967. */
  21968. uniqueId: number;
  21969. /**
  21970. * The name of the material
  21971. */
  21972. name: string;
  21973. /**
  21974. * Gets or sets user defined metadata
  21975. */
  21976. metadata: any;
  21977. /**
  21978. * For internal use only. Please do not use.
  21979. */
  21980. reservedDataStore: any;
  21981. /**
  21982. * Specifies if the ready state should be checked on each call
  21983. */
  21984. checkReadyOnEveryCall: boolean;
  21985. /**
  21986. * Specifies if the ready state should be checked once
  21987. */
  21988. checkReadyOnlyOnce: boolean;
  21989. /**
  21990. * The state of the material
  21991. */
  21992. state: string;
  21993. /**
  21994. * The alpha value of the material
  21995. */
  21996. protected _alpha: number;
  21997. /**
  21998. * List of inspectable custom properties (used by the Inspector)
  21999. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22000. */
  22001. inspectableCustomProperties: IInspectable[];
  22002. /**
  22003. * Sets the alpha value of the material
  22004. */
  22005. /**
  22006. * Gets the alpha value of the material
  22007. */
  22008. alpha: number;
  22009. /**
  22010. * Specifies if back face culling is enabled
  22011. */
  22012. protected _backFaceCulling: boolean;
  22013. /**
  22014. * Sets the back-face culling state
  22015. */
  22016. /**
  22017. * Gets the back-face culling state
  22018. */
  22019. backFaceCulling: boolean;
  22020. /**
  22021. * Stores the value for side orientation
  22022. */
  22023. sideOrientation: number;
  22024. /**
  22025. * Callback triggered when the material is compiled
  22026. */
  22027. onCompiled: (effect: Effect) => void;
  22028. /**
  22029. * Callback triggered when an error occurs
  22030. */
  22031. onError: (effect: Effect, errors: string) => void;
  22032. /**
  22033. * Callback triggered to get the render target textures
  22034. */
  22035. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22036. /**
  22037. * Gets a boolean indicating that current material needs to register RTT
  22038. */
  22039. readonly hasRenderTargetTextures: boolean;
  22040. /**
  22041. * Specifies if the material should be serialized
  22042. */
  22043. doNotSerialize: boolean;
  22044. /**
  22045. * @hidden
  22046. */
  22047. _storeEffectOnSubMeshes: boolean;
  22048. /**
  22049. * Stores the animations for the material
  22050. */
  22051. animations: Array<Animation>;
  22052. /**
  22053. * An event triggered when the material is disposed
  22054. */
  22055. onDisposeObservable: Observable<Material>;
  22056. /**
  22057. * An observer which watches for dispose events
  22058. */
  22059. private _onDisposeObserver;
  22060. private _onUnBindObservable;
  22061. /**
  22062. * Called during a dispose event
  22063. */
  22064. onDispose: () => void;
  22065. private _onBindObservable;
  22066. /**
  22067. * An event triggered when the material is bound
  22068. */
  22069. readonly onBindObservable: Observable<AbstractMesh>;
  22070. /**
  22071. * An observer which watches for bind events
  22072. */
  22073. private _onBindObserver;
  22074. /**
  22075. * Called during a bind event
  22076. */
  22077. onBind: (Mesh: AbstractMesh) => void;
  22078. /**
  22079. * An event triggered when the material is unbound
  22080. */
  22081. readonly onUnBindObservable: Observable<Material>;
  22082. /**
  22083. * Stores the value of the alpha mode
  22084. */
  22085. private _alphaMode;
  22086. /**
  22087. * Sets the value of the alpha mode.
  22088. *
  22089. * | Value | Type | Description |
  22090. * | --- | --- | --- |
  22091. * | 0 | ALPHA_DISABLE | |
  22092. * | 1 | ALPHA_ADD | |
  22093. * | 2 | ALPHA_COMBINE | |
  22094. * | 3 | ALPHA_SUBTRACT | |
  22095. * | 4 | ALPHA_MULTIPLY | |
  22096. * | 5 | ALPHA_MAXIMIZED | |
  22097. * | 6 | ALPHA_ONEONE | |
  22098. * | 7 | ALPHA_PREMULTIPLIED | |
  22099. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22100. * | 9 | ALPHA_INTERPOLATE | |
  22101. * | 10 | ALPHA_SCREENMODE | |
  22102. *
  22103. */
  22104. /**
  22105. * Gets the value of the alpha mode
  22106. */
  22107. alphaMode: number;
  22108. /**
  22109. * Stores the state of the need depth pre-pass value
  22110. */
  22111. private _needDepthPrePass;
  22112. /**
  22113. * Sets the need depth pre-pass value
  22114. */
  22115. /**
  22116. * Gets the depth pre-pass value
  22117. */
  22118. needDepthPrePass: boolean;
  22119. /**
  22120. * Specifies if depth writing should be disabled
  22121. */
  22122. disableDepthWrite: boolean;
  22123. /**
  22124. * Specifies if depth writing should be forced
  22125. */
  22126. forceDepthWrite: boolean;
  22127. /**
  22128. * Specifies if there should be a separate pass for culling
  22129. */
  22130. separateCullingPass: boolean;
  22131. /**
  22132. * Stores the state specifing if fog should be enabled
  22133. */
  22134. private _fogEnabled;
  22135. /**
  22136. * Sets the state for enabling fog
  22137. */
  22138. /**
  22139. * Gets the value of the fog enabled state
  22140. */
  22141. fogEnabled: boolean;
  22142. /**
  22143. * Stores the size of points
  22144. */
  22145. pointSize: number;
  22146. /**
  22147. * Stores the z offset value
  22148. */
  22149. zOffset: number;
  22150. /**
  22151. * Gets a value specifying if wireframe mode is enabled
  22152. */
  22153. /**
  22154. * Sets the state of wireframe mode
  22155. */
  22156. wireframe: boolean;
  22157. /**
  22158. * Gets the value specifying if point clouds are enabled
  22159. */
  22160. /**
  22161. * Sets the state of point cloud mode
  22162. */
  22163. pointsCloud: boolean;
  22164. /**
  22165. * Gets the material fill mode
  22166. */
  22167. /**
  22168. * Sets the material fill mode
  22169. */
  22170. fillMode: number;
  22171. /**
  22172. * @hidden
  22173. * Stores the effects for the material
  22174. */
  22175. _effect: Nullable<Effect>;
  22176. /**
  22177. * @hidden
  22178. * Specifies if the material was previously ready
  22179. */
  22180. _wasPreviouslyReady: boolean;
  22181. /**
  22182. * Specifies if uniform buffers should be used
  22183. */
  22184. private _useUBO;
  22185. /**
  22186. * Stores a reference to the scene
  22187. */
  22188. private _scene;
  22189. /**
  22190. * Stores the fill mode state
  22191. */
  22192. private _fillMode;
  22193. /**
  22194. * Specifies if the depth write state should be cached
  22195. */
  22196. private _cachedDepthWriteState;
  22197. /**
  22198. * Stores the uniform buffer
  22199. */
  22200. protected _uniformBuffer: UniformBuffer;
  22201. /** @hidden */
  22202. _indexInSceneMaterialArray: number;
  22203. /** @hidden */
  22204. meshMap: Nullable<{
  22205. [id: string]: AbstractMesh | undefined;
  22206. }>;
  22207. /**
  22208. * Creates a material instance
  22209. * @param name defines the name of the material
  22210. * @param scene defines the scene to reference
  22211. * @param doNotAdd specifies if the material should be added to the scene
  22212. */
  22213. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22214. /**
  22215. * Returns a string representation of the current material
  22216. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22217. * @returns a string with material information
  22218. */
  22219. toString(fullDetails?: boolean): string;
  22220. /**
  22221. * Gets the class name of the material
  22222. * @returns a string with the class name of the material
  22223. */
  22224. getClassName(): string;
  22225. /**
  22226. * Specifies if updates for the material been locked
  22227. */
  22228. readonly isFrozen: boolean;
  22229. /**
  22230. * Locks updates for the material
  22231. */
  22232. freeze(): void;
  22233. /**
  22234. * Unlocks updates for the material
  22235. */
  22236. unfreeze(): void;
  22237. /**
  22238. * Specifies if the material is ready to be used
  22239. * @param mesh defines the mesh to check
  22240. * @param useInstances specifies if instances should be used
  22241. * @returns a boolean indicating if the material is ready to be used
  22242. */
  22243. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22244. /**
  22245. * Specifies that the submesh is ready to be used
  22246. * @param mesh defines the mesh to check
  22247. * @param subMesh defines which submesh to check
  22248. * @param useInstances specifies that instances should be used
  22249. * @returns a boolean indicating that the submesh is ready or not
  22250. */
  22251. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22252. /**
  22253. * Returns the material effect
  22254. * @returns the effect associated with the material
  22255. */
  22256. getEffect(): Nullable<Effect>;
  22257. /**
  22258. * Returns the current scene
  22259. * @returns a Scene
  22260. */
  22261. getScene(): Scene;
  22262. /**
  22263. * Specifies if the material will require alpha blending
  22264. * @returns a boolean specifying if alpha blending is needed
  22265. */
  22266. needAlphaBlending(): boolean;
  22267. /**
  22268. * Specifies if the mesh will require alpha blending
  22269. * @param mesh defines the mesh to check
  22270. * @returns a boolean specifying if alpha blending is needed for the mesh
  22271. */
  22272. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22273. /**
  22274. * Specifies if this material should be rendered in alpha test mode
  22275. * @returns a boolean specifying if an alpha test is needed.
  22276. */
  22277. needAlphaTesting(): boolean;
  22278. /**
  22279. * Gets the texture used for the alpha test
  22280. * @returns the texture to use for alpha testing
  22281. */
  22282. getAlphaTestTexture(): Nullable<BaseTexture>;
  22283. /**
  22284. * Marks the material to indicate that it needs to be re-calculated
  22285. */
  22286. markDirty(): void;
  22287. /** @hidden */
  22288. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22289. /**
  22290. * Binds the material to the mesh
  22291. * @param world defines the world transformation matrix
  22292. * @param mesh defines the mesh to bind the material to
  22293. */
  22294. bind(world: Matrix, mesh?: Mesh): void;
  22295. /**
  22296. * Binds the submesh to the material
  22297. * @param world defines the world transformation matrix
  22298. * @param mesh defines the mesh containing the submesh
  22299. * @param subMesh defines the submesh to bind the material to
  22300. */
  22301. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22302. /**
  22303. * Binds the world matrix to the material
  22304. * @param world defines the world transformation matrix
  22305. */
  22306. bindOnlyWorldMatrix(world: Matrix): void;
  22307. /**
  22308. * Binds the scene's uniform buffer to the effect.
  22309. * @param effect defines the effect to bind to the scene uniform buffer
  22310. * @param sceneUbo defines the uniform buffer storing scene data
  22311. */
  22312. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22313. /**
  22314. * Binds the view matrix to the effect
  22315. * @param effect defines the effect to bind the view matrix to
  22316. */
  22317. bindView(effect: Effect): void;
  22318. /**
  22319. * Binds the view projection matrix to the effect
  22320. * @param effect defines the effect to bind the view projection matrix to
  22321. */
  22322. bindViewProjection(effect: Effect): void;
  22323. /**
  22324. * Specifies if material alpha testing should be turned on for the mesh
  22325. * @param mesh defines the mesh to check
  22326. */
  22327. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22328. /**
  22329. * Processes to execute after binding the material to a mesh
  22330. * @param mesh defines the rendered mesh
  22331. */
  22332. protected _afterBind(mesh?: Mesh): void;
  22333. /**
  22334. * Unbinds the material from the mesh
  22335. */
  22336. unbind(): void;
  22337. /**
  22338. * Gets the active textures from the material
  22339. * @returns an array of textures
  22340. */
  22341. getActiveTextures(): BaseTexture[];
  22342. /**
  22343. * Specifies if the material uses a texture
  22344. * @param texture defines the texture to check against the material
  22345. * @returns a boolean specifying if the material uses the texture
  22346. */
  22347. hasTexture(texture: BaseTexture): boolean;
  22348. /**
  22349. * Makes a duplicate of the material, and gives it a new name
  22350. * @param name defines the new name for the duplicated material
  22351. * @returns the cloned material
  22352. */
  22353. clone(name: string): Nullable<Material>;
  22354. /**
  22355. * Gets the meshes bound to the material
  22356. * @returns an array of meshes bound to the material
  22357. */
  22358. getBindedMeshes(): AbstractMesh[];
  22359. /**
  22360. * Force shader compilation
  22361. * @param mesh defines the mesh associated with this material
  22362. * @param onCompiled defines a function to execute once the material is compiled
  22363. * @param options defines the options to configure the compilation
  22364. */
  22365. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22366. clipPlane: boolean;
  22367. }>): void;
  22368. /**
  22369. * Force shader compilation
  22370. * @param mesh defines the mesh that will use this material
  22371. * @param options defines additional options for compiling the shaders
  22372. * @returns a promise that resolves when the compilation completes
  22373. */
  22374. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22375. clipPlane: boolean;
  22376. }>): Promise<void>;
  22377. private static readonly _ImageProcessingDirtyCallBack;
  22378. private static readonly _TextureDirtyCallBack;
  22379. private static readonly _FresnelDirtyCallBack;
  22380. private static readonly _MiscDirtyCallBack;
  22381. private static readonly _LightsDirtyCallBack;
  22382. private static readonly _AttributeDirtyCallBack;
  22383. private static _FresnelAndMiscDirtyCallBack;
  22384. private static _TextureAndMiscDirtyCallBack;
  22385. private static readonly _DirtyCallbackArray;
  22386. private static readonly _RunDirtyCallBacks;
  22387. /**
  22388. * Marks a define in the material to indicate that it needs to be re-computed
  22389. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22390. */
  22391. markAsDirty(flag: number): void;
  22392. /**
  22393. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22394. * @param func defines a function which checks material defines against the submeshes
  22395. */
  22396. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22397. /**
  22398. * Indicates that image processing needs to be re-calculated for all submeshes
  22399. */
  22400. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22401. /**
  22402. * Indicates that textures need to be re-calculated for all submeshes
  22403. */
  22404. protected _markAllSubMeshesAsTexturesDirty(): void;
  22405. /**
  22406. * Indicates that fresnel needs to be re-calculated for all submeshes
  22407. */
  22408. protected _markAllSubMeshesAsFresnelDirty(): void;
  22409. /**
  22410. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22411. */
  22412. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22413. /**
  22414. * Indicates that lights need to be re-calculated for all submeshes
  22415. */
  22416. protected _markAllSubMeshesAsLightsDirty(): void;
  22417. /**
  22418. * Indicates that attributes need to be re-calculated for all submeshes
  22419. */
  22420. protected _markAllSubMeshesAsAttributesDirty(): void;
  22421. /**
  22422. * Indicates that misc needs to be re-calculated for all submeshes
  22423. */
  22424. protected _markAllSubMeshesAsMiscDirty(): void;
  22425. /**
  22426. * Indicates that textures and misc need to be re-calculated for all submeshes
  22427. */
  22428. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22429. /**
  22430. * Disposes the material
  22431. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22432. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22433. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22434. */
  22435. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22436. /** @hidden */
  22437. private releaseVertexArrayObject;
  22438. /**
  22439. * Serializes this material
  22440. * @returns the serialized material object
  22441. */
  22442. serialize(): any;
  22443. /**
  22444. * Creates a material from parsed material data
  22445. * @param parsedMaterial defines parsed material data
  22446. * @param scene defines the hosting scene
  22447. * @param rootUrl defines the root URL to use to load textures
  22448. * @returns a new material
  22449. */
  22450. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22451. }
  22452. }
  22453. declare module "babylonjs/Meshes/subMesh" {
  22454. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22455. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22456. import { Engine } from "babylonjs/Engines/engine";
  22457. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22458. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22459. import { Effect } from "babylonjs/Materials/effect";
  22460. import { Collider } from "babylonjs/Collisions/collider";
  22461. import { Material } from "babylonjs/Materials/material";
  22462. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22464. import { Mesh } from "babylonjs/Meshes/mesh";
  22465. import { Ray } from "babylonjs/Culling/ray";
  22466. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22467. /**
  22468. * Base class for submeshes
  22469. */
  22470. export class BaseSubMesh {
  22471. /** @hidden */
  22472. _materialDefines: Nullable<MaterialDefines>;
  22473. /** @hidden */
  22474. _materialEffect: Nullable<Effect>;
  22475. /**
  22476. * Gets associated effect
  22477. */
  22478. readonly effect: Nullable<Effect>;
  22479. /**
  22480. * Sets associated effect (effect used to render this submesh)
  22481. * @param effect defines the effect to associate with
  22482. * @param defines defines the set of defines used to compile this effect
  22483. */
  22484. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22485. }
  22486. /**
  22487. * Defines a subdivision inside a mesh
  22488. */
  22489. export class SubMesh extends BaseSubMesh implements ICullable {
  22490. /** the material index to use */
  22491. materialIndex: number;
  22492. /** vertex index start */
  22493. verticesStart: number;
  22494. /** vertices count */
  22495. verticesCount: number;
  22496. /** index start */
  22497. indexStart: number;
  22498. /** indices count */
  22499. indexCount: number;
  22500. /** @hidden */
  22501. _linesIndexCount: number;
  22502. private _mesh;
  22503. private _renderingMesh;
  22504. private _boundingInfo;
  22505. private _linesIndexBuffer;
  22506. /** @hidden */
  22507. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22508. /** @hidden */
  22509. _trianglePlanes: Plane[];
  22510. /** @hidden */
  22511. _lastColliderTransformMatrix: Matrix;
  22512. /** @hidden */
  22513. _renderId: number;
  22514. /** @hidden */
  22515. _alphaIndex: number;
  22516. /** @hidden */
  22517. _distanceToCamera: number;
  22518. /** @hidden */
  22519. _id: number;
  22520. private _currentMaterial;
  22521. /**
  22522. * Add a new submesh to a mesh
  22523. * @param materialIndex defines the material index to use
  22524. * @param verticesStart defines vertex index start
  22525. * @param verticesCount defines vertices count
  22526. * @param indexStart defines index start
  22527. * @param indexCount defines indices count
  22528. * @param mesh defines the parent mesh
  22529. * @param renderingMesh defines an optional rendering mesh
  22530. * @param createBoundingBox defines if bounding box should be created for this submesh
  22531. * @returns the new submesh
  22532. */
  22533. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22534. /**
  22535. * Creates a new submesh
  22536. * @param materialIndex defines the material index to use
  22537. * @param verticesStart defines vertex index start
  22538. * @param verticesCount defines vertices count
  22539. * @param indexStart defines index start
  22540. * @param indexCount defines indices count
  22541. * @param mesh defines the parent mesh
  22542. * @param renderingMesh defines an optional rendering mesh
  22543. * @param createBoundingBox defines if bounding box should be created for this submesh
  22544. */
  22545. constructor(
  22546. /** the material index to use */
  22547. materialIndex: number,
  22548. /** vertex index start */
  22549. verticesStart: number,
  22550. /** vertices count */
  22551. verticesCount: number,
  22552. /** index start */
  22553. indexStart: number,
  22554. /** indices count */
  22555. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22556. /**
  22557. * Returns true if this submesh covers the entire parent mesh
  22558. * @ignorenaming
  22559. */
  22560. readonly IsGlobal: boolean;
  22561. /**
  22562. * Returns the submesh BoudingInfo object
  22563. * @returns current bounding info (or mesh's one if the submesh is global)
  22564. */
  22565. getBoundingInfo(): BoundingInfo;
  22566. /**
  22567. * Sets the submesh BoundingInfo
  22568. * @param boundingInfo defines the new bounding info to use
  22569. * @returns the SubMesh
  22570. */
  22571. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22572. /**
  22573. * Returns the mesh of the current submesh
  22574. * @return the parent mesh
  22575. */
  22576. getMesh(): AbstractMesh;
  22577. /**
  22578. * Returns the rendering mesh of the submesh
  22579. * @returns the rendering mesh (could be different from parent mesh)
  22580. */
  22581. getRenderingMesh(): Mesh;
  22582. /**
  22583. * Returns the submesh material
  22584. * @returns null or the current material
  22585. */
  22586. getMaterial(): Nullable<Material>;
  22587. /**
  22588. * Sets a new updated BoundingInfo object to the submesh
  22589. * @returns the SubMesh
  22590. */
  22591. refreshBoundingInfo(): SubMesh;
  22592. /** @hidden */
  22593. _checkCollision(collider: Collider): boolean;
  22594. /**
  22595. * Updates the submesh BoundingInfo
  22596. * @param world defines the world matrix to use to update the bounding info
  22597. * @returns the submesh
  22598. */
  22599. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22600. /**
  22601. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22602. * @param frustumPlanes defines the frustum planes
  22603. * @returns true if the submesh is intersecting with the frustum
  22604. */
  22605. isInFrustum(frustumPlanes: Plane[]): boolean;
  22606. /**
  22607. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22608. * @param frustumPlanes defines the frustum planes
  22609. * @returns true if the submesh is inside the frustum
  22610. */
  22611. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22612. /**
  22613. * Renders the submesh
  22614. * @param enableAlphaMode defines if alpha needs to be used
  22615. * @returns the submesh
  22616. */
  22617. render(enableAlphaMode: boolean): SubMesh;
  22618. /**
  22619. * @hidden
  22620. */
  22621. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22622. /**
  22623. * Checks if the submesh intersects with a ray
  22624. * @param ray defines the ray to test
  22625. * @returns true is the passed ray intersects the submesh bounding box
  22626. */
  22627. canIntersects(ray: Ray): boolean;
  22628. /**
  22629. * Intersects current submesh with a ray
  22630. * @param ray defines the ray to test
  22631. * @param positions defines mesh's positions array
  22632. * @param indices defines mesh's indices array
  22633. * @param fastCheck defines if only bounding info should be used
  22634. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22635. * @returns intersection info or null if no intersection
  22636. */
  22637. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22638. /** @hidden */
  22639. private _intersectLines;
  22640. /** @hidden */
  22641. private _intersectTriangles;
  22642. /** @hidden */
  22643. _rebuild(): void;
  22644. /**
  22645. * Creates a new submesh from the passed mesh
  22646. * @param newMesh defines the new hosting mesh
  22647. * @param newRenderingMesh defines an optional rendering mesh
  22648. * @returns the new submesh
  22649. */
  22650. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22651. /**
  22652. * Release associated resources
  22653. */
  22654. dispose(): void;
  22655. /**
  22656. * Gets the class name
  22657. * @returns the string "SubMesh".
  22658. */
  22659. getClassName(): string;
  22660. /**
  22661. * Creates a new submesh from indices data
  22662. * @param materialIndex the index of the main mesh material
  22663. * @param startIndex the index where to start the copy in the mesh indices array
  22664. * @param indexCount the number of indices to copy then from the startIndex
  22665. * @param mesh the main mesh to create the submesh from
  22666. * @param renderingMesh the optional rendering mesh
  22667. * @returns a new submesh
  22668. */
  22669. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22670. }
  22671. }
  22672. declare module "babylonjs/Meshes/geometry" {
  22673. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22674. import { Scene } from "babylonjs/scene";
  22675. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22676. import { Engine } from "babylonjs/Engines/engine";
  22677. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22678. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22679. import { Effect } from "babylonjs/Materials/effect";
  22680. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22681. import { Mesh } from "babylonjs/Meshes/mesh";
  22682. /**
  22683. * Class used to store geometry data (vertex buffers + index buffer)
  22684. */
  22685. export class Geometry implements IGetSetVerticesData {
  22686. /**
  22687. * Gets or sets the ID of the geometry
  22688. */
  22689. id: string;
  22690. /**
  22691. * Gets or sets the unique ID of the geometry
  22692. */
  22693. uniqueId: number;
  22694. /**
  22695. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22696. */
  22697. delayLoadState: number;
  22698. /**
  22699. * Gets the file containing the data to load when running in delay load state
  22700. */
  22701. delayLoadingFile: Nullable<string>;
  22702. /**
  22703. * Callback called when the geometry is updated
  22704. */
  22705. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22706. private _scene;
  22707. private _engine;
  22708. private _meshes;
  22709. private _totalVertices;
  22710. /** @hidden */
  22711. _indices: IndicesArray;
  22712. /** @hidden */
  22713. _vertexBuffers: {
  22714. [key: string]: VertexBuffer;
  22715. };
  22716. private _isDisposed;
  22717. private _extend;
  22718. private _boundingBias;
  22719. /** @hidden */
  22720. _delayInfo: Array<string>;
  22721. private _indexBuffer;
  22722. private _indexBufferIsUpdatable;
  22723. /** @hidden */
  22724. _boundingInfo: Nullable<BoundingInfo>;
  22725. /** @hidden */
  22726. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22727. /** @hidden */
  22728. _softwareSkinningFrameId: number;
  22729. private _vertexArrayObjects;
  22730. private _updatable;
  22731. /** @hidden */
  22732. _positions: Nullable<Vector3[]>;
  22733. /**
  22734. * 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
  22735. */
  22736. /**
  22737. * 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
  22738. */
  22739. boundingBias: Vector2;
  22740. /**
  22741. * Static function used to attach a new empty geometry to a mesh
  22742. * @param mesh defines the mesh to attach the geometry to
  22743. * @returns the new Geometry
  22744. */
  22745. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22746. /**
  22747. * Creates a new geometry
  22748. * @param id defines the unique ID
  22749. * @param scene defines the hosting scene
  22750. * @param vertexData defines the VertexData used to get geometry data
  22751. * @param updatable defines if geometry must be updatable (false by default)
  22752. * @param mesh defines the mesh that will be associated with the geometry
  22753. */
  22754. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22755. /**
  22756. * Gets the current extend of the geometry
  22757. */
  22758. readonly extend: {
  22759. minimum: Vector3;
  22760. maximum: Vector3;
  22761. };
  22762. /**
  22763. * Gets the hosting scene
  22764. * @returns the hosting Scene
  22765. */
  22766. getScene(): Scene;
  22767. /**
  22768. * Gets the hosting engine
  22769. * @returns the hosting Engine
  22770. */
  22771. getEngine(): Engine;
  22772. /**
  22773. * Defines if the geometry is ready to use
  22774. * @returns true if the geometry is ready to be used
  22775. */
  22776. isReady(): boolean;
  22777. /**
  22778. * Gets a value indicating that the geometry should not be serialized
  22779. */
  22780. readonly doNotSerialize: boolean;
  22781. /** @hidden */
  22782. _rebuild(): void;
  22783. /**
  22784. * Affects all geometry data in one call
  22785. * @param vertexData defines the geometry data
  22786. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22787. */
  22788. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22789. /**
  22790. * Set specific vertex data
  22791. * @param kind defines the data kind (Position, normal, etc...)
  22792. * @param data defines the vertex data to use
  22793. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22794. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22795. */
  22796. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22797. /**
  22798. * Removes a specific vertex data
  22799. * @param kind defines the data kind (Position, normal, etc...)
  22800. */
  22801. removeVerticesData(kind: string): void;
  22802. /**
  22803. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22804. * @param buffer defines the vertex buffer to use
  22805. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22806. */
  22807. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22808. /**
  22809. * Update a specific vertex buffer
  22810. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22811. * It will do nothing if the buffer is not updatable
  22812. * @param kind defines the data kind (Position, normal, etc...)
  22813. * @param data defines the data to use
  22814. * @param offset defines the offset in the target buffer where to store the data
  22815. * @param useBytes set to true if the offset is in bytes
  22816. */
  22817. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22818. /**
  22819. * Update a specific vertex buffer
  22820. * This function will create a new buffer if the current one is not updatable
  22821. * @param kind defines the data kind (Position, normal, etc...)
  22822. * @param data defines the data to use
  22823. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22824. */
  22825. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22826. private _updateBoundingInfo;
  22827. /** @hidden */
  22828. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22829. /**
  22830. * Gets total number of vertices
  22831. * @returns the total number of vertices
  22832. */
  22833. getTotalVertices(): number;
  22834. /**
  22835. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22836. * @param kind defines the data kind (Position, normal, etc...)
  22837. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22838. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22839. * @returns a float array containing vertex data
  22840. */
  22841. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22842. /**
  22843. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22844. * @param kind defines the data kind (Position, normal, etc...)
  22845. * @returns true if the vertex buffer with the specified kind is updatable
  22846. */
  22847. isVertexBufferUpdatable(kind: string): boolean;
  22848. /**
  22849. * Gets a specific vertex buffer
  22850. * @param kind defines the data kind (Position, normal, etc...)
  22851. * @returns a VertexBuffer
  22852. */
  22853. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22854. /**
  22855. * Returns all vertex buffers
  22856. * @return an object holding all vertex buffers indexed by kind
  22857. */
  22858. getVertexBuffers(): Nullable<{
  22859. [key: string]: VertexBuffer;
  22860. }>;
  22861. /**
  22862. * Gets a boolean indicating if specific vertex buffer is present
  22863. * @param kind defines the data kind (Position, normal, etc...)
  22864. * @returns true if data is present
  22865. */
  22866. isVerticesDataPresent(kind: string): boolean;
  22867. /**
  22868. * Gets a list of all attached data kinds (Position, normal, etc...)
  22869. * @returns a list of string containing all kinds
  22870. */
  22871. getVerticesDataKinds(): string[];
  22872. /**
  22873. * Update index buffer
  22874. * @param indices defines the indices to store in the index buffer
  22875. * @param offset defines the offset in the target buffer where to store the data
  22876. * @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)
  22877. */
  22878. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22879. /**
  22880. * Creates a new index buffer
  22881. * @param indices defines the indices to store in the index buffer
  22882. * @param totalVertices defines the total number of vertices (could be null)
  22883. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22884. */
  22885. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22886. /**
  22887. * Return the total number of indices
  22888. * @returns the total number of indices
  22889. */
  22890. getTotalIndices(): number;
  22891. /**
  22892. * Gets the index buffer array
  22893. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22894. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22895. * @returns the index buffer array
  22896. */
  22897. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22898. /**
  22899. * Gets the index buffer
  22900. * @return the index buffer
  22901. */
  22902. getIndexBuffer(): Nullable<WebGLBuffer>;
  22903. /** @hidden */
  22904. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22905. /**
  22906. * Release the associated resources for a specific mesh
  22907. * @param mesh defines the source mesh
  22908. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22909. */
  22910. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22911. /**
  22912. * Apply current geometry to a given mesh
  22913. * @param mesh defines the mesh to apply geometry to
  22914. */
  22915. applyToMesh(mesh: Mesh): void;
  22916. private _updateExtend;
  22917. private _applyToMesh;
  22918. private notifyUpdate;
  22919. /**
  22920. * Load the geometry if it was flagged as delay loaded
  22921. * @param scene defines the hosting scene
  22922. * @param onLoaded defines a callback called when the geometry is loaded
  22923. */
  22924. load(scene: Scene, onLoaded?: () => void): void;
  22925. private _queueLoad;
  22926. /**
  22927. * Invert the geometry to move from a right handed system to a left handed one.
  22928. */
  22929. toLeftHanded(): void;
  22930. /** @hidden */
  22931. _resetPointsArrayCache(): void;
  22932. /** @hidden */
  22933. _generatePointsArray(): boolean;
  22934. /**
  22935. * Gets a value indicating if the geometry is disposed
  22936. * @returns true if the geometry was disposed
  22937. */
  22938. isDisposed(): boolean;
  22939. private _disposeVertexArrayObjects;
  22940. /**
  22941. * Free all associated resources
  22942. */
  22943. dispose(): void;
  22944. /**
  22945. * Clone the current geometry into a new geometry
  22946. * @param id defines the unique ID of the new geometry
  22947. * @returns a new geometry object
  22948. */
  22949. copy(id: string): Geometry;
  22950. /**
  22951. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22952. * @return a JSON representation of the current geometry data (without the vertices data)
  22953. */
  22954. serialize(): any;
  22955. private toNumberArray;
  22956. /**
  22957. * Serialize all vertices data into a JSON oject
  22958. * @returns a JSON representation of the current geometry data
  22959. */
  22960. serializeVerticeData(): any;
  22961. /**
  22962. * Extracts a clone of a mesh geometry
  22963. * @param mesh defines the source mesh
  22964. * @param id defines the unique ID of the new geometry object
  22965. * @returns the new geometry object
  22966. */
  22967. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22968. /**
  22969. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22970. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22971. * Be aware Math.random() could cause collisions, but:
  22972. * "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"
  22973. * @returns a string containing a new GUID
  22974. */
  22975. static RandomId(): string;
  22976. /** @hidden */
  22977. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22978. private static _CleanMatricesWeights;
  22979. /**
  22980. * Create a new geometry from persisted data (Using .babylon file format)
  22981. * @param parsedVertexData defines the persisted data
  22982. * @param scene defines the hosting scene
  22983. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22984. * @returns the new geometry object
  22985. */
  22986. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22987. }
  22988. }
  22989. declare module "babylonjs/Meshes/mesh.vertexData" {
  22990. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22991. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22992. import { Geometry } from "babylonjs/Meshes/geometry";
  22993. import { Mesh } from "babylonjs/Meshes/mesh";
  22994. /**
  22995. * Define an interface for all classes that will get and set the data on vertices
  22996. */
  22997. export interface IGetSetVerticesData {
  22998. /**
  22999. * Gets a boolean indicating if specific vertex data is present
  23000. * @param kind defines the vertex data kind to use
  23001. * @returns true is data kind is present
  23002. */
  23003. isVerticesDataPresent(kind: string): boolean;
  23004. /**
  23005. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23006. * @param kind defines the data kind (Position, normal, etc...)
  23007. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23008. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23009. * @returns a float array containing vertex data
  23010. */
  23011. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23012. /**
  23013. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23014. * @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.
  23015. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23016. * @returns the indices array or an empty array if the mesh has no geometry
  23017. */
  23018. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23019. /**
  23020. * Set specific vertex data
  23021. * @param kind defines the data kind (Position, normal, etc...)
  23022. * @param data defines the vertex data to use
  23023. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23024. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23025. */
  23026. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23027. /**
  23028. * Update a specific associated vertex buffer
  23029. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23030. * - VertexBuffer.PositionKind
  23031. * - VertexBuffer.UVKind
  23032. * - VertexBuffer.UV2Kind
  23033. * - VertexBuffer.UV3Kind
  23034. * - VertexBuffer.UV4Kind
  23035. * - VertexBuffer.UV5Kind
  23036. * - VertexBuffer.UV6Kind
  23037. * - VertexBuffer.ColorKind
  23038. * - VertexBuffer.MatricesIndicesKind
  23039. * - VertexBuffer.MatricesIndicesExtraKind
  23040. * - VertexBuffer.MatricesWeightsKind
  23041. * - VertexBuffer.MatricesWeightsExtraKind
  23042. * @param data defines the data source
  23043. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23044. * @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)
  23045. */
  23046. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23047. /**
  23048. * Creates a new index buffer
  23049. * @param indices defines the indices to store in the index buffer
  23050. * @param totalVertices defines the total number of vertices (could be null)
  23051. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23052. */
  23053. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23054. }
  23055. /**
  23056. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23057. */
  23058. export class VertexData {
  23059. /**
  23060. * Mesh side orientation : usually the external or front surface
  23061. */
  23062. static readonly FRONTSIDE: number;
  23063. /**
  23064. * Mesh side orientation : usually the internal or back surface
  23065. */
  23066. static readonly BACKSIDE: number;
  23067. /**
  23068. * Mesh side orientation : both internal and external or front and back surfaces
  23069. */
  23070. static readonly DOUBLESIDE: number;
  23071. /**
  23072. * Mesh side orientation : by default, `FRONTSIDE`
  23073. */
  23074. static readonly DEFAULTSIDE: number;
  23075. /**
  23076. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23077. */
  23078. positions: Nullable<FloatArray>;
  23079. /**
  23080. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23081. */
  23082. normals: Nullable<FloatArray>;
  23083. /**
  23084. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23085. */
  23086. tangents: Nullable<FloatArray>;
  23087. /**
  23088. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23089. */
  23090. uvs: Nullable<FloatArray>;
  23091. /**
  23092. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23093. */
  23094. uvs2: Nullable<FloatArray>;
  23095. /**
  23096. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23097. */
  23098. uvs3: Nullable<FloatArray>;
  23099. /**
  23100. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23101. */
  23102. uvs4: Nullable<FloatArray>;
  23103. /**
  23104. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23105. */
  23106. uvs5: Nullable<FloatArray>;
  23107. /**
  23108. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23109. */
  23110. uvs6: Nullable<FloatArray>;
  23111. /**
  23112. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23113. */
  23114. colors: Nullable<FloatArray>;
  23115. /**
  23116. * 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).
  23117. */
  23118. matricesIndices: Nullable<FloatArray>;
  23119. /**
  23120. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23121. */
  23122. matricesWeights: Nullable<FloatArray>;
  23123. /**
  23124. * An array extending the number of possible indices
  23125. */
  23126. matricesIndicesExtra: Nullable<FloatArray>;
  23127. /**
  23128. * An array extending the number of possible weights when the number of indices is extended
  23129. */
  23130. matricesWeightsExtra: Nullable<FloatArray>;
  23131. /**
  23132. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23133. */
  23134. indices: Nullable<IndicesArray>;
  23135. /**
  23136. * Uses the passed data array to set the set the values for the specified kind of data
  23137. * @param data a linear array of floating numbers
  23138. * @param kind the type of data that is being set, eg positions, colors etc
  23139. */
  23140. set(data: FloatArray, kind: string): void;
  23141. /**
  23142. * Associates the vertexData to the passed Mesh.
  23143. * Sets it as updatable or not (default `false`)
  23144. * @param mesh the mesh the vertexData is applied to
  23145. * @param updatable when used and having the value true allows new data to update the vertexData
  23146. * @returns the VertexData
  23147. */
  23148. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23149. /**
  23150. * Associates the vertexData to the passed Geometry.
  23151. * Sets it as updatable or not (default `false`)
  23152. * @param geometry the geometry the vertexData is applied to
  23153. * @param updatable when used and having the value true allows new data to update the vertexData
  23154. * @returns VertexData
  23155. */
  23156. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23157. /**
  23158. * Updates the associated mesh
  23159. * @param mesh the mesh to be updated
  23160. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23161. * @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
  23162. * @returns VertexData
  23163. */
  23164. updateMesh(mesh: Mesh): VertexData;
  23165. /**
  23166. * Updates the associated geometry
  23167. * @param geometry the geometry to be updated
  23168. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23169. * @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
  23170. * @returns VertexData.
  23171. */
  23172. updateGeometry(geometry: Geometry): VertexData;
  23173. private _applyTo;
  23174. private _update;
  23175. /**
  23176. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23177. * @param matrix the transforming matrix
  23178. * @returns the VertexData
  23179. */
  23180. transform(matrix: Matrix): VertexData;
  23181. /**
  23182. * Merges the passed VertexData into the current one
  23183. * @param other the VertexData to be merged into the current one
  23184. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23185. * @returns the modified VertexData
  23186. */
  23187. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23188. private _mergeElement;
  23189. private _validate;
  23190. /**
  23191. * Serializes the VertexData
  23192. * @returns a serialized object
  23193. */
  23194. serialize(): any;
  23195. /**
  23196. * Extracts the vertexData from a mesh
  23197. * @param mesh the mesh from which to extract the VertexData
  23198. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23199. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23200. * @returns the object VertexData associated to the passed mesh
  23201. */
  23202. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23203. /**
  23204. * Extracts the vertexData from the geometry
  23205. * @param geometry the geometry from which to extract the VertexData
  23206. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23207. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23208. * @returns the object VertexData associated to the passed mesh
  23209. */
  23210. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23211. private static _ExtractFrom;
  23212. /**
  23213. * Creates the VertexData for a Ribbon
  23214. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23215. * * pathArray array of paths, each of which an array of successive Vector3
  23216. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23217. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23218. * * 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
  23219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23220. * * 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)
  23221. * * 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)
  23222. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23223. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23224. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23225. * @returns the VertexData of the ribbon
  23226. */
  23227. static CreateRibbon(options: {
  23228. pathArray: Vector3[][];
  23229. closeArray?: boolean;
  23230. closePath?: boolean;
  23231. offset?: number;
  23232. sideOrientation?: number;
  23233. frontUVs?: Vector4;
  23234. backUVs?: Vector4;
  23235. invertUV?: boolean;
  23236. uvs?: Vector2[];
  23237. colors?: Color4[];
  23238. }): VertexData;
  23239. /**
  23240. * Creates the VertexData for a box
  23241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23242. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23243. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23244. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23245. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23246. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23247. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23248. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23249. * * 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)
  23250. * * 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)
  23251. * @returns the VertexData of the box
  23252. */
  23253. static CreateBox(options: {
  23254. size?: number;
  23255. width?: number;
  23256. height?: number;
  23257. depth?: number;
  23258. faceUV?: Vector4[];
  23259. faceColors?: Color4[];
  23260. sideOrientation?: number;
  23261. frontUVs?: Vector4;
  23262. backUVs?: Vector4;
  23263. }): VertexData;
  23264. /**
  23265. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23267. * * segments sets the number of horizontal strips optional, default 32
  23268. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23269. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23270. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23271. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23272. * * 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
  23273. * * 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
  23274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23275. * * 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)
  23276. * * 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)
  23277. * @returns the VertexData of the ellipsoid
  23278. */
  23279. static CreateSphere(options: {
  23280. segments?: number;
  23281. diameter?: number;
  23282. diameterX?: number;
  23283. diameterY?: number;
  23284. diameterZ?: number;
  23285. arc?: number;
  23286. slice?: number;
  23287. sideOrientation?: number;
  23288. frontUVs?: Vector4;
  23289. backUVs?: Vector4;
  23290. }): VertexData;
  23291. /**
  23292. * Creates the VertexData for a cylinder, cone or prism
  23293. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23294. * * height sets the height (y direction) of the cylinder, optional, default 2
  23295. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23296. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23297. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23298. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23299. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23300. * * 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
  23301. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23302. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23303. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23304. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23306. * * 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)
  23307. * * 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)
  23308. * @returns the VertexData of the cylinder, cone or prism
  23309. */
  23310. static CreateCylinder(options: {
  23311. height?: number;
  23312. diameterTop?: number;
  23313. diameterBottom?: number;
  23314. diameter?: number;
  23315. tessellation?: number;
  23316. subdivisions?: number;
  23317. arc?: number;
  23318. faceColors?: Color4[];
  23319. faceUV?: Vector4[];
  23320. hasRings?: boolean;
  23321. enclose?: boolean;
  23322. sideOrientation?: number;
  23323. frontUVs?: Vector4;
  23324. backUVs?: Vector4;
  23325. }): VertexData;
  23326. /**
  23327. * Creates the VertexData for a torus
  23328. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23329. * * diameter the diameter of the torus, optional default 1
  23330. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23331. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23333. * * 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)
  23334. * * 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)
  23335. * @returns the VertexData of the torus
  23336. */
  23337. static CreateTorus(options: {
  23338. diameter?: number;
  23339. thickness?: number;
  23340. tessellation?: number;
  23341. sideOrientation?: number;
  23342. frontUVs?: Vector4;
  23343. backUVs?: Vector4;
  23344. }): VertexData;
  23345. /**
  23346. * Creates the VertexData of the LineSystem
  23347. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23348. * - lines an array of lines, each line being an array of successive Vector3
  23349. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23350. * @returns the VertexData of the LineSystem
  23351. */
  23352. static CreateLineSystem(options: {
  23353. lines: Vector3[][];
  23354. colors?: Nullable<Color4[][]>;
  23355. }): VertexData;
  23356. /**
  23357. * Create the VertexData for a DashedLines
  23358. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23359. * - points an array successive Vector3
  23360. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23361. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23362. * - dashNb the intended total number of dashes, optional, default 200
  23363. * @returns the VertexData for the DashedLines
  23364. */
  23365. static CreateDashedLines(options: {
  23366. points: Vector3[];
  23367. dashSize?: number;
  23368. gapSize?: number;
  23369. dashNb?: number;
  23370. }): VertexData;
  23371. /**
  23372. * Creates the VertexData for a Ground
  23373. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23374. * - width the width (x direction) of the ground, optional, default 1
  23375. * - height the height (z direction) of the ground, optional, default 1
  23376. * - subdivisions the number of subdivisions per side, optional, default 1
  23377. * @returns the VertexData of the Ground
  23378. */
  23379. static CreateGround(options: {
  23380. width?: number;
  23381. height?: number;
  23382. subdivisions?: number;
  23383. subdivisionsX?: number;
  23384. subdivisionsY?: number;
  23385. }): VertexData;
  23386. /**
  23387. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23388. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23389. * * xmin the ground minimum X coordinate, optional, default -1
  23390. * * zmin the ground minimum Z coordinate, optional, default -1
  23391. * * xmax the ground maximum X coordinate, optional, default 1
  23392. * * zmax the ground maximum Z coordinate, optional, default 1
  23393. * * 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}
  23394. * * 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}
  23395. * @returns the VertexData of the TiledGround
  23396. */
  23397. static CreateTiledGround(options: {
  23398. xmin: number;
  23399. zmin: number;
  23400. xmax: number;
  23401. zmax: number;
  23402. subdivisions?: {
  23403. w: number;
  23404. h: number;
  23405. };
  23406. precision?: {
  23407. w: number;
  23408. h: number;
  23409. };
  23410. }): VertexData;
  23411. /**
  23412. * Creates the VertexData of the Ground designed from a heightmap
  23413. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23414. * * width the width (x direction) of the ground
  23415. * * height the height (z direction) of the ground
  23416. * * subdivisions the number of subdivisions per side
  23417. * * minHeight the minimum altitude on the ground, optional, default 0
  23418. * * maxHeight the maximum altitude on the ground, optional default 1
  23419. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23420. * * buffer the array holding the image color data
  23421. * * bufferWidth the width of image
  23422. * * bufferHeight the height of image
  23423. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23424. * @returns the VertexData of the Ground designed from a heightmap
  23425. */
  23426. static CreateGroundFromHeightMap(options: {
  23427. width: number;
  23428. height: number;
  23429. subdivisions: number;
  23430. minHeight: number;
  23431. maxHeight: number;
  23432. colorFilter: Color3;
  23433. buffer: Uint8Array;
  23434. bufferWidth: number;
  23435. bufferHeight: number;
  23436. alphaFilter: number;
  23437. }): VertexData;
  23438. /**
  23439. * Creates the VertexData for a Plane
  23440. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23441. * * size sets the width and height of the plane to the value of size, optional default 1
  23442. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23443. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23445. * * 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)
  23446. * * 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)
  23447. * @returns the VertexData of the box
  23448. */
  23449. static CreatePlane(options: {
  23450. size?: number;
  23451. width?: number;
  23452. height?: number;
  23453. sideOrientation?: number;
  23454. frontUVs?: Vector4;
  23455. backUVs?: Vector4;
  23456. }): VertexData;
  23457. /**
  23458. * Creates the VertexData of the Disc or regular Polygon
  23459. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23460. * * radius the radius of the disc, optional default 0.5
  23461. * * tessellation the number of polygon sides, optional, default 64
  23462. * * 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
  23463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23464. * * 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)
  23465. * * 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)
  23466. * @returns the VertexData of the box
  23467. */
  23468. static CreateDisc(options: {
  23469. radius?: number;
  23470. tessellation?: number;
  23471. arc?: number;
  23472. sideOrientation?: number;
  23473. frontUVs?: Vector4;
  23474. backUVs?: Vector4;
  23475. }): VertexData;
  23476. /**
  23477. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23478. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23479. * @param polygon a mesh built from polygonTriangulation.build()
  23480. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23481. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23482. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23483. * @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)
  23484. * @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)
  23485. * @returns the VertexData of the Polygon
  23486. */
  23487. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23488. /**
  23489. * Creates the VertexData of the IcoSphere
  23490. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23491. * * radius the radius of the IcoSphere, optional default 1
  23492. * * radiusX allows stretching in the x direction, optional, default radius
  23493. * * radiusY allows stretching in the y direction, optional, default radius
  23494. * * radiusZ allows stretching in the z direction, optional, default radius
  23495. * * flat when true creates a flat shaded mesh, optional, default true
  23496. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23498. * * 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)
  23499. * * 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)
  23500. * @returns the VertexData of the IcoSphere
  23501. */
  23502. static CreateIcoSphere(options: {
  23503. radius?: number;
  23504. radiusX?: number;
  23505. radiusY?: number;
  23506. radiusZ?: number;
  23507. flat?: boolean;
  23508. subdivisions?: number;
  23509. sideOrientation?: number;
  23510. frontUVs?: Vector4;
  23511. backUVs?: Vector4;
  23512. }): VertexData;
  23513. /**
  23514. * Creates the VertexData for a Polyhedron
  23515. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23516. * * type provided types are:
  23517. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23518. * * 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)
  23519. * * size the size of the IcoSphere, optional default 1
  23520. * * sizeX allows stretching in the x direction, optional, default size
  23521. * * sizeY allows stretching in the y direction, optional, default size
  23522. * * sizeZ allows stretching in the z direction, optional, default size
  23523. * * 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
  23524. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23525. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23526. * * flat when true creates a flat shaded mesh, optional, default true
  23527. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23529. * * 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)
  23530. * * 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)
  23531. * @returns the VertexData of the Polyhedron
  23532. */
  23533. static CreatePolyhedron(options: {
  23534. type?: number;
  23535. size?: number;
  23536. sizeX?: number;
  23537. sizeY?: number;
  23538. sizeZ?: number;
  23539. custom?: any;
  23540. faceUV?: Vector4[];
  23541. faceColors?: Color4[];
  23542. flat?: boolean;
  23543. sideOrientation?: number;
  23544. frontUVs?: Vector4;
  23545. backUVs?: Vector4;
  23546. }): VertexData;
  23547. /**
  23548. * Creates the VertexData for a TorusKnot
  23549. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23550. * * radius the radius of the torus knot, optional, default 2
  23551. * * tube the thickness of the tube, optional, default 0.5
  23552. * * radialSegments the number of sides on each tube segments, optional, default 32
  23553. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23554. * * p the number of windings around the z axis, optional, default 2
  23555. * * q the number of windings around the x axis, optional, default 3
  23556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23557. * * 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)
  23558. * * 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)
  23559. * @returns the VertexData of the Torus Knot
  23560. */
  23561. static CreateTorusKnot(options: {
  23562. radius?: number;
  23563. tube?: number;
  23564. radialSegments?: number;
  23565. tubularSegments?: number;
  23566. p?: number;
  23567. q?: number;
  23568. sideOrientation?: number;
  23569. frontUVs?: Vector4;
  23570. backUVs?: Vector4;
  23571. }): VertexData;
  23572. /**
  23573. * Compute normals for given positions and indices
  23574. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23575. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23576. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23577. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23578. * * facetNormals : optional array of facet normals (vector3)
  23579. * * facetPositions : optional array of facet positions (vector3)
  23580. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23581. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23582. * * bInfo : optional bounding info, required for facetPartitioning computation
  23583. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23584. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23585. * * useRightHandedSystem: optional boolean to for right handed system computation
  23586. * * depthSort : optional boolean to enable the facet depth sort computation
  23587. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23588. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23589. */
  23590. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23591. facetNormals?: any;
  23592. facetPositions?: any;
  23593. facetPartitioning?: any;
  23594. ratio?: number;
  23595. bInfo?: any;
  23596. bbSize?: Vector3;
  23597. subDiv?: any;
  23598. useRightHandedSystem?: boolean;
  23599. depthSort?: boolean;
  23600. distanceTo?: Vector3;
  23601. depthSortedFacets?: any;
  23602. }): void;
  23603. /** @hidden */
  23604. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23605. /**
  23606. * Applies VertexData created from the imported parameters to the geometry
  23607. * @param parsedVertexData the parsed data from an imported file
  23608. * @param geometry the geometry to apply the VertexData to
  23609. */
  23610. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23611. }
  23612. }
  23613. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23614. import { Nullable } from "babylonjs/types";
  23615. import { Scene } from "babylonjs/scene";
  23616. import { Vector4 } from "babylonjs/Maths/math";
  23617. import { Mesh } from "babylonjs/Meshes/mesh";
  23618. /**
  23619. * Class containing static functions to help procedurally build meshes
  23620. */
  23621. export class DiscBuilder {
  23622. /**
  23623. * Creates a plane polygonal mesh. By default, this is a disc
  23624. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23625. * * 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
  23626. * * 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
  23627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23630. * @param name defines the name of the mesh
  23631. * @param options defines the options used to create the mesh
  23632. * @param scene defines the hosting scene
  23633. * @returns the plane polygonal mesh
  23634. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23635. */
  23636. static CreateDisc(name: string, options: {
  23637. radius?: number;
  23638. tessellation?: number;
  23639. arc?: number;
  23640. updatable?: boolean;
  23641. sideOrientation?: number;
  23642. frontUVs?: Vector4;
  23643. backUVs?: Vector4;
  23644. }, scene?: Nullable<Scene>): Mesh;
  23645. }
  23646. }
  23647. declare module "babylonjs/Particles/solidParticleSystem" {
  23648. import { Vector3 } from "babylonjs/Maths/math";
  23649. import { Mesh } from "babylonjs/Meshes/mesh";
  23650. import { Scene, IDisposable } from "babylonjs/scene";
  23651. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23652. /**
  23653. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23654. *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.
  23655. * The SPS is also a particle system. It provides some methods to manage the particles.
  23656. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23657. *
  23658. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23659. */
  23660. export class SolidParticleSystem implements IDisposable {
  23661. /**
  23662. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23663. * Example : var p = SPS.particles[i];
  23664. */
  23665. particles: SolidParticle[];
  23666. /**
  23667. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23668. */
  23669. nbParticles: number;
  23670. /**
  23671. * If the particles must ever face the camera (default false). Useful for planar particles.
  23672. */
  23673. billboard: boolean;
  23674. /**
  23675. * Recompute normals when adding a shape
  23676. */
  23677. recomputeNormals: boolean;
  23678. /**
  23679. * This a counter ofr your own usage. It's not set by any SPS functions.
  23680. */
  23681. counter: number;
  23682. /**
  23683. * The SPS name. This name is also given to the underlying mesh.
  23684. */
  23685. name: string;
  23686. /**
  23687. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23688. */
  23689. mesh: Mesh;
  23690. /**
  23691. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23692. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23693. */
  23694. vars: any;
  23695. /**
  23696. * This array is populated when the SPS is set as 'pickable'.
  23697. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23698. * Each element of this array is an object `{idx: int, faceId: int}`.
  23699. * `idx` is the picked particle index in the `SPS.particles` array
  23700. * `faceId` is the picked face index counted within this particle.
  23701. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23702. */
  23703. pickedParticles: {
  23704. idx: number;
  23705. faceId: number;
  23706. }[];
  23707. /**
  23708. * This array is populated when `enableDepthSort` is set to true.
  23709. * Each element of this array is an instance of the class DepthSortedParticle.
  23710. */
  23711. depthSortedParticles: DepthSortedParticle[];
  23712. /**
  23713. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23714. * @hidden
  23715. */
  23716. _bSphereOnly: boolean;
  23717. /**
  23718. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23719. * @hidden
  23720. */
  23721. _bSphereRadiusFactor: number;
  23722. private _scene;
  23723. private _positions;
  23724. private _indices;
  23725. private _normals;
  23726. private _colors;
  23727. private _uvs;
  23728. private _indices32;
  23729. private _positions32;
  23730. private _normals32;
  23731. private _fixedNormal32;
  23732. private _colors32;
  23733. private _uvs32;
  23734. private _index;
  23735. private _updatable;
  23736. private _pickable;
  23737. private _isVisibilityBoxLocked;
  23738. private _alwaysVisible;
  23739. private _depthSort;
  23740. private _shapeCounter;
  23741. private _copy;
  23742. private _color;
  23743. private _computeParticleColor;
  23744. private _computeParticleTexture;
  23745. private _computeParticleRotation;
  23746. private _computeParticleVertex;
  23747. private _computeBoundingBox;
  23748. private _depthSortParticles;
  23749. private _camera;
  23750. private _mustUnrotateFixedNormals;
  23751. private _particlesIntersect;
  23752. private _needs32Bits;
  23753. /**
  23754. * Creates a SPS (Solid Particle System) object.
  23755. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23756. * @param scene (Scene) is the scene in which the SPS is added.
  23757. * @param options defines the options of the sps e.g.
  23758. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23759. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23760. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23761. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23762. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23763. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23764. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23765. */
  23766. constructor(name: string, scene: Scene, options?: {
  23767. updatable?: boolean;
  23768. isPickable?: boolean;
  23769. enableDepthSort?: boolean;
  23770. particleIntersection?: boolean;
  23771. boundingSphereOnly?: boolean;
  23772. bSphereRadiusFactor?: number;
  23773. });
  23774. /**
  23775. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23776. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23777. * @returns the created mesh
  23778. */
  23779. buildMesh(): Mesh;
  23780. /**
  23781. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23782. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23783. * Thus the particles generated from `digest()` have their property `position` set yet.
  23784. * @param mesh ( Mesh ) is the mesh to be digested
  23785. * @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
  23786. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23787. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23788. * @returns the current SPS
  23789. */
  23790. digest(mesh: Mesh, options?: {
  23791. facetNb?: number;
  23792. number?: number;
  23793. delta?: number;
  23794. }): SolidParticleSystem;
  23795. private _unrotateFixedNormals;
  23796. private _resetCopy;
  23797. private _meshBuilder;
  23798. private _posToShape;
  23799. private _uvsToShapeUV;
  23800. private _addParticle;
  23801. /**
  23802. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23803. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23804. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23805. * @param nb (positive integer) the number of particles to be created from this model
  23806. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23807. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23808. * @returns the number of shapes in the system
  23809. */
  23810. addShape(mesh: Mesh, nb: number, options?: {
  23811. positionFunction?: any;
  23812. vertexFunction?: any;
  23813. }): number;
  23814. private _rebuildParticle;
  23815. /**
  23816. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23817. * @returns the SPS.
  23818. */
  23819. rebuildMesh(): SolidParticleSystem;
  23820. /**
  23821. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23822. * This method calls `updateParticle()` for each particle of the SPS.
  23823. * For an animated SPS, it is usually called within the render loop.
  23824. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23825. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23826. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23827. * @returns the SPS.
  23828. */
  23829. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23830. /**
  23831. * Disposes the SPS.
  23832. */
  23833. dispose(): void;
  23834. /**
  23835. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23836. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23837. * @returns the SPS.
  23838. */
  23839. refreshVisibleSize(): SolidParticleSystem;
  23840. /**
  23841. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23842. * @param size the size (float) of the visibility box
  23843. * note : this doesn't lock the SPS mesh bounding box.
  23844. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23845. */
  23846. setVisibilityBox(size: number): void;
  23847. /**
  23848. * Gets whether the SPS as always visible or not
  23849. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23850. */
  23851. /**
  23852. * Sets the SPS as always visible or not
  23853. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23854. */
  23855. isAlwaysVisible: boolean;
  23856. /**
  23857. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23858. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23859. */
  23860. /**
  23861. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23862. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23863. */
  23864. isVisibilityBoxLocked: boolean;
  23865. /**
  23866. * Tells to `setParticles()` to compute the particle rotations or not.
  23867. * Default value : true. The SPS is faster when it's set to false.
  23868. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23869. */
  23870. /**
  23871. * Gets if `setParticles()` computes the particle rotations or not.
  23872. * Default value : true. The SPS is faster when it's set to false.
  23873. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23874. */
  23875. computeParticleRotation: boolean;
  23876. /**
  23877. * Tells to `setParticles()` to compute the particle colors or not.
  23878. * Default value : true. The SPS is faster when it's set to false.
  23879. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23880. */
  23881. /**
  23882. * Gets if `setParticles()` computes the particle colors or not.
  23883. * Default value : true. The SPS is faster when it's set to false.
  23884. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23885. */
  23886. computeParticleColor: boolean;
  23887. /**
  23888. * Gets if `setParticles()` computes the particle textures or not.
  23889. * Default value : true. The SPS is faster when it's set to false.
  23890. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23891. */
  23892. computeParticleTexture: boolean;
  23893. /**
  23894. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23895. * Default value : false. The SPS is faster when it's set to false.
  23896. * Note : the particle custom vertex positions aren't stored values.
  23897. */
  23898. /**
  23899. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23900. * Default value : false. The SPS is faster when it's set to false.
  23901. * Note : the particle custom vertex positions aren't stored values.
  23902. */
  23903. computeParticleVertex: boolean;
  23904. /**
  23905. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23906. */
  23907. /**
  23908. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23909. */
  23910. computeBoundingBox: boolean;
  23911. /**
  23912. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23913. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23914. * Default : `true`
  23915. */
  23916. /**
  23917. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23918. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23919. * Default : `true`
  23920. */
  23921. depthSortParticles: boolean;
  23922. /**
  23923. * This function does nothing. It may be overwritten to set all the particle first values.
  23924. * The SPS doesn't call this function, you may have to call it by your own.
  23925. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23926. */
  23927. initParticles(): void;
  23928. /**
  23929. * This function does nothing. It may be overwritten to recycle a particle.
  23930. * The SPS doesn't call this function, you may have to call it by your own.
  23931. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23932. * @param particle The particle to recycle
  23933. * @returns the recycled particle
  23934. */
  23935. recycleParticle(particle: SolidParticle): SolidParticle;
  23936. /**
  23937. * Updates a particle : this function should be overwritten by the user.
  23938. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23939. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23940. * @example : just set a particle position or velocity and recycle conditions
  23941. * @param particle The particle to update
  23942. * @returns the updated particle
  23943. */
  23944. updateParticle(particle: SolidParticle): SolidParticle;
  23945. /**
  23946. * Updates a vertex of a particle : it can be overwritten by the user.
  23947. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23948. * @param particle the current particle
  23949. * @param vertex the current index of the current particle
  23950. * @param pt the index of the current vertex in the particle shape
  23951. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23952. * @example : just set a vertex particle position
  23953. * @returns the updated vertex
  23954. */
  23955. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23956. /**
  23957. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23958. * This does nothing and may be overwritten by the user.
  23959. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23960. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23961. * @param update the boolean update value actually passed to setParticles()
  23962. */
  23963. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23964. /**
  23965. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23966. * This will be passed three parameters.
  23967. * This does nothing and may be overwritten by the user.
  23968. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23969. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23970. * @param update the boolean update value actually passed to setParticles()
  23971. */
  23972. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23973. }
  23974. }
  23975. declare module "babylonjs/Particles/solidParticle" {
  23976. import { Nullable } from "babylonjs/types";
  23977. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23978. import { Mesh } from "babylonjs/Meshes/mesh";
  23979. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23980. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23981. /**
  23982. * Represents one particle of a solid particle system.
  23983. */
  23984. export class SolidParticle {
  23985. /**
  23986. * particle global index
  23987. */
  23988. idx: number;
  23989. /**
  23990. * The color of the particle
  23991. */
  23992. color: Nullable<Color4>;
  23993. /**
  23994. * The world space position of the particle.
  23995. */
  23996. position: Vector3;
  23997. /**
  23998. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23999. */
  24000. rotation: Vector3;
  24001. /**
  24002. * The world space rotation quaternion of the particle.
  24003. */
  24004. rotationQuaternion: Nullable<Quaternion>;
  24005. /**
  24006. * The scaling of the particle.
  24007. */
  24008. scaling: Vector3;
  24009. /**
  24010. * The uvs of the particle.
  24011. */
  24012. uvs: Vector4;
  24013. /**
  24014. * The current speed of the particle.
  24015. */
  24016. velocity: Vector3;
  24017. /**
  24018. * The pivot point in the particle local space.
  24019. */
  24020. pivot: Vector3;
  24021. /**
  24022. * Must the particle be translated from its pivot point in its local space ?
  24023. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24024. * Default : false
  24025. */
  24026. translateFromPivot: boolean;
  24027. /**
  24028. * Is the particle active or not ?
  24029. */
  24030. alive: boolean;
  24031. /**
  24032. * Is the particle visible or not ?
  24033. */
  24034. isVisible: boolean;
  24035. /**
  24036. * Index of this particle in the global "positions" array (Internal use)
  24037. * @hidden
  24038. */
  24039. _pos: number;
  24040. /**
  24041. * @hidden Index of this particle in the global "indices" array (Internal use)
  24042. */
  24043. _ind: number;
  24044. /**
  24045. * @hidden ModelShape of this particle (Internal use)
  24046. */
  24047. _model: ModelShape;
  24048. /**
  24049. * ModelShape id of this particle
  24050. */
  24051. shapeId: number;
  24052. /**
  24053. * Index of the particle in its shape id (Internal use)
  24054. */
  24055. idxInShape: number;
  24056. /**
  24057. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24058. */
  24059. _modelBoundingInfo: BoundingInfo;
  24060. /**
  24061. * @hidden Particle BoundingInfo object (Internal use)
  24062. */
  24063. _boundingInfo: BoundingInfo;
  24064. /**
  24065. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24066. */
  24067. _sps: SolidParticleSystem;
  24068. /**
  24069. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24070. */
  24071. _stillInvisible: boolean;
  24072. /**
  24073. * @hidden Last computed particle rotation matrix
  24074. */
  24075. _rotationMatrix: number[];
  24076. /**
  24077. * Parent particle Id, if any.
  24078. * Default null.
  24079. */
  24080. parentId: Nullable<number>;
  24081. /**
  24082. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24083. * The possible values are :
  24084. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24085. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24086. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24087. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24088. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24089. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24090. * */
  24091. cullingStrategy: number;
  24092. /**
  24093. * @hidden Internal global position in the SPS.
  24094. */
  24095. _globalPosition: Vector3;
  24096. /**
  24097. * Creates a Solid Particle object.
  24098. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24099. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24100. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24101. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24102. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24103. * @param shapeId (integer) is the model shape identifier in the SPS.
  24104. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24105. * @param sps defines the sps it is associated to
  24106. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24107. */
  24108. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24109. /**
  24110. * Legacy support, changed scale to scaling
  24111. */
  24112. /**
  24113. * Legacy support, changed scale to scaling
  24114. */
  24115. scale: Vector3;
  24116. /**
  24117. * Legacy support, changed quaternion to rotationQuaternion
  24118. */
  24119. /**
  24120. * Legacy support, changed quaternion to rotationQuaternion
  24121. */
  24122. quaternion: Nullable<Quaternion>;
  24123. /**
  24124. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24125. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24126. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24127. * @returns true if it intersects
  24128. */
  24129. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24130. /**
  24131. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24132. * A particle is in the frustum if its bounding box intersects the frustum
  24133. * @param frustumPlanes defines the frustum to test
  24134. * @returns true if the particle is in the frustum planes
  24135. */
  24136. isInFrustum(frustumPlanes: Plane[]): boolean;
  24137. /**
  24138. * get the rotation matrix of the particle
  24139. * @hidden
  24140. */
  24141. getRotationMatrix(m: Matrix): void;
  24142. }
  24143. /**
  24144. * Represents the shape of the model used by one particle of a solid particle system.
  24145. * SPS internal tool, don't use it manually.
  24146. */
  24147. export class ModelShape {
  24148. /**
  24149. * The shape id
  24150. * @hidden
  24151. */
  24152. shapeID: number;
  24153. /**
  24154. * flat array of model positions (internal use)
  24155. * @hidden
  24156. */
  24157. _shape: Vector3[];
  24158. /**
  24159. * flat array of model UVs (internal use)
  24160. * @hidden
  24161. */
  24162. _shapeUV: number[];
  24163. /**
  24164. * length of the shape in the model indices array (internal use)
  24165. * @hidden
  24166. */
  24167. _indicesLength: number;
  24168. /**
  24169. * Custom position function (internal use)
  24170. * @hidden
  24171. */
  24172. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24173. /**
  24174. * Custom vertex function (internal use)
  24175. * @hidden
  24176. */
  24177. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24178. /**
  24179. * 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.
  24180. * SPS internal tool, don't use it manually.
  24181. * @hidden
  24182. */
  24183. 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>);
  24184. }
  24185. /**
  24186. * Represents a Depth Sorted Particle in the solid particle system.
  24187. */
  24188. export class DepthSortedParticle {
  24189. /**
  24190. * Index of the particle in the "indices" array
  24191. */
  24192. ind: number;
  24193. /**
  24194. * Length of the particle shape in the "indices" array
  24195. */
  24196. indicesLength: number;
  24197. /**
  24198. * Squared distance from the particle to the camera
  24199. */
  24200. sqDistance: number;
  24201. }
  24202. }
  24203. declare module "babylonjs/Meshes/abstractMesh" {
  24204. import { Observable } from "babylonjs/Misc/observable";
  24205. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24206. import { Camera } from "babylonjs/Cameras/camera";
  24207. import { Scene, IDisposable } from "babylonjs/scene";
  24208. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24209. import { Node } from "babylonjs/node";
  24210. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24211. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24212. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24213. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24214. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24215. import { Material } from "babylonjs/Materials/material";
  24216. import { Light } from "babylonjs/Lights/light";
  24217. import { Skeleton } from "babylonjs/Bones/skeleton";
  24218. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24219. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24220. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24221. import { Ray } from "babylonjs/Culling/ray";
  24222. import { Collider } from "babylonjs/Collisions/collider";
  24223. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24224. /**
  24225. * Class used to store all common mesh properties
  24226. */
  24227. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24228. /** No occlusion */
  24229. static OCCLUSION_TYPE_NONE: number;
  24230. /** Occlusion set to optimisitic */
  24231. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24232. /** Occlusion set to strict */
  24233. static OCCLUSION_TYPE_STRICT: number;
  24234. /** Use an accurante occlusion algorithm */
  24235. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24236. /** Use a conservative occlusion algorithm */
  24237. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24238. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24239. * Test order :
  24240. * Is the bounding sphere outside the frustum ?
  24241. * If not, are the bounding box vertices outside the frustum ?
  24242. * It not, then the cullable object is in the frustum.
  24243. */
  24244. static readonly CULLINGSTRATEGY_STANDARD: number;
  24245. /** Culling strategy : Bounding Sphere Only.
  24246. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24247. * It's also less accurate than the standard because some not visible objects can still be selected.
  24248. * Test : is the bounding sphere outside the frustum ?
  24249. * If not, then the cullable object is in the frustum.
  24250. */
  24251. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24252. /** Culling strategy : Optimistic Inclusion.
  24253. * This in an inclusion test first, then the standard exclusion test.
  24254. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24255. * 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.
  24256. * Anyway, it's as accurate as the standard strategy.
  24257. * Test :
  24258. * Is the cullable object bounding sphere center in the frustum ?
  24259. * If not, apply the default culling strategy.
  24260. */
  24261. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24262. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24263. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24264. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24265. * 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.
  24266. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24267. * Test :
  24268. * Is the cullable object bounding sphere center in the frustum ?
  24269. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24270. */
  24271. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24272. /**
  24273. * No billboard
  24274. */
  24275. static readonly BILLBOARDMODE_NONE: number;
  24276. /** Billboard on X axis */
  24277. static readonly BILLBOARDMODE_X: number;
  24278. /** Billboard on Y axis */
  24279. static readonly BILLBOARDMODE_Y: number;
  24280. /** Billboard on Z axis */
  24281. static readonly BILLBOARDMODE_Z: number;
  24282. /** Billboard on all axes */
  24283. static readonly BILLBOARDMODE_ALL: number;
  24284. private _facetData;
  24285. /**
  24286. * The culling strategy to use to check whether the mesh must be rendered or not.
  24287. * This value can be changed at any time and will be used on the next render mesh selection.
  24288. * The possible values are :
  24289. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24290. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24291. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24292. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24293. * Please read each static variable documentation to get details about the culling process.
  24294. * */
  24295. cullingStrategy: number;
  24296. /**
  24297. * Gets the number of facets in the mesh
  24298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24299. */
  24300. readonly facetNb: number;
  24301. /**
  24302. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24304. */
  24305. partitioningSubdivisions: number;
  24306. /**
  24307. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24308. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24310. */
  24311. partitioningBBoxRatio: number;
  24312. /**
  24313. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24314. * Works only for updatable meshes.
  24315. * Doesn't work with multi-materials
  24316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24317. */
  24318. mustDepthSortFacets: boolean;
  24319. /**
  24320. * The location (Vector3) where the facet depth sort must be computed from.
  24321. * By default, the active camera position.
  24322. * Used only when facet depth sort is enabled
  24323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24324. */
  24325. facetDepthSortFrom: Vector3;
  24326. /**
  24327. * gets a boolean indicating if facetData is enabled
  24328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24329. */
  24330. readonly isFacetDataEnabled: boolean;
  24331. /** @hidden */
  24332. _updateNonUniformScalingState(value: boolean): boolean;
  24333. /**
  24334. * An event triggered when this mesh collides with another one
  24335. */
  24336. onCollideObservable: Observable<AbstractMesh>;
  24337. private _onCollideObserver;
  24338. /** Set a function to call when this mesh collides with another one */
  24339. onCollide: () => void;
  24340. /**
  24341. * An event triggered when the collision's position changes
  24342. */
  24343. onCollisionPositionChangeObservable: Observable<Vector3>;
  24344. private _onCollisionPositionChangeObserver;
  24345. /** Set a function to call when the collision's position changes */
  24346. onCollisionPositionChange: () => void;
  24347. /**
  24348. * An event triggered when material is changed
  24349. */
  24350. onMaterialChangedObservable: Observable<AbstractMesh>;
  24351. /**
  24352. * Gets or sets the orientation for POV movement & rotation
  24353. */
  24354. definedFacingForward: boolean;
  24355. /** @hidden */
  24356. _occlusionQuery: Nullable<WebGLQuery>;
  24357. private _visibility;
  24358. /**
  24359. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24360. */
  24361. /**
  24362. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24363. */
  24364. visibility: number;
  24365. /** Gets or sets the alpha index used to sort transparent meshes
  24366. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24367. */
  24368. alphaIndex: number;
  24369. /**
  24370. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24371. */
  24372. isVisible: boolean;
  24373. /**
  24374. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24375. */
  24376. isPickable: boolean;
  24377. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24378. showSubMeshesBoundingBox: boolean;
  24379. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24380. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24381. */
  24382. isBlocker: boolean;
  24383. /**
  24384. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24385. */
  24386. enablePointerMoveEvents: boolean;
  24387. /**
  24388. * Specifies the rendering group id for this mesh (0 by default)
  24389. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24390. */
  24391. renderingGroupId: number;
  24392. private _material;
  24393. /** Gets or sets current material */
  24394. material: Nullable<Material>;
  24395. private _receiveShadows;
  24396. /**
  24397. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24398. * @see http://doc.babylonjs.com/babylon101/shadows
  24399. */
  24400. receiveShadows: boolean;
  24401. /** Defines color to use when rendering outline */
  24402. outlineColor: Color3;
  24403. /** Define width to use when rendering outline */
  24404. outlineWidth: number;
  24405. /** Defines color to use when rendering overlay */
  24406. overlayColor: Color3;
  24407. /** Defines alpha to use when rendering overlay */
  24408. overlayAlpha: number;
  24409. private _hasVertexAlpha;
  24410. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24411. hasVertexAlpha: boolean;
  24412. private _useVertexColors;
  24413. /** 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) */
  24414. useVertexColors: boolean;
  24415. private _computeBonesUsingShaders;
  24416. /**
  24417. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24418. */
  24419. computeBonesUsingShaders: boolean;
  24420. private _numBoneInfluencers;
  24421. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24422. numBoneInfluencers: number;
  24423. private _applyFog;
  24424. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24425. applyFog: boolean;
  24426. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24427. useOctreeForRenderingSelection: boolean;
  24428. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24429. useOctreeForPicking: boolean;
  24430. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24431. useOctreeForCollisions: boolean;
  24432. private _layerMask;
  24433. /**
  24434. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24435. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24436. */
  24437. layerMask: number;
  24438. /**
  24439. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24440. */
  24441. alwaysSelectAsActiveMesh: boolean;
  24442. /**
  24443. * Gets or sets the current action manager
  24444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24445. */
  24446. actionManager: Nullable<AbstractActionManager>;
  24447. private _checkCollisions;
  24448. private _collisionMask;
  24449. private _collisionGroup;
  24450. /**
  24451. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24452. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24453. */
  24454. ellipsoid: Vector3;
  24455. /**
  24456. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24458. */
  24459. ellipsoidOffset: Vector3;
  24460. private _collider;
  24461. private _oldPositionForCollisions;
  24462. private _diffPositionForCollisions;
  24463. /**
  24464. * Gets or sets a collision mask used to mask collisions (default is -1).
  24465. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24466. */
  24467. collisionMask: number;
  24468. /**
  24469. * Gets or sets the current collision group mask (-1 by default).
  24470. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24471. */
  24472. collisionGroup: number;
  24473. /**
  24474. * Defines edge width used when edgesRenderer is enabled
  24475. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24476. */
  24477. edgesWidth: number;
  24478. /**
  24479. * Defines edge color used when edgesRenderer is enabled
  24480. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24481. */
  24482. edgesColor: Color4;
  24483. /** @hidden */
  24484. _edgesRenderer: Nullable<IEdgesRenderer>;
  24485. /** @hidden */
  24486. _masterMesh: Nullable<AbstractMesh>;
  24487. /** @hidden */
  24488. _boundingInfo: Nullable<BoundingInfo>;
  24489. /** @hidden */
  24490. _renderId: number;
  24491. /**
  24492. * Gets or sets the list of subMeshes
  24493. * @see http://doc.babylonjs.com/how_to/multi_materials
  24494. */
  24495. subMeshes: SubMesh[];
  24496. /** @hidden */
  24497. _intersectionsInProgress: AbstractMesh[];
  24498. /** @hidden */
  24499. _unIndexed: boolean;
  24500. /** @hidden */
  24501. _lightSources: Light[];
  24502. /** @hidden */
  24503. readonly _positions: Nullable<Vector3[]>;
  24504. /** @hidden */
  24505. _waitingActions: any;
  24506. /** @hidden */
  24507. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24508. private _skeleton;
  24509. /** @hidden */
  24510. _bonesTransformMatrices: Nullable<Float32Array>;
  24511. /**
  24512. * Gets or sets a skeleton to apply skining transformations
  24513. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24514. */
  24515. skeleton: Nullable<Skeleton>;
  24516. /**
  24517. * An event triggered when the mesh is rebuilt.
  24518. */
  24519. onRebuildObservable: Observable<AbstractMesh>;
  24520. /**
  24521. * Creates a new AbstractMesh
  24522. * @param name defines the name of the mesh
  24523. * @param scene defines the hosting scene
  24524. */
  24525. constructor(name: string, scene?: Nullable<Scene>);
  24526. /**
  24527. * Returns the string "AbstractMesh"
  24528. * @returns "AbstractMesh"
  24529. */
  24530. getClassName(): string;
  24531. /**
  24532. * Gets a string representation of the current mesh
  24533. * @param fullDetails defines a boolean indicating if full details must be included
  24534. * @returns a string representation of the current mesh
  24535. */
  24536. toString(fullDetails?: boolean): string;
  24537. /** @hidden */
  24538. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24539. /** @hidden */
  24540. _rebuild(): void;
  24541. /** @hidden */
  24542. _resyncLightSources(): void;
  24543. /** @hidden */
  24544. _resyncLighSource(light: Light): void;
  24545. /** @hidden */
  24546. _unBindEffect(): void;
  24547. /** @hidden */
  24548. _removeLightSource(light: Light): void;
  24549. private _markSubMeshesAsDirty;
  24550. /** @hidden */
  24551. _markSubMeshesAsLightDirty(): void;
  24552. /** @hidden */
  24553. _markSubMeshesAsAttributesDirty(): void;
  24554. /** @hidden */
  24555. _markSubMeshesAsMiscDirty(): void;
  24556. /**
  24557. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24558. */
  24559. scaling: Vector3;
  24560. /**
  24561. * Returns true if the mesh is blocked. Implemented by child classes
  24562. */
  24563. readonly isBlocked: boolean;
  24564. /**
  24565. * Returns the mesh itself by default. Implemented by child classes
  24566. * @param camera defines the camera to use to pick the right LOD level
  24567. * @returns the currentAbstractMesh
  24568. */
  24569. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24570. /**
  24571. * Returns 0 by default. Implemented by child classes
  24572. * @returns an integer
  24573. */
  24574. getTotalVertices(): number;
  24575. /**
  24576. * Returns a positive integer : the total number of indices in this mesh geometry.
  24577. * @returns the numner of indices or zero if the mesh has no geometry.
  24578. */
  24579. getTotalIndices(): number;
  24580. /**
  24581. * Returns null by default. Implemented by child classes
  24582. * @returns null
  24583. */
  24584. getIndices(): Nullable<IndicesArray>;
  24585. /**
  24586. * Returns the array of the requested vertex data kind. Implemented by child classes
  24587. * @param kind defines the vertex data kind to use
  24588. * @returns null
  24589. */
  24590. getVerticesData(kind: string): Nullable<FloatArray>;
  24591. /**
  24592. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24593. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24594. * Note that a new underlying VertexBuffer object is created each call.
  24595. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24596. * @param kind defines vertex data kind:
  24597. * * VertexBuffer.PositionKind
  24598. * * VertexBuffer.UVKind
  24599. * * VertexBuffer.UV2Kind
  24600. * * VertexBuffer.UV3Kind
  24601. * * VertexBuffer.UV4Kind
  24602. * * VertexBuffer.UV5Kind
  24603. * * VertexBuffer.UV6Kind
  24604. * * VertexBuffer.ColorKind
  24605. * * VertexBuffer.MatricesIndicesKind
  24606. * * VertexBuffer.MatricesIndicesExtraKind
  24607. * * VertexBuffer.MatricesWeightsKind
  24608. * * VertexBuffer.MatricesWeightsExtraKind
  24609. * @param data defines the data source
  24610. * @param updatable defines if the data must be flagged as updatable (or static)
  24611. * @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
  24612. * @returns the current mesh
  24613. */
  24614. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24615. /**
  24616. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24617. * If the mesh has no geometry, it is simply returned as it is.
  24618. * @param kind defines vertex data kind:
  24619. * * VertexBuffer.PositionKind
  24620. * * VertexBuffer.UVKind
  24621. * * VertexBuffer.UV2Kind
  24622. * * VertexBuffer.UV3Kind
  24623. * * VertexBuffer.UV4Kind
  24624. * * VertexBuffer.UV5Kind
  24625. * * VertexBuffer.UV6Kind
  24626. * * VertexBuffer.ColorKind
  24627. * * VertexBuffer.MatricesIndicesKind
  24628. * * VertexBuffer.MatricesIndicesExtraKind
  24629. * * VertexBuffer.MatricesWeightsKind
  24630. * * VertexBuffer.MatricesWeightsExtraKind
  24631. * @param data defines the data source
  24632. * @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
  24633. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24634. * @returns the current mesh
  24635. */
  24636. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24637. /**
  24638. * Sets the mesh indices,
  24639. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24640. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24641. * @param totalVertices Defines the total number of vertices
  24642. * @returns the current mesh
  24643. */
  24644. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24645. /**
  24646. * Gets a boolean indicating if specific vertex data is present
  24647. * @param kind defines the vertex data kind to use
  24648. * @returns true is data kind is present
  24649. */
  24650. isVerticesDataPresent(kind: string): boolean;
  24651. /**
  24652. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24653. * @returns a BoundingInfo
  24654. */
  24655. getBoundingInfo(): BoundingInfo;
  24656. /**
  24657. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24658. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24659. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24660. * @returns the current mesh
  24661. */
  24662. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24663. /**
  24664. * Overwrite the current bounding info
  24665. * @param boundingInfo defines the new bounding info
  24666. * @returns the current mesh
  24667. */
  24668. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24669. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24670. readonly useBones: boolean;
  24671. /** @hidden */
  24672. _preActivate(): void;
  24673. /** @hidden */
  24674. _preActivateForIntermediateRendering(renderId: number): void;
  24675. /** @hidden */
  24676. _activate(renderId: number): void;
  24677. /**
  24678. * Gets the current world matrix
  24679. * @returns a Matrix
  24680. */
  24681. getWorldMatrix(): Matrix;
  24682. /** @hidden */
  24683. _getWorldMatrixDeterminant(): number;
  24684. /**
  24685. * Perform relative position change from the point of view of behind the front of the mesh.
  24686. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24687. * Supports definition of mesh facing forward or backward
  24688. * @param amountRight defines the distance on the right axis
  24689. * @param amountUp defines the distance on the up axis
  24690. * @param amountForward defines the distance on the forward axis
  24691. * @returns the current mesh
  24692. */
  24693. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24694. /**
  24695. * Calculate relative position change from the point of view of behind the front of the mesh.
  24696. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24697. * Supports definition of mesh facing forward or backward
  24698. * @param amountRight defines the distance on the right axis
  24699. * @param amountUp defines the distance on the up axis
  24700. * @param amountForward defines the distance on the forward axis
  24701. * @returns the new displacement vector
  24702. */
  24703. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24704. /**
  24705. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24706. * Supports definition of mesh facing forward or backward
  24707. * @param flipBack defines the flip
  24708. * @param twirlClockwise defines the twirl
  24709. * @param tiltRight defines the tilt
  24710. * @returns the current mesh
  24711. */
  24712. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24713. /**
  24714. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24715. * Supports definition of mesh facing forward or backward.
  24716. * @param flipBack defines the flip
  24717. * @param twirlClockwise defines the twirl
  24718. * @param tiltRight defines the tilt
  24719. * @returns the new rotation vector
  24720. */
  24721. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24722. /**
  24723. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24724. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24725. * @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
  24726. * @returns the new bounding vectors
  24727. */
  24728. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24729. min: Vector3;
  24730. max: Vector3;
  24731. };
  24732. /**
  24733. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24734. * This means the mesh underlying bounding box and sphere are recomputed.
  24735. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24736. * @returns the current mesh
  24737. */
  24738. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24739. /** @hidden */
  24740. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24741. /** @hidden */
  24742. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24743. /** @hidden */
  24744. _updateBoundingInfo(): AbstractMesh;
  24745. /** @hidden */
  24746. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24747. /** @hidden */
  24748. protected _afterComputeWorldMatrix(): void;
  24749. /**
  24750. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24751. * A mesh is in the frustum if its bounding box intersects the frustum
  24752. * @param frustumPlanes defines the frustum to test
  24753. * @returns true if the mesh is in the frustum planes
  24754. */
  24755. isInFrustum(frustumPlanes: Plane[]): boolean;
  24756. /**
  24757. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24758. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24759. * @param frustumPlanes defines the frustum to test
  24760. * @returns true if the mesh is completely in the frustum planes
  24761. */
  24762. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24763. /**
  24764. * True if the mesh intersects another mesh or a SolidParticle object
  24765. * @param mesh defines a target mesh or SolidParticle to test
  24766. * @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)
  24767. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24768. * @returns true if there is an intersection
  24769. */
  24770. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24771. /**
  24772. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24773. * @param point defines the point to test
  24774. * @returns true if there is an intersection
  24775. */
  24776. intersectsPoint(point: Vector3): boolean;
  24777. /**
  24778. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24779. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24780. */
  24781. checkCollisions: boolean;
  24782. /**
  24783. * Gets Collider object used to compute collisions (not physics)
  24784. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24785. */
  24786. readonly collider: Collider;
  24787. /**
  24788. * Move the mesh using collision engine
  24789. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24790. * @param displacement defines the requested displacement vector
  24791. * @returns the current mesh
  24792. */
  24793. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24794. private _onCollisionPositionChange;
  24795. /** @hidden */
  24796. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24797. /** @hidden */
  24798. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24799. /** @hidden */
  24800. _checkCollision(collider: Collider): AbstractMesh;
  24801. /** @hidden */
  24802. _generatePointsArray(): boolean;
  24803. /**
  24804. * Checks if the passed Ray intersects with the mesh
  24805. * @param ray defines the ray to use
  24806. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24807. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24808. * @returns the picking info
  24809. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24810. */
  24811. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24812. /**
  24813. * Clones the current mesh
  24814. * @param name defines the mesh name
  24815. * @param newParent defines the new mesh parent
  24816. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24817. * @returns the new mesh
  24818. */
  24819. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24820. /**
  24821. * Disposes all the submeshes of the current meshnp
  24822. * @returns the current mesh
  24823. */
  24824. releaseSubMeshes(): AbstractMesh;
  24825. /**
  24826. * Releases resources associated with this abstract mesh.
  24827. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24828. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24829. */
  24830. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24831. /**
  24832. * Adds the passed mesh as a child to the current mesh
  24833. * @param mesh defines the child mesh
  24834. * @returns the current mesh
  24835. */
  24836. addChild(mesh: AbstractMesh): AbstractMesh;
  24837. /**
  24838. * Removes the passed mesh from the current mesh children list
  24839. * @param mesh defines the child mesh
  24840. * @returns the current mesh
  24841. */
  24842. removeChild(mesh: AbstractMesh): AbstractMesh;
  24843. /** @hidden */
  24844. private _initFacetData;
  24845. /**
  24846. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24847. * This method can be called within the render loop.
  24848. * 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
  24849. * @returns the current mesh
  24850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24851. */
  24852. updateFacetData(): AbstractMesh;
  24853. /**
  24854. * Returns the facetLocalNormals array.
  24855. * The normals are expressed in the mesh local spac
  24856. * @returns an array of Vector3
  24857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24858. */
  24859. getFacetLocalNormals(): Vector3[];
  24860. /**
  24861. * Returns the facetLocalPositions array.
  24862. * The facet positions are expressed in the mesh local space
  24863. * @returns an array of Vector3
  24864. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24865. */
  24866. getFacetLocalPositions(): Vector3[];
  24867. /**
  24868. * Returns the facetLocalPartioning array
  24869. * @returns an array of array of numbers
  24870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24871. */
  24872. getFacetLocalPartitioning(): number[][];
  24873. /**
  24874. * Returns the i-th facet position in the world system.
  24875. * This method allocates a new Vector3 per call
  24876. * @param i defines the facet index
  24877. * @returns a new Vector3
  24878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24879. */
  24880. getFacetPosition(i: number): Vector3;
  24881. /**
  24882. * Sets the reference Vector3 with the i-th facet position in the world system
  24883. * @param i defines the facet index
  24884. * @param ref defines the target vector
  24885. * @returns the current mesh
  24886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24887. */
  24888. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24889. /**
  24890. * Returns the i-th facet normal in the world system.
  24891. * This method allocates a new Vector3 per call
  24892. * @param i defines the facet index
  24893. * @returns a new Vector3
  24894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24895. */
  24896. getFacetNormal(i: number): Vector3;
  24897. /**
  24898. * Sets the reference Vector3 with the i-th facet normal in the world system
  24899. * @param i defines the facet index
  24900. * @param ref defines the target vector
  24901. * @returns the current mesh
  24902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24903. */
  24904. getFacetNormalToRef(i: number, ref: Vector3): this;
  24905. /**
  24906. * 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)
  24907. * @param x defines x coordinate
  24908. * @param y defines y coordinate
  24909. * @param z defines z coordinate
  24910. * @returns the array of facet indexes
  24911. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24912. */
  24913. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24914. /**
  24915. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24916. * @param projected sets as the (x,y,z) world projection on the facet
  24917. * @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
  24918. * @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
  24919. * @param x defines x coordinate
  24920. * @param y defines y coordinate
  24921. * @param z defines z coordinate
  24922. * @returns the face index if found (or null instead)
  24923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24924. */
  24925. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24926. /**
  24927. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24928. * @param projected sets as the (x,y,z) local projection on the facet
  24929. * @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
  24930. * @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
  24931. * @param x defines x coordinate
  24932. * @param y defines y coordinate
  24933. * @param z defines z coordinate
  24934. * @returns the face index if found (or null instead)
  24935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24936. */
  24937. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24938. /**
  24939. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24940. * @returns the parameters
  24941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24942. */
  24943. getFacetDataParameters(): any;
  24944. /**
  24945. * Disables the feature FacetData and frees the related memory
  24946. * @returns the current mesh
  24947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24948. */
  24949. disableFacetData(): AbstractMesh;
  24950. /**
  24951. * Updates the AbstractMesh indices array
  24952. * @param indices defines the data source
  24953. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24954. * @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)
  24955. * @returns the current mesh
  24956. */
  24957. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24958. /**
  24959. * Creates new normals data for the mesh
  24960. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24961. * @returns the current mesh
  24962. */
  24963. createNormals(updatable: boolean): AbstractMesh;
  24964. /**
  24965. * Align the mesh with a normal
  24966. * @param normal defines the normal to use
  24967. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24968. * @returns the current mesh
  24969. */
  24970. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24971. /** @hidden */
  24972. _checkOcclusionQuery(): boolean;
  24973. }
  24974. }
  24975. declare module "babylonjs/Actions/actionEvent" {
  24976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24977. import { Nullable } from "babylonjs/types";
  24978. import { Sprite } from "babylonjs/Sprites/sprite";
  24979. import { Scene } from "babylonjs/scene";
  24980. import { Vector2 } from "babylonjs/Maths/math";
  24981. /**
  24982. * Interface used to define ActionEvent
  24983. */
  24984. export interface IActionEvent {
  24985. /** The mesh or sprite that triggered the action */
  24986. source: any;
  24987. /** The X mouse cursor position at the time of the event */
  24988. pointerX: number;
  24989. /** The Y mouse cursor position at the time of the event */
  24990. pointerY: number;
  24991. /** The mesh that is currently pointed at (can be null) */
  24992. meshUnderPointer: Nullable<AbstractMesh>;
  24993. /** the original (browser) event that triggered the ActionEvent */
  24994. sourceEvent?: any;
  24995. /** additional data for the event */
  24996. additionalData?: any;
  24997. }
  24998. /**
  24999. * ActionEvent is the event being sent when an action is triggered.
  25000. */
  25001. export class ActionEvent implements IActionEvent {
  25002. /** The mesh or sprite that triggered the action */
  25003. source: any;
  25004. /** The X mouse cursor position at the time of the event */
  25005. pointerX: number;
  25006. /** The Y mouse cursor position at the time of the event */
  25007. pointerY: number;
  25008. /** The mesh that is currently pointed at (can be null) */
  25009. meshUnderPointer: Nullable<AbstractMesh>;
  25010. /** the original (browser) event that triggered the ActionEvent */
  25011. sourceEvent?: any;
  25012. /** additional data for the event */
  25013. additionalData?: any;
  25014. /**
  25015. * Creates a new ActionEvent
  25016. * @param source The mesh or sprite that triggered the action
  25017. * @param pointerX The X mouse cursor position at the time of the event
  25018. * @param pointerY The Y mouse cursor position at the time of the event
  25019. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25020. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25021. * @param additionalData additional data for the event
  25022. */
  25023. constructor(
  25024. /** The mesh or sprite that triggered the action */
  25025. source: any,
  25026. /** The X mouse cursor position at the time of the event */
  25027. pointerX: number,
  25028. /** The Y mouse cursor position at the time of the event */
  25029. pointerY: number,
  25030. /** The mesh that is currently pointed at (can be null) */
  25031. meshUnderPointer: Nullable<AbstractMesh>,
  25032. /** the original (browser) event that triggered the ActionEvent */
  25033. sourceEvent?: any,
  25034. /** additional data for the event */
  25035. additionalData?: any);
  25036. /**
  25037. * Helper function to auto-create an ActionEvent from a source mesh.
  25038. * @param source The source mesh that triggered the event
  25039. * @param evt The original (browser) event
  25040. * @param additionalData additional data for the event
  25041. * @returns the new ActionEvent
  25042. */
  25043. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25044. /**
  25045. * Helper function to auto-create an ActionEvent from a source sprite
  25046. * @param source The source sprite that triggered the event
  25047. * @param scene Scene associated with the sprite
  25048. * @param evt The original (browser) event
  25049. * @param additionalData additional data for the event
  25050. * @returns the new ActionEvent
  25051. */
  25052. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25053. /**
  25054. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25055. * @param scene the scene where the event occurred
  25056. * @param evt The original (browser) event
  25057. * @returns the new ActionEvent
  25058. */
  25059. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25060. /**
  25061. * Helper function to auto-create an ActionEvent from a primitive
  25062. * @param prim defines the target primitive
  25063. * @param pointerPos defines the pointer position
  25064. * @param evt The original (browser) event
  25065. * @param additionalData additional data for the event
  25066. * @returns the new ActionEvent
  25067. */
  25068. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25069. }
  25070. }
  25071. declare module "babylonjs/Actions/abstractActionManager" {
  25072. import { IDisposable } from "babylonjs/scene";
  25073. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25074. import { IAction } from "babylonjs/Actions/action";
  25075. import { Nullable } from "babylonjs/types";
  25076. /**
  25077. * Abstract class used to decouple action Manager from scene and meshes.
  25078. * Do not instantiate.
  25079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25080. */
  25081. export abstract class AbstractActionManager implements IDisposable {
  25082. /** Gets the list of active triggers */
  25083. static Triggers: {
  25084. [key: string]: number;
  25085. };
  25086. /** Gets the cursor to use when hovering items */
  25087. hoverCursor: string;
  25088. /** Gets the list of actions */
  25089. actions: IAction[];
  25090. /**
  25091. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25092. */
  25093. isRecursive: boolean;
  25094. /**
  25095. * Releases all associated resources
  25096. */
  25097. abstract dispose(): void;
  25098. /**
  25099. * Does this action manager has pointer triggers
  25100. */
  25101. abstract readonly hasPointerTriggers: boolean;
  25102. /**
  25103. * Does this action manager has pick triggers
  25104. */
  25105. abstract readonly hasPickTriggers: boolean;
  25106. /**
  25107. * Process a specific trigger
  25108. * @param trigger defines the trigger to process
  25109. * @param evt defines the event details to be processed
  25110. */
  25111. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25112. /**
  25113. * Does this action manager handles actions of any of the given triggers
  25114. * @param triggers defines the triggers to be tested
  25115. * @return a boolean indicating whether one (or more) of the triggers is handled
  25116. */
  25117. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25118. /**
  25119. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25120. * speed.
  25121. * @param triggerA defines the trigger to be tested
  25122. * @param triggerB defines the trigger to be tested
  25123. * @return a boolean indicating whether one (or more) of the triggers is handled
  25124. */
  25125. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25126. /**
  25127. * Does this action manager handles actions of a given trigger
  25128. * @param trigger defines the trigger to be tested
  25129. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25130. * @return whether the trigger is handled
  25131. */
  25132. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25133. /**
  25134. * Serialize this manager to a JSON object
  25135. * @param name defines the property name to store this manager
  25136. * @returns a JSON representation of this manager
  25137. */
  25138. abstract serialize(name: string): any;
  25139. /**
  25140. * Registers an action to this action manager
  25141. * @param action defines the action to be registered
  25142. * @return the action amended (prepared) after registration
  25143. */
  25144. abstract registerAction(action: IAction): Nullable<IAction>;
  25145. /**
  25146. * Unregisters an action to this action manager
  25147. * @param action defines the action to be unregistered
  25148. * @return a boolean indicating whether the action has been unregistered
  25149. */
  25150. abstract unregisterAction(action: IAction): Boolean;
  25151. /**
  25152. * Does exist one action manager with at least one trigger
  25153. **/
  25154. static readonly HasTriggers: boolean;
  25155. /**
  25156. * Does exist one action manager with at least one pick trigger
  25157. **/
  25158. static readonly HasPickTriggers: boolean;
  25159. /**
  25160. * Does exist one action manager that handles actions of a given trigger
  25161. * @param trigger defines the trigger to be tested
  25162. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25163. **/
  25164. static HasSpecificTrigger(trigger: number): boolean;
  25165. }
  25166. }
  25167. declare module "babylonjs/node" {
  25168. import { Scene } from "babylonjs/scene";
  25169. import { Nullable } from "babylonjs/types";
  25170. import { Matrix } from "babylonjs/Maths/math";
  25171. import { Engine } from "babylonjs/Engines/engine";
  25172. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25173. import { Observable } from "babylonjs/Misc/observable";
  25174. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25175. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25176. import { Animatable } from "babylonjs/Animations/animatable";
  25177. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25178. import { Animation } from "babylonjs/Animations/animation";
  25179. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25181. /**
  25182. * Defines how a node can be built from a string name.
  25183. */
  25184. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25185. /**
  25186. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25187. */
  25188. export class Node implements IBehaviorAware<Node> {
  25189. /** @hidden */
  25190. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25191. private static _NodeConstructors;
  25192. /**
  25193. * Add a new node constructor
  25194. * @param type defines the type name of the node to construct
  25195. * @param constructorFunc defines the constructor function
  25196. */
  25197. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25198. /**
  25199. * Returns a node constructor based on type name
  25200. * @param type defines the type name
  25201. * @param name defines the new node name
  25202. * @param scene defines the hosting scene
  25203. * @param options defines optional options to transmit to constructors
  25204. * @returns the new constructor or null
  25205. */
  25206. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25207. /**
  25208. * Gets or sets the name of the node
  25209. */
  25210. name: string;
  25211. /**
  25212. * Gets or sets the id of the node
  25213. */
  25214. id: string;
  25215. /**
  25216. * Gets or sets the unique id of the node
  25217. */
  25218. uniqueId: number;
  25219. /**
  25220. * Gets or sets a string used to store user defined state for the node
  25221. */
  25222. state: string;
  25223. /**
  25224. * Gets or sets an object used to store user defined information for the node
  25225. */
  25226. metadata: any;
  25227. /**
  25228. * For internal use only. Please do not use.
  25229. */
  25230. reservedDataStore: any;
  25231. /**
  25232. * List of inspectable custom properties (used by the Inspector)
  25233. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25234. */
  25235. inspectableCustomProperties: IInspectable[];
  25236. /**
  25237. * Gets or sets a boolean used to define if the node must be serialized
  25238. */
  25239. doNotSerialize: boolean;
  25240. /** @hidden */
  25241. _isDisposed: boolean;
  25242. /**
  25243. * Gets a list of Animations associated with the node
  25244. */
  25245. animations: import("babylonjs/Animations/animation").Animation[];
  25246. protected _ranges: {
  25247. [name: string]: Nullable<AnimationRange>;
  25248. };
  25249. /**
  25250. * Callback raised when the node is ready to be used
  25251. */
  25252. onReady: (node: Node) => void;
  25253. private _isEnabled;
  25254. private _isParentEnabled;
  25255. private _isReady;
  25256. /** @hidden */
  25257. _currentRenderId: number;
  25258. private _parentRenderId;
  25259. protected _childRenderId: number;
  25260. /** @hidden */
  25261. _waitingParentId: Nullable<string>;
  25262. /** @hidden */
  25263. _scene: Scene;
  25264. /** @hidden */
  25265. _cache: any;
  25266. private _parentNode;
  25267. private _children;
  25268. /** @hidden */
  25269. _worldMatrix: Matrix;
  25270. /** @hidden */
  25271. _worldMatrixDeterminant: number;
  25272. /** @hidden */
  25273. private _sceneRootNodesIndex;
  25274. /**
  25275. * Gets a boolean indicating if the node has been disposed
  25276. * @returns true if the node was disposed
  25277. */
  25278. isDisposed(): boolean;
  25279. /**
  25280. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25281. * @see https://doc.babylonjs.com/how_to/parenting
  25282. */
  25283. parent: Nullable<Node>;
  25284. private addToSceneRootNodes;
  25285. private removeFromSceneRootNodes;
  25286. private _animationPropertiesOverride;
  25287. /**
  25288. * Gets or sets the animation properties override
  25289. */
  25290. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25291. /**
  25292. * Gets a string idenfifying the name of the class
  25293. * @returns "Node" string
  25294. */
  25295. getClassName(): string;
  25296. /** @hidden */
  25297. readonly _isNode: boolean;
  25298. /**
  25299. * An event triggered when the mesh is disposed
  25300. */
  25301. onDisposeObservable: Observable<Node>;
  25302. private _onDisposeObserver;
  25303. /**
  25304. * Sets a callback that will be raised when the node will be disposed
  25305. */
  25306. onDispose: () => void;
  25307. /**
  25308. * Creates a new Node
  25309. * @param name the name and id to be given to this node
  25310. * @param scene the scene this node will be added to
  25311. * @param addToRootNodes the node will be added to scene.rootNodes
  25312. */
  25313. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25314. /**
  25315. * Gets the scene of the node
  25316. * @returns a scene
  25317. */
  25318. getScene(): Scene;
  25319. /**
  25320. * Gets the engine of the node
  25321. * @returns a Engine
  25322. */
  25323. getEngine(): Engine;
  25324. private _behaviors;
  25325. /**
  25326. * Attach a behavior to the node
  25327. * @see http://doc.babylonjs.com/features/behaviour
  25328. * @param behavior defines the behavior to attach
  25329. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25330. * @returns the current Node
  25331. */
  25332. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25333. /**
  25334. * Remove an attached behavior
  25335. * @see http://doc.babylonjs.com/features/behaviour
  25336. * @param behavior defines the behavior to attach
  25337. * @returns the current Node
  25338. */
  25339. removeBehavior(behavior: Behavior<Node>): Node;
  25340. /**
  25341. * Gets the list of attached behaviors
  25342. * @see http://doc.babylonjs.com/features/behaviour
  25343. */
  25344. readonly behaviors: Behavior<Node>[];
  25345. /**
  25346. * Gets an attached behavior by name
  25347. * @param name defines the name of the behavior to look for
  25348. * @see http://doc.babylonjs.com/features/behaviour
  25349. * @returns null if behavior was not found else the requested behavior
  25350. */
  25351. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25352. /**
  25353. * Returns the latest update of the World matrix
  25354. * @returns a Matrix
  25355. */
  25356. getWorldMatrix(): Matrix;
  25357. /** @hidden */
  25358. _getWorldMatrixDeterminant(): number;
  25359. /**
  25360. * Returns directly the latest state of the mesh World matrix.
  25361. * A Matrix is returned.
  25362. */
  25363. readonly worldMatrixFromCache: Matrix;
  25364. /** @hidden */
  25365. _initCache(): void;
  25366. /** @hidden */
  25367. updateCache(force?: boolean): void;
  25368. /** @hidden */
  25369. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25370. /** @hidden */
  25371. _updateCache(ignoreParentClass?: boolean): void;
  25372. /** @hidden */
  25373. _isSynchronized(): boolean;
  25374. /** @hidden */
  25375. _markSyncedWithParent(): void;
  25376. /** @hidden */
  25377. isSynchronizedWithParent(): boolean;
  25378. /** @hidden */
  25379. isSynchronized(): boolean;
  25380. /**
  25381. * Is this node ready to be used/rendered
  25382. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25383. * @return true if the node is ready
  25384. */
  25385. isReady(completeCheck?: boolean): boolean;
  25386. /**
  25387. * Is this node enabled?
  25388. * 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
  25389. * @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
  25390. * @return whether this node (and its parent) is enabled
  25391. */
  25392. isEnabled(checkAncestors?: boolean): boolean;
  25393. /** @hidden */
  25394. protected _syncParentEnabledState(): void;
  25395. /**
  25396. * Set the enabled state of this node
  25397. * @param value defines the new enabled state
  25398. */
  25399. setEnabled(value: boolean): void;
  25400. /**
  25401. * Is this node a descendant of the given node?
  25402. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25403. * @param ancestor defines the parent node to inspect
  25404. * @returns a boolean indicating if this node is a descendant of the given node
  25405. */
  25406. isDescendantOf(ancestor: Node): boolean;
  25407. /** @hidden */
  25408. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25409. /**
  25410. * Will return all nodes that have this node as ascendant
  25411. * @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
  25412. * @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
  25413. * @return all children nodes of all types
  25414. */
  25415. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25416. /**
  25417. * Get all child-meshes of this node
  25418. * @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)
  25419. * @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
  25420. * @returns an array of AbstractMesh
  25421. */
  25422. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25423. /**
  25424. * Get all direct children of this node
  25425. * @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
  25426. * @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)
  25427. * @returns an array of Node
  25428. */
  25429. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25430. /** @hidden */
  25431. _setReady(state: boolean): void;
  25432. /**
  25433. * Get an animation by name
  25434. * @param name defines the name of the animation to look for
  25435. * @returns null if not found else the requested animation
  25436. */
  25437. getAnimationByName(name: string): Nullable<Animation>;
  25438. /**
  25439. * Creates an animation range for this node
  25440. * @param name defines the name of the range
  25441. * @param from defines the starting key
  25442. * @param to defines the end key
  25443. */
  25444. createAnimationRange(name: string, from: number, to: number): void;
  25445. /**
  25446. * Delete a specific animation range
  25447. * @param name defines the name of the range to delete
  25448. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25449. */
  25450. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25451. /**
  25452. * Get an animation range by name
  25453. * @param name defines the name of the animation range to look for
  25454. * @returns null if not found else the requested animation range
  25455. */
  25456. getAnimationRange(name: string): Nullable<AnimationRange>;
  25457. /**
  25458. * Gets the list of all animation ranges defined on this node
  25459. * @returns an array
  25460. */
  25461. getAnimationRanges(): Nullable<AnimationRange>[];
  25462. /**
  25463. * Will start the animation sequence
  25464. * @param name defines the range frames for animation sequence
  25465. * @param loop defines if the animation should loop (false by default)
  25466. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25467. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25468. * @returns the object created for this animation. If range does not exist, it will return null
  25469. */
  25470. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25471. /**
  25472. * Serialize animation ranges into a JSON compatible object
  25473. * @returns serialization object
  25474. */
  25475. serializeAnimationRanges(): any;
  25476. /**
  25477. * Computes the world matrix of the node
  25478. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25479. * @returns the world matrix
  25480. */
  25481. computeWorldMatrix(force?: boolean): Matrix;
  25482. /**
  25483. * Releases resources associated with this node.
  25484. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25485. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25486. */
  25487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25488. /**
  25489. * Parse animation range data from a serialization object and store them into a given node
  25490. * @param node defines where to store the animation ranges
  25491. * @param parsedNode defines the serialization object to read data from
  25492. * @param scene defines the hosting scene
  25493. */
  25494. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25495. }
  25496. }
  25497. declare module "babylonjs/Animations/animation" {
  25498. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25499. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25500. import { Nullable } from "babylonjs/types";
  25501. import { Scene } from "babylonjs/scene";
  25502. import { IAnimatable } from "babylonjs/Misc/tools";
  25503. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25504. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25505. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25506. import { Node } from "babylonjs/node";
  25507. import { Animatable } from "babylonjs/Animations/animatable";
  25508. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25509. /**
  25510. * Class used to store any kind of animation
  25511. */
  25512. export class Animation {
  25513. /**Name of the animation */
  25514. name: string;
  25515. /**Property to animate */
  25516. targetProperty: string;
  25517. /**The frames per second of the animation */
  25518. framePerSecond: number;
  25519. /**The data type of the animation */
  25520. dataType: number;
  25521. /**The loop mode of the animation */
  25522. loopMode?: number | undefined;
  25523. /**Specifies if blending should be enabled */
  25524. enableBlending?: boolean | undefined;
  25525. /**
  25526. * Use matrix interpolation instead of using direct key value when animating matrices
  25527. */
  25528. static AllowMatricesInterpolation: boolean;
  25529. /**
  25530. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25531. */
  25532. static AllowMatrixDecomposeForInterpolation: boolean;
  25533. /**
  25534. * Stores the key frames of the animation
  25535. */
  25536. private _keys;
  25537. /**
  25538. * Stores the easing function of the animation
  25539. */
  25540. private _easingFunction;
  25541. /**
  25542. * @hidden Internal use only
  25543. */
  25544. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25545. /**
  25546. * The set of event that will be linked to this animation
  25547. */
  25548. private _events;
  25549. /**
  25550. * Stores an array of target property paths
  25551. */
  25552. targetPropertyPath: string[];
  25553. /**
  25554. * Stores the blending speed of the animation
  25555. */
  25556. blendingSpeed: number;
  25557. /**
  25558. * Stores the animation ranges for the animation
  25559. */
  25560. private _ranges;
  25561. /**
  25562. * @hidden Internal use
  25563. */
  25564. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25565. /**
  25566. * Sets up an animation
  25567. * @param property The property to animate
  25568. * @param animationType The animation type to apply
  25569. * @param framePerSecond The frames per second of the animation
  25570. * @param easingFunction The easing function used in the animation
  25571. * @returns The created animation
  25572. */
  25573. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25574. /**
  25575. * Create and start an animation on a node
  25576. * @param name defines the name of the global animation that will be run on all nodes
  25577. * @param node defines the root node where the animation will take place
  25578. * @param targetProperty defines property to animate
  25579. * @param framePerSecond defines the number of frame per second yo use
  25580. * @param totalFrame defines the number of frames in total
  25581. * @param from defines the initial value
  25582. * @param to defines the final value
  25583. * @param loopMode defines which loop mode you want to use (off by default)
  25584. * @param easingFunction defines the easing function to use (linear by default)
  25585. * @param onAnimationEnd defines the callback to call when animation end
  25586. * @returns the animatable created for this animation
  25587. */
  25588. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25589. /**
  25590. * Create and start an animation on a node and its descendants
  25591. * @param name defines the name of the global animation that will be run on all nodes
  25592. * @param node defines the root node where the animation will take place
  25593. * @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
  25594. * @param targetProperty defines property to animate
  25595. * @param framePerSecond defines the number of frame per second to use
  25596. * @param totalFrame defines the number of frames in total
  25597. * @param from defines the initial value
  25598. * @param to defines the final value
  25599. * @param loopMode defines which loop mode you want to use (off by default)
  25600. * @param easingFunction defines the easing function to use (linear by default)
  25601. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25602. * @returns the list of animatables created for all nodes
  25603. * @example https://www.babylonjs-playground.com/#MH0VLI
  25604. */
  25605. 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[]>;
  25606. /**
  25607. * Creates a new animation, merges it with the existing animations and starts it
  25608. * @param name Name of the animation
  25609. * @param node Node which contains the scene that begins the animations
  25610. * @param targetProperty Specifies which property to animate
  25611. * @param framePerSecond The frames per second of the animation
  25612. * @param totalFrame The total number of frames
  25613. * @param from The frame at the beginning of the animation
  25614. * @param to The frame at the end of the animation
  25615. * @param loopMode Specifies the loop mode of the animation
  25616. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25617. * @param onAnimationEnd Callback to run once the animation is complete
  25618. * @returns Nullable animation
  25619. */
  25620. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25621. /**
  25622. * Transition property of an host to the target Value
  25623. * @param property The property to transition
  25624. * @param targetValue The target Value of the property
  25625. * @param host The object where the property to animate belongs
  25626. * @param scene Scene used to run the animation
  25627. * @param frameRate Framerate (in frame/s) to use
  25628. * @param transition The transition type we want to use
  25629. * @param duration The duration of the animation, in milliseconds
  25630. * @param onAnimationEnd Callback trigger at the end of the animation
  25631. * @returns Nullable animation
  25632. */
  25633. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25634. /**
  25635. * Return the array of runtime animations currently using this animation
  25636. */
  25637. readonly runtimeAnimations: RuntimeAnimation[];
  25638. /**
  25639. * Specifies if any of the runtime animations are currently running
  25640. */
  25641. readonly hasRunningRuntimeAnimations: boolean;
  25642. /**
  25643. * Initializes the animation
  25644. * @param name Name of the animation
  25645. * @param targetProperty Property to animate
  25646. * @param framePerSecond The frames per second of the animation
  25647. * @param dataType The data type of the animation
  25648. * @param loopMode The loop mode of the animation
  25649. * @param enableBlending Specifies if blending should be enabled
  25650. */
  25651. constructor(
  25652. /**Name of the animation */
  25653. name: string,
  25654. /**Property to animate */
  25655. targetProperty: string,
  25656. /**The frames per second of the animation */
  25657. framePerSecond: number,
  25658. /**The data type of the animation */
  25659. dataType: number,
  25660. /**The loop mode of the animation */
  25661. loopMode?: number | undefined,
  25662. /**Specifies if blending should be enabled */
  25663. enableBlending?: boolean | undefined);
  25664. /**
  25665. * Converts the animation to a string
  25666. * @param fullDetails support for multiple levels of logging within scene loading
  25667. * @returns String form of the animation
  25668. */
  25669. toString(fullDetails?: boolean): string;
  25670. /**
  25671. * Add an event to this animation
  25672. * @param event Event to add
  25673. */
  25674. addEvent(event: AnimationEvent): void;
  25675. /**
  25676. * Remove all events found at the given frame
  25677. * @param frame The frame to remove events from
  25678. */
  25679. removeEvents(frame: number): void;
  25680. /**
  25681. * Retrieves all the events from the animation
  25682. * @returns Events from the animation
  25683. */
  25684. getEvents(): AnimationEvent[];
  25685. /**
  25686. * Creates an animation range
  25687. * @param name Name of the animation range
  25688. * @param from Starting frame of the animation range
  25689. * @param to Ending frame of the animation
  25690. */
  25691. createRange(name: string, from: number, to: number): void;
  25692. /**
  25693. * Deletes an animation range by name
  25694. * @param name Name of the animation range to delete
  25695. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25696. */
  25697. deleteRange(name: string, deleteFrames?: boolean): void;
  25698. /**
  25699. * Gets the animation range by name, or null if not defined
  25700. * @param name Name of the animation range
  25701. * @returns Nullable animation range
  25702. */
  25703. getRange(name: string): Nullable<AnimationRange>;
  25704. /**
  25705. * Gets the key frames from the animation
  25706. * @returns The key frames of the animation
  25707. */
  25708. getKeys(): Array<IAnimationKey>;
  25709. /**
  25710. * Gets the highest frame rate of the animation
  25711. * @returns Highest frame rate of the animation
  25712. */
  25713. getHighestFrame(): number;
  25714. /**
  25715. * Gets the easing function of the animation
  25716. * @returns Easing function of the animation
  25717. */
  25718. getEasingFunction(): IEasingFunction;
  25719. /**
  25720. * Sets the easing function of the animation
  25721. * @param easingFunction A custom mathematical formula for animation
  25722. */
  25723. setEasingFunction(easingFunction: EasingFunction): void;
  25724. /**
  25725. * Interpolates a scalar linearly
  25726. * @param startValue Start value of the animation curve
  25727. * @param endValue End value of the animation curve
  25728. * @param gradient Scalar amount to interpolate
  25729. * @returns Interpolated scalar value
  25730. */
  25731. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25732. /**
  25733. * Interpolates a scalar cubically
  25734. * @param startValue Start value of the animation curve
  25735. * @param outTangent End tangent of the animation
  25736. * @param endValue End value of the animation curve
  25737. * @param inTangent Start tangent of the animation curve
  25738. * @param gradient Scalar amount to interpolate
  25739. * @returns Interpolated scalar value
  25740. */
  25741. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25742. /**
  25743. * Interpolates a quaternion using a spherical linear interpolation
  25744. * @param startValue Start value of the animation curve
  25745. * @param endValue End value of the animation curve
  25746. * @param gradient Scalar amount to interpolate
  25747. * @returns Interpolated quaternion value
  25748. */
  25749. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25750. /**
  25751. * Interpolates a quaternion cubically
  25752. * @param startValue Start value of the animation curve
  25753. * @param outTangent End tangent of the animation curve
  25754. * @param endValue End value of the animation curve
  25755. * @param inTangent Start tangent of the animation curve
  25756. * @param gradient Scalar amount to interpolate
  25757. * @returns Interpolated quaternion value
  25758. */
  25759. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25760. /**
  25761. * Interpolates a Vector3 linearl
  25762. * @param startValue Start value of the animation curve
  25763. * @param endValue End value of the animation curve
  25764. * @param gradient Scalar amount to interpolate
  25765. * @returns Interpolated scalar value
  25766. */
  25767. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25768. /**
  25769. * Interpolates a Vector3 cubically
  25770. * @param startValue Start value of the animation curve
  25771. * @param outTangent End tangent of the animation
  25772. * @param endValue End value of the animation curve
  25773. * @param inTangent Start tangent of the animation curve
  25774. * @param gradient Scalar amount to interpolate
  25775. * @returns InterpolatedVector3 value
  25776. */
  25777. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25778. /**
  25779. * Interpolates a Vector2 linearly
  25780. * @param startValue Start value of the animation curve
  25781. * @param endValue End value of the animation curve
  25782. * @param gradient Scalar amount to interpolate
  25783. * @returns Interpolated Vector2 value
  25784. */
  25785. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25786. /**
  25787. * Interpolates a Vector2 cubically
  25788. * @param startValue Start value of the animation curve
  25789. * @param outTangent End tangent of the animation
  25790. * @param endValue End value of the animation curve
  25791. * @param inTangent Start tangent of the animation curve
  25792. * @param gradient Scalar amount to interpolate
  25793. * @returns Interpolated Vector2 value
  25794. */
  25795. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25796. /**
  25797. * Interpolates a size linearly
  25798. * @param startValue Start value of the animation curve
  25799. * @param endValue End value of the animation curve
  25800. * @param gradient Scalar amount to interpolate
  25801. * @returns Interpolated Size value
  25802. */
  25803. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25804. /**
  25805. * Interpolates a Color3 linearly
  25806. * @param startValue Start value of the animation curve
  25807. * @param endValue End value of the animation curve
  25808. * @param gradient Scalar amount to interpolate
  25809. * @returns Interpolated Color3 value
  25810. */
  25811. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25812. /**
  25813. * @hidden Internal use only
  25814. */
  25815. _getKeyValue(value: any): any;
  25816. /**
  25817. * @hidden Internal use only
  25818. */
  25819. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25820. /**
  25821. * Defines the function to use to interpolate matrices
  25822. * @param startValue defines the start matrix
  25823. * @param endValue defines the end matrix
  25824. * @param gradient defines the gradient between both matrices
  25825. * @param result defines an optional target matrix where to store the interpolation
  25826. * @returns the interpolated matrix
  25827. */
  25828. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25829. /**
  25830. * Makes a copy of the animation
  25831. * @returns Cloned animation
  25832. */
  25833. clone(): Animation;
  25834. /**
  25835. * Sets the key frames of the animation
  25836. * @param values The animation key frames to set
  25837. */
  25838. setKeys(values: Array<IAnimationKey>): void;
  25839. /**
  25840. * Serializes the animation to an object
  25841. * @returns Serialized object
  25842. */
  25843. serialize(): any;
  25844. /**
  25845. * Float animation type
  25846. */
  25847. private static _ANIMATIONTYPE_FLOAT;
  25848. /**
  25849. * Vector3 animation type
  25850. */
  25851. private static _ANIMATIONTYPE_VECTOR3;
  25852. /**
  25853. * Quaternion animation type
  25854. */
  25855. private static _ANIMATIONTYPE_QUATERNION;
  25856. /**
  25857. * Matrix animation type
  25858. */
  25859. private static _ANIMATIONTYPE_MATRIX;
  25860. /**
  25861. * Color3 animation type
  25862. */
  25863. private static _ANIMATIONTYPE_COLOR3;
  25864. /**
  25865. * Vector2 animation type
  25866. */
  25867. private static _ANIMATIONTYPE_VECTOR2;
  25868. /**
  25869. * Size animation type
  25870. */
  25871. private static _ANIMATIONTYPE_SIZE;
  25872. /**
  25873. * Relative Loop Mode
  25874. */
  25875. private static _ANIMATIONLOOPMODE_RELATIVE;
  25876. /**
  25877. * Cycle Loop Mode
  25878. */
  25879. private static _ANIMATIONLOOPMODE_CYCLE;
  25880. /**
  25881. * Constant Loop Mode
  25882. */
  25883. private static _ANIMATIONLOOPMODE_CONSTANT;
  25884. /**
  25885. * Get the float animation type
  25886. */
  25887. static readonly ANIMATIONTYPE_FLOAT: number;
  25888. /**
  25889. * Get the Vector3 animation type
  25890. */
  25891. static readonly ANIMATIONTYPE_VECTOR3: number;
  25892. /**
  25893. * Get the Vector2 animation type
  25894. */
  25895. static readonly ANIMATIONTYPE_VECTOR2: number;
  25896. /**
  25897. * Get the Size animation type
  25898. */
  25899. static readonly ANIMATIONTYPE_SIZE: number;
  25900. /**
  25901. * Get the Quaternion animation type
  25902. */
  25903. static readonly ANIMATIONTYPE_QUATERNION: number;
  25904. /**
  25905. * Get the Matrix animation type
  25906. */
  25907. static readonly ANIMATIONTYPE_MATRIX: number;
  25908. /**
  25909. * Get the Color3 animation type
  25910. */
  25911. static readonly ANIMATIONTYPE_COLOR3: number;
  25912. /**
  25913. * Get the Relative Loop Mode
  25914. */
  25915. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25916. /**
  25917. * Get the Cycle Loop Mode
  25918. */
  25919. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25920. /**
  25921. * Get the Constant Loop Mode
  25922. */
  25923. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25924. /** @hidden */
  25925. static _UniversalLerp(left: any, right: any, amount: number): any;
  25926. /**
  25927. * Parses an animation object and creates an animation
  25928. * @param parsedAnimation Parsed animation object
  25929. * @returns Animation object
  25930. */
  25931. static Parse(parsedAnimation: any): Animation;
  25932. /**
  25933. * Appends the serialized animations from the source animations
  25934. * @param source Source containing the animations
  25935. * @param destination Target to store the animations
  25936. */
  25937. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25938. }
  25939. }
  25940. declare module "babylonjs/Materials/Textures/baseTexture" {
  25941. import { Observable } from "babylonjs/Misc/observable";
  25942. import { IAnimatable } from "babylonjs/Misc/tools";
  25943. import { Nullable } from "babylonjs/types";
  25944. import { Scene } from "babylonjs/scene";
  25945. import { Matrix, ISize } from "babylonjs/Maths/math";
  25946. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25948. /**
  25949. * Base class of all the textures in babylon.
  25950. * It groups all the common properties the materials, post process, lights... might need
  25951. * in order to make a correct use of the texture.
  25952. */
  25953. export class BaseTexture implements IAnimatable {
  25954. /**
  25955. * Default anisotropic filtering level for the application.
  25956. * It is set to 4 as a good tradeoff between perf and quality.
  25957. */
  25958. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25959. /**
  25960. * Gets or sets the unique id of the texture
  25961. */
  25962. uniqueId: number;
  25963. /**
  25964. * Define the name of the texture.
  25965. */
  25966. name: string;
  25967. /**
  25968. * Gets or sets an object used to store user defined information.
  25969. */
  25970. metadata: any;
  25971. /**
  25972. * For internal use only. Please do not use.
  25973. */
  25974. reservedDataStore: any;
  25975. private _hasAlpha;
  25976. /**
  25977. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25978. */
  25979. hasAlpha: boolean;
  25980. /**
  25981. * Defines if the alpha value should be determined via the rgb values.
  25982. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25983. */
  25984. getAlphaFromRGB: boolean;
  25985. /**
  25986. * Intensity or strength of the texture.
  25987. * It is commonly used by materials to fine tune the intensity of the texture
  25988. */
  25989. level: number;
  25990. /**
  25991. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25992. * This is part of the texture as textures usually maps to one uv set.
  25993. */
  25994. coordinatesIndex: number;
  25995. private _coordinatesMode;
  25996. /**
  25997. * How a texture is mapped.
  25998. *
  25999. * | Value | Type | Description |
  26000. * | ----- | ----------------------------------- | ----------- |
  26001. * | 0 | EXPLICIT_MODE | |
  26002. * | 1 | SPHERICAL_MODE | |
  26003. * | 2 | PLANAR_MODE | |
  26004. * | 3 | CUBIC_MODE | |
  26005. * | 4 | PROJECTION_MODE | |
  26006. * | 5 | SKYBOX_MODE | |
  26007. * | 6 | INVCUBIC_MODE | |
  26008. * | 7 | EQUIRECTANGULAR_MODE | |
  26009. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26010. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26011. */
  26012. coordinatesMode: number;
  26013. /**
  26014. * | Value | Type | Description |
  26015. * | ----- | ------------------ | ----------- |
  26016. * | 0 | CLAMP_ADDRESSMODE | |
  26017. * | 1 | WRAP_ADDRESSMODE | |
  26018. * | 2 | MIRROR_ADDRESSMODE | |
  26019. */
  26020. wrapU: number;
  26021. /**
  26022. * | Value | Type | Description |
  26023. * | ----- | ------------------ | ----------- |
  26024. * | 0 | CLAMP_ADDRESSMODE | |
  26025. * | 1 | WRAP_ADDRESSMODE | |
  26026. * | 2 | MIRROR_ADDRESSMODE | |
  26027. */
  26028. wrapV: number;
  26029. /**
  26030. * | Value | Type | Description |
  26031. * | ----- | ------------------ | ----------- |
  26032. * | 0 | CLAMP_ADDRESSMODE | |
  26033. * | 1 | WRAP_ADDRESSMODE | |
  26034. * | 2 | MIRROR_ADDRESSMODE | |
  26035. */
  26036. wrapR: number;
  26037. /**
  26038. * With compliant hardware and browser (supporting anisotropic filtering)
  26039. * this defines the level of anisotropic filtering in the texture.
  26040. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26041. */
  26042. anisotropicFilteringLevel: number;
  26043. /**
  26044. * Define if the texture is a cube texture or if false a 2d texture.
  26045. */
  26046. isCube: boolean;
  26047. /**
  26048. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26049. */
  26050. is3D: boolean;
  26051. /**
  26052. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26053. * HDR texture are usually stored in linear space.
  26054. * This only impacts the PBR and Background materials
  26055. */
  26056. gammaSpace: boolean;
  26057. /**
  26058. * Gets whether or not the texture contains RGBD data.
  26059. */
  26060. readonly isRGBD: boolean;
  26061. /**
  26062. * Is Z inverted in the texture (useful in a cube texture).
  26063. */
  26064. invertZ: boolean;
  26065. /**
  26066. * Are mip maps generated for this texture or not.
  26067. */
  26068. readonly noMipmap: boolean;
  26069. /**
  26070. * @hidden
  26071. */
  26072. lodLevelInAlpha: boolean;
  26073. /**
  26074. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26075. */
  26076. lodGenerationOffset: number;
  26077. /**
  26078. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26079. */
  26080. lodGenerationScale: number;
  26081. /**
  26082. * Define if the texture is a render target.
  26083. */
  26084. isRenderTarget: boolean;
  26085. /**
  26086. * Define the unique id of the texture in the scene.
  26087. */
  26088. readonly uid: string;
  26089. /**
  26090. * Return a string representation of the texture.
  26091. * @returns the texture as a string
  26092. */
  26093. toString(): string;
  26094. /**
  26095. * Get the class name of the texture.
  26096. * @returns "BaseTexture"
  26097. */
  26098. getClassName(): string;
  26099. /**
  26100. * Define the list of animation attached to the texture.
  26101. */
  26102. animations: import("babylonjs/Animations/animation").Animation[];
  26103. /**
  26104. * An event triggered when the texture is disposed.
  26105. */
  26106. onDisposeObservable: Observable<BaseTexture>;
  26107. private _onDisposeObserver;
  26108. /**
  26109. * Callback triggered when the texture has been disposed.
  26110. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26111. */
  26112. onDispose: () => void;
  26113. /**
  26114. * Define the current state of the loading sequence when in delayed load mode.
  26115. */
  26116. delayLoadState: number;
  26117. private _scene;
  26118. /** @hidden */
  26119. _texture: Nullable<InternalTexture>;
  26120. private _uid;
  26121. /**
  26122. * Define if the texture is preventinga material to render or not.
  26123. * If not and the texture is not ready, the engine will use a default black texture instead.
  26124. */
  26125. readonly isBlocking: boolean;
  26126. /**
  26127. * Instantiates a new BaseTexture.
  26128. * Base class of all the textures in babylon.
  26129. * It groups all the common properties the materials, post process, lights... might need
  26130. * in order to make a correct use of the texture.
  26131. * @param scene Define the scene the texture blongs to
  26132. */
  26133. constructor(scene: Nullable<Scene>);
  26134. /**
  26135. * Get the scene the texture belongs to.
  26136. * @returns the scene or null if undefined
  26137. */
  26138. getScene(): Nullable<Scene>;
  26139. /**
  26140. * Get the texture transform matrix used to offset tile the texture for istance.
  26141. * @returns the transformation matrix
  26142. */
  26143. getTextureMatrix(): Matrix;
  26144. /**
  26145. * Get the texture reflection matrix used to rotate/transform the reflection.
  26146. * @returns the reflection matrix
  26147. */
  26148. getReflectionTextureMatrix(): Matrix;
  26149. /**
  26150. * Get the underlying lower level texture from Babylon.
  26151. * @returns the insternal texture
  26152. */
  26153. getInternalTexture(): Nullable<InternalTexture>;
  26154. /**
  26155. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26156. * @returns true if ready or not blocking
  26157. */
  26158. isReadyOrNotBlocking(): boolean;
  26159. /**
  26160. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26161. * @returns true if fully ready
  26162. */
  26163. isReady(): boolean;
  26164. private _cachedSize;
  26165. /**
  26166. * Get the size of the texture.
  26167. * @returns the texture size.
  26168. */
  26169. getSize(): ISize;
  26170. /**
  26171. * Get the base size of the texture.
  26172. * It can be different from the size if the texture has been resized for POT for instance
  26173. * @returns the base size
  26174. */
  26175. getBaseSize(): ISize;
  26176. /**
  26177. * Update the sampling mode of the texture.
  26178. * Default is Trilinear mode.
  26179. *
  26180. * | Value | Type | Description |
  26181. * | ----- | ------------------ | ----------- |
  26182. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26183. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26184. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26185. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26186. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26187. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26188. * | 7 | NEAREST_LINEAR | |
  26189. * | 8 | NEAREST_NEAREST | |
  26190. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26191. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26192. * | 11 | LINEAR_LINEAR | |
  26193. * | 12 | LINEAR_NEAREST | |
  26194. *
  26195. * > _mag_: magnification filter (close to the viewer)
  26196. * > _min_: minification filter (far from the viewer)
  26197. * > _mip_: filter used between mip map levels
  26198. *@param samplingMode Define the new sampling mode of the texture
  26199. */
  26200. updateSamplingMode(samplingMode: number): void;
  26201. /**
  26202. * Scales the texture if is `canRescale()`
  26203. * @param ratio the resize factor we want to use to rescale
  26204. */
  26205. scale(ratio: number): void;
  26206. /**
  26207. * Get if the texture can rescale.
  26208. */
  26209. readonly canRescale: boolean;
  26210. /** @hidden */
  26211. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26212. /** @hidden */
  26213. _rebuild(): void;
  26214. /**
  26215. * Triggers the load sequence in delayed load mode.
  26216. */
  26217. delayLoad(): void;
  26218. /**
  26219. * Clones the texture.
  26220. * @returns the cloned texture
  26221. */
  26222. clone(): Nullable<BaseTexture>;
  26223. /**
  26224. * Get the texture underlying type (INT, FLOAT...)
  26225. */
  26226. readonly textureType: number;
  26227. /**
  26228. * Get the texture underlying format (RGB, RGBA...)
  26229. */
  26230. readonly textureFormat: number;
  26231. /**
  26232. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26233. * This will returns an RGBA array buffer containing either in values (0-255) or
  26234. * float values (0-1) depending of the underlying buffer type.
  26235. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26236. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26237. * @param buffer defines a user defined buffer to fill with data (can be null)
  26238. * @returns The Array buffer containing the pixels data.
  26239. */
  26240. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26241. /**
  26242. * Release and destroy the underlying lower level texture aka internalTexture.
  26243. */
  26244. releaseInternalTexture(): void;
  26245. /**
  26246. * Get the polynomial representation of the texture data.
  26247. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26248. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26249. */
  26250. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26251. /** @hidden */
  26252. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26253. /** @hidden */
  26254. readonly _lodTextureMid: Nullable<BaseTexture>;
  26255. /** @hidden */
  26256. readonly _lodTextureLow: Nullable<BaseTexture>;
  26257. /**
  26258. * Dispose the texture and release its associated resources.
  26259. */
  26260. dispose(): void;
  26261. /**
  26262. * Serialize the texture into a JSON representation that can be parsed later on.
  26263. * @returns the JSON representation of the texture
  26264. */
  26265. serialize(): any;
  26266. /**
  26267. * Helper function to be called back once a list of texture contains only ready textures.
  26268. * @param textures Define the list of textures to wait for
  26269. * @param callback Define the callback triggered once the entire list will be ready
  26270. */
  26271. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26272. }
  26273. }
  26274. declare module "babylonjs/Materials/uniformBuffer" {
  26275. import { Nullable, FloatArray } from "babylonjs/types";
  26276. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26277. import { Engine } from "babylonjs/Engines/engine";
  26278. import { Effect } from "babylonjs/Materials/effect";
  26279. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26280. /**
  26281. * Uniform buffer objects.
  26282. *
  26283. * Handles blocks of uniform on the GPU.
  26284. *
  26285. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26286. *
  26287. * For more information, please refer to :
  26288. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26289. */
  26290. export class UniformBuffer {
  26291. private _engine;
  26292. private _buffer;
  26293. private _data;
  26294. private _bufferData;
  26295. private _dynamic?;
  26296. private _uniformLocations;
  26297. private _uniformSizes;
  26298. private _uniformLocationPointer;
  26299. private _needSync;
  26300. private _noUBO;
  26301. private _currentEffect;
  26302. private static _MAX_UNIFORM_SIZE;
  26303. private static _tempBuffer;
  26304. /**
  26305. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26306. * This is dynamic to allow compat with webgl 1 and 2.
  26307. * You will need to pass the name of the uniform as well as the value.
  26308. */
  26309. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26310. /**
  26311. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26312. * This is dynamic to allow compat with webgl 1 and 2.
  26313. * You will need to pass the name of the uniform as well as the value.
  26314. */
  26315. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26316. /**
  26317. * Lambda to Update a single float in a uniform buffer.
  26318. * This is dynamic to allow compat with webgl 1 and 2.
  26319. * You will need to pass the name of the uniform as well as the value.
  26320. */
  26321. updateFloat: (name: string, x: number) => void;
  26322. /**
  26323. * Lambda to Update a vec2 of float in a uniform buffer.
  26324. * This is dynamic to allow compat with webgl 1 and 2.
  26325. * You will need to pass the name of the uniform as well as the value.
  26326. */
  26327. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26328. /**
  26329. * Lambda to Update a vec3 of float in a uniform buffer.
  26330. * This is dynamic to allow compat with webgl 1 and 2.
  26331. * You will need to pass the name of the uniform as well as the value.
  26332. */
  26333. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26334. /**
  26335. * Lambda to Update a vec4 of float in a uniform buffer.
  26336. * This is dynamic to allow compat with webgl 1 and 2.
  26337. * You will need to pass the name of the uniform as well as the value.
  26338. */
  26339. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26340. /**
  26341. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26342. * This is dynamic to allow compat with webgl 1 and 2.
  26343. * You will need to pass the name of the uniform as well as the value.
  26344. */
  26345. updateMatrix: (name: string, mat: Matrix) => void;
  26346. /**
  26347. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26348. * This is dynamic to allow compat with webgl 1 and 2.
  26349. * You will need to pass the name of the uniform as well as the value.
  26350. */
  26351. updateVector3: (name: string, vector: Vector3) => void;
  26352. /**
  26353. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26354. * This is dynamic to allow compat with webgl 1 and 2.
  26355. * You will need to pass the name of the uniform as well as the value.
  26356. */
  26357. updateVector4: (name: string, vector: Vector4) => void;
  26358. /**
  26359. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26360. * This is dynamic to allow compat with webgl 1 and 2.
  26361. * You will need to pass the name of the uniform as well as the value.
  26362. */
  26363. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26364. /**
  26365. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26366. * This is dynamic to allow compat with webgl 1 and 2.
  26367. * You will need to pass the name of the uniform as well as the value.
  26368. */
  26369. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26370. /**
  26371. * Instantiates a new Uniform buffer objects.
  26372. *
  26373. * Handles blocks of uniform on the GPU.
  26374. *
  26375. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26376. *
  26377. * For more information, please refer to :
  26378. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26379. * @param engine Define the engine the buffer is associated with
  26380. * @param data Define the data contained in the buffer
  26381. * @param dynamic Define if the buffer is updatable
  26382. */
  26383. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26384. /**
  26385. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26386. * or just falling back on setUniformXXX calls.
  26387. */
  26388. readonly useUbo: boolean;
  26389. /**
  26390. * Indicates if the WebGL underlying uniform buffer is in sync
  26391. * with the javascript cache data.
  26392. */
  26393. readonly isSync: boolean;
  26394. /**
  26395. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26396. * Also, a dynamic UniformBuffer will disable cache verification and always
  26397. * update the underlying WebGL uniform buffer to the GPU.
  26398. * @returns if Dynamic, otherwise false
  26399. */
  26400. isDynamic(): boolean;
  26401. /**
  26402. * The data cache on JS side.
  26403. * @returns the underlying data as a float array
  26404. */
  26405. getData(): Float32Array;
  26406. /**
  26407. * The underlying WebGL Uniform buffer.
  26408. * @returns the webgl buffer
  26409. */
  26410. getBuffer(): Nullable<WebGLBuffer>;
  26411. /**
  26412. * std140 layout specifies how to align data within an UBO structure.
  26413. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26414. * for specs.
  26415. */
  26416. private _fillAlignment;
  26417. /**
  26418. * Adds an uniform in the buffer.
  26419. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26420. * for the layout to be correct !
  26421. * @param name Name of the uniform, as used in the uniform block in the shader.
  26422. * @param size Data size, or data directly.
  26423. */
  26424. addUniform(name: string, size: number | number[]): void;
  26425. /**
  26426. * Adds a Matrix 4x4 to the uniform buffer.
  26427. * @param name Name of the uniform, as used in the uniform block in the shader.
  26428. * @param mat A 4x4 matrix.
  26429. */
  26430. addMatrix(name: string, mat: Matrix): void;
  26431. /**
  26432. * Adds a vec2 to the uniform buffer.
  26433. * @param name Name of the uniform, as used in the uniform block in the shader.
  26434. * @param x Define the x component value of the vec2
  26435. * @param y Define the y component value of the vec2
  26436. */
  26437. addFloat2(name: string, x: number, y: number): void;
  26438. /**
  26439. * Adds a vec3 to the uniform buffer.
  26440. * @param name Name of the uniform, as used in the uniform block in the shader.
  26441. * @param x Define the x component value of the vec3
  26442. * @param y Define the y component value of the vec3
  26443. * @param z Define the z component value of the vec3
  26444. */
  26445. addFloat3(name: string, x: number, y: number, z: number): void;
  26446. /**
  26447. * Adds a vec3 to the uniform buffer.
  26448. * @param name Name of the uniform, as used in the uniform block in the shader.
  26449. * @param color Define the vec3 from a Color
  26450. */
  26451. addColor3(name: string, color: Color3): void;
  26452. /**
  26453. * Adds a vec4 to the uniform buffer.
  26454. * @param name Name of the uniform, as used in the uniform block in the shader.
  26455. * @param color Define the rgb components from a Color
  26456. * @param alpha Define the a component of the vec4
  26457. */
  26458. addColor4(name: string, color: Color3, alpha: number): void;
  26459. /**
  26460. * Adds a vec3 to the uniform buffer.
  26461. * @param name Name of the uniform, as used in the uniform block in the shader.
  26462. * @param vector Define the vec3 components from a Vector
  26463. */
  26464. addVector3(name: string, vector: Vector3): void;
  26465. /**
  26466. * Adds a Matrix 3x3 to the uniform buffer.
  26467. * @param name Name of the uniform, as used in the uniform block in the shader.
  26468. */
  26469. addMatrix3x3(name: string): void;
  26470. /**
  26471. * Adds a Matrix 2x2 to the uniform buffer.
  26472. * @param name Name of the uniform, as used in the uniform block in the shader.
  26473. */
  26474. addMatrix2x2(name: string): void;
  26475. /**
  26476. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26477. */
  26478. create(): void;
  26479. /** @hidden */
  26480. _rebuild(): void;
  26481. /**
  26482. * Updates the WebGL Uniform Buffer on the GPU.
  26483. * If the `dynamic` flag is set to true, no cache comparison is done.
  26484. * Otherwise, the buffer will be updated only if the cache differs.
  26485. */
  26486. update(): void;
  26487. /**
  26488. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26489. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26490. * @param data Define the flattened data
  26491. * @param size Define the size of the data.
  26492. */
  26493. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26494. private _updateMatrix3x3ForUniform;
  26495. private _updateMatrix3x3ForEffect;
  26496. private _updateMatrix2x2ForEffect;
  26497. private _updateMatrix2x2ForUniform;
  26498. private _updateFloatForEffect;
  26499. private _updateFloatForUniform;
  26500. private _updateFloat2ForEffect;
  26501. private _updateFloat2ForUniform;
  26502. private _updateFloat3ForEffect;
  26503. private _updateFloat3ForUniform;
  26504. private _updateFloat4ForEffect;
  26505. private _updateFloat4ForUniform;
  26506. private _updateMatrixForEffect;
  26507. private _updateMatrixForUniform;
  26508. private _updateVector3ForEffect;
  26509. private _updateVector3ForUniform;
  26510. private _updateVector4ForEffect;
  26511. private _updateVector4ForUniform;
  26512. private _updateColor3ForEffect;
  26513. private _updateColor3ForUniform;
  26514. private _updateColor4ForEffect;
  26515. private _updateColor4ForUniform;
  26516. /**
  26517. * Sets a sampler uniform on the effect.
  26518. * @param name Define the name of the sampler.
  26519. * @param texture Define the texture to set in the sampler
  26520. */
  26521. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26522. /**
  26523. * Directly updates the value of the uniform in the cache AND on the GPU.
  26524. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26525. * @param data Define the flattened data
  26526. */
  26527. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26528. /**
  26529. * Binds this uniform buffer to an effect.
  26530. * @param effect Define the effect to bind the buffer to
  26531. * @param name Name of the uniform block in the shader.
  26532. */
  26533. bindToEffect(effect: Effect, name: string): void;
  26534. /**
  26535. * Disposes the uniform buffer.
  26536. */
  26537. dispose(): void;
  26538. }
  26539. }
  26540. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26541. import { Nullable } from "babylonjs/types";
  26542. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26543. /**
  26544. * This represents the required contract to create a new type of texture loader.
  26545. */
  26546. export interface IInternalTextureLoader {
  26547. /**
  26548. * Defines wether the loader supports cascade loading the different faces.
  26549. */
  26550. supportCascades: boolean;
  26551. /**
  26552. * This returns if the loader support the current file information.
  26553. * @param extension defines the file extension of the file being loaded
  26554. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26555. * @param fallback defines the fallback internal texture if any
  26556. * @param isBase64 defines whether the texture is encoded as a base64
  26557. * @param isBuffer defines whether the texture data are stored as a buffer
  26558. * @returns true if the loader can load the specified file
  26559. */
  26560. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26561. /**
  26562. * Transform the url before loading if required.
  26563. * @param rootUrl the url of the texture
  26564. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26565. * @returns the transformed texture
  26566. */
  26567. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26568. /**
  26569. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26570. * @param rootUrl the url of the texture
  26571. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26572. * @returns the fallback texture
  26573. */
  26574. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26575. /**
  26576. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26577. * @param data contains the texture data
  26578. * @param texture defines the BabylonJS internal texture
  26579. * @param createPolynomials will be true if polynomials have been requested
  26580. * @param onLoad defines the callback to trigger once the texture is ready
  26581. * @param onError defines the callback to trigger in case of error
  26582. */
  26583. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26584. /**
  26585. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26586. * @param data contains the texture data
  26587. * @param texture defines the BabylonJS internal texture
  26588. * @param callback defines the method to call once ready to upload
  26589. */
  26590. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26591. }
  26592. }
  26593. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26594. import { Scene } from "babylonjs/scene";
  26595. import { Engine } from "babylonjs/Engines/engine";
  26596. import { Texture } from "babylonjs/Materials/Textures/texture";
  26597. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26598. /**
  26599. * Creation options of the multi render target texture.
  26600. */
  26601. export interface IMultiRenderTargetOptions {
  26602. /**
  26603. * Define if the texture needs to create mip maps after render.
  26604. */
  26605. generateMipMaps?: boolean;
  26606. /**
  26607. * Define the types of all the draw buffers we want to create
  26608. */
  26609. types?: number[];
  26610. /**
  26611. * Define the sampling modes of all the draw buffers we want to create
  26612. */
  26613. samplingModes?: number[];
  26614. /**
  26615. * Define if a depth buffer is required
  26616. */
  26617. generateDepthBuffer?: boolean;
  26618. /**
  26619. * Define if a stencil buffer is required
  26620. */
  26621. generateStencilBuffer?: boolean;
  26622. /**
  26623. * Define if a depth texture is required instead of a depth buffer
  26624. */
  26625. generateDepthTexture?: boolean;
  26626. /**
  26627. * Define the number of desired draw buffers
  26628. */
  26629. textureCount?: number;
  26630. /**
  26631. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26632. */
  26633. doNotChangeAspectRatio?: boolean;
  26634. /**
  26635. * Define the default type of the buffers we are creating
  26636. */
  26637. defaultType?: number;
  26638. }
  26639. /**
  26640. * A multi render target, like a render target provides the ability to render to a texture.
  26641. * Unlike the render target, it can render to several draw buffers in one draw.
  26642. * This is specially interesting in deferred rendering or for any effects requiring more than
  26643. * just one color from a single pass.
  26644. */
  26645. export class MultiRenderTarget extends RenderTargetTexture {
  26646. private _internalTextures;
  26647. private _textures;
  26648. private _multiRenderTargetOptions;
  26649. /**
  26650. * Get if draw buffers are currently supported by the used hardware and browser.
  26651. */
  26652. readonly isSupported: boolean;
  26653. /**
  26654. * Get the list of textures generated by the multi render target.
  26655. */
  26656. readonly textures: Texture[];
  26657. /**
  26658. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26659. */
  26660. readonly depthTexture: Texture;
  26661. /**
  26662. * Set the wrapping mode on U of all the textures we are rendering to.
  26663. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26664. */
  26665. wrapU: number;
  26666. /**
  26667. * Set the wrapping mode on V of all the textures we are rendering to.
  26668. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26669. */
  26670. wrapV: number;
  26671. /**
  26672. * Instantiate a new multi render target texture.
  26673. * A multi render target, like a render target provides the ability to render to a texture.
  26674. * Unlike the render target, it can render to several draw buffers in one draw.
  26675. * This is specially interesting in deferred rendering or for any effects requiring more than
  26676. * just one color from a single pass.
  26677. * @param name Define the name of the texture
  26678. * @param size Define the size of the buffers to render to
  26679. * @param count Define the number of target we are rendering into
  26680. * @param scene Define the scene the texture belongs to
  26681. * @param options Define the options used to create the multi render target
  26682. */
  26683. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26684. /** @hidden */
  26685. _rebuild(): void;
  26686. private _createInternalTextures;
  26687. private _createTextures;
  26688. /**
  26689. * Define the number of samples used if MSAA is enabled.
  26690. */
  26691. samples: number;
  26692. /**
  26693. * Resize all the textures in the multi render target.
  26694. * Be carrefull as it will recreate all the data in the new texture.
  26695. * @param size Define the new size
  26696. */
  26697. resize(size: any): void;
  26698. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26699. /**
  26700. * Dispose the render targets and their associated resources
  26701. */
  26702. dispose(): void;
  26703. /**
  26704. * Release all the underlying texture used as draw buffers.
  26705. */
  26706. releaseInternalTextures(): void;
  26707. }
  26708. }
  26709. declare module "babylonjs/Audio/analyser" {
  26710. import { Scene } from "babylonjs/scene";
  26711. /**
  26712. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26714. */
  26715. export class Analyser {
  26716. /**
  26717. * Gets or sets the smoothing
  26718. * @ignorenaming
  26719. */
  26720. SMOOTHING: number;
  26721. /**
  26722. * Gets or sets the FFT table size
  26723. * @ignorenaming
  26724. */
  26725. FFT_SIZE: number;
  26726. /**
  26727. * Gets or sets the bar graph amplitude
  26728. * @ignorenaming
  26729. */
  26730. BARGRAPHAMPLITUDE: number;
  26731. /**
  26732. * Gets or sets the position of the debug canvas
  26733. * @ignorenaming
  26734. */
  26735. DEBUGCANVASPOS: {
  26736. x: number;
  26737. y: number;
  26738. };
  26739. /**
  26740. * Gets or sets the debug canvas size
  26741. * @ignorenaming
  26742. */
  26743. DEBUGCANVASSIZE: {
  26744. width: number;
  26745. height: number;
  26746. };
  26747. private _byteFreqs;
  26748. private _byteTime;
  26749. private _floatFreqs;
  26750. private _webAudioAnalyser;
  26751. private _debugCanvas;
  26752. private _debugCanvasContext;
  26753. private _scene;
  26754. private _registerFunc;
  26755. private _audioEngine;
  26756. /**
  26757. * Creates a new analyser
  26758. * @param scene defines hosting scene
  26759. */
  26760. constructor(scene: Scene);
  26761. /**
  26762. * Get the number of data values you will have to play with for the visualization
  26763. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26764. * @returns a number
  26765. */
  26766. getFrequencyBinCount(): number;
  26767. /**
  26768. * Gets the current frequency data as a byte array
  26769. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26770. * @returns a Uint8Array
  26771. */
  26772. getByteFrequencyData(): Uint8Array;
  26773. /**
  26774. * Gets the current waveform as a byte array
  26775. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26776. * @returns a Uint8Array
  26777. */
  26778. getByteTimeDomainData(): Uint8Array;
  26779. /**
  26780. * Gets the current frequency data as a float array
  26781. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26782. * @returns a Float32Array
  26783. */
  26784. getFloatFrequencyData(): Float32Array;
  26785. /**
  26786. * Renders the debug canvas
  26787. */
  26788. drawDebugCanvas(): void;
  26789. /**
  26790. * Stops rendering the debug canvas and removes it
  26791. */
  26792. stopDebugCanvas(): void;
  26793. /**
  26794. * Connects two audio nodes
  26795. * @param inputAudioNode defines first node to connect
  26796. * @param outputAudioNode defines second node to connect
  26797. */
  26798. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26799. /**
  26800. * Releases all associated resources
  26801. */
  26802. dispose(): void;
  26803. }
  26804. }
  26805. declare module "babylonjs/Audio/audioEngine" {
  26806. import { IDisposable } from "babylonjs/scene";
  26807. import { Analyser } from "babylonjs/Audio/analyser";
  26808. import { Nullable } from "babylonjs/types";
  26809. import { Observable } from "babylonjs/Misc/observable";
  26810. /**
  26811. * This represents an audio engine and it is responsible
  26812. * to play, synchronize and analyse sounds throughout the application.
  26813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26814. */
  26815. export interface IAudioEngine extends IDisposable {
  26816. /**
  26817. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26818. */
  26819. readonly canUseWebAudio: boolean;
  26820. /**
  26821. * Gets the current AudioContext if available.
  26822. */
  26823. readonly audioContext: Nullable<AudioContext>;
  26824. /**
  26825. * The master gain node defines the global audio volume of your audio engine.
  26826. */
  26827. readonly masterGain: GainNode;
  26828. /**
  26829. * Gets whether or not mp3 are supported by your browser.
  26830. */
  26831. readonly isMP3supported: boolean;
  26832. /**
  26833. * Gets whether or not ogg are supported by your browser.
  26834. */
  26835. readonly isOGGsupported: boolean;
  26836. /**
  26837. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26838. * @ignoreNaming
  26839. */
  26840. WarnedWebAudioUnsupported: boolean;
  26841. /**
  26842. * Defines if the audio engine relies on a custom unlocked button.
  26843. * In this case, the embedded button will not be displayed.
  26844. */
  26845. useCustomUnlockedButton: boolean;
  26846. /**
  26847. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26848. */
  26849. readonly unlocked: boolean;
  26850. /**
  26851. * Event raised when audio has been unlocked on the browser.
  26852. */
  26853. onAudioUnlockedObservable: Observable<AudioEngine>;
  26854. /**
  26855. * Event raised when audio has been locked on the browser.
  26856. */
  26857. onAudioLockedObservable: Observable<AudioEngine>;
  26858. /**
  26859. * Flags the audio engine in Locked state.
  26860. * This happens due to new browser policies preventing audio to autoplay.
  26861. */
  26862. lock(): void;
  26863. /**
  26864. * Unlocks the audio engine once a user action has been done on the dom.
  26865. * This is helpful to resume play once browser policies have been satisfied.
  26866. */
  26867. unlock(): void;
  26868. }
  26869. /**
  26870. * This represents the default audio engine used in babylon.
  26871. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26873. */
  26874. export class AudioEngine implements IAudioEngine {
  26875. private _audioContext;
  26876. private _audioContextInitialized;
  26877. private _muteButton;
  26878. private _hostElement;
  26879. /**
  26880. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26881. */
  26882. canUseWebAudio: boolean;
  26883. /**
  26884. * The master gain node defines the global audio volume of your audio engine.
  26885. */
  26886. masterGain: GainNode;
  26887. /**
  26888. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26889. * @ignoreNaming
  26890. */
  26891. WarnedWebAudioUnsupported: boolean;
  26892. /**
  26893. * Gets whether or not mp3 are supported by your browser.
  26894. */
  26895. isMP3supported: boolean;
  26896. /**
  26897. * Gets whether or not ogg are supported by your browser.
  26898. */
  26899. isOGGsupported: boolean;
  26900. /**
  26901. * Gets whether audio has been unlocked on the device.
  26902. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26903. * a user interaction has happened.
  26904. */
  26905. unlocked: boolean;
  26906. /**
  26907. * Defines if the audio engine relies on a custom unlocked button.
  26908. * In this case, the embedded button will not be displayed.
  26909. */
  26910. useCustomUnlockedButton: boolean;
  26911. /**
  26912. * Event raised when audio has been unlocked on the browser.
  26913. */
  26914. onAudioUnlockedObservable: Observable<AudioEngine>;
  26915. /**
  26916. * Event raised when audio has been locked on the browser.
  26917. */
  26918. onAudioLockedObservable: Observable<AudioEngine>;
  26919. /**
  26920. * Gets the current AudioContext if available.
  26921. */
  26922. readonly audioContext: Nullable<AudioContext>;
  26923. private _connectedAnalyser;
  26924. /**
  26925. * Instantiates a new audio engine.
  26926. *
  26927. * There should be only one per page as some browsers restrict the number
  26928. * of audio contexts you can create.
  26929. * @param hostElement defines the host element where to display the mute icon if necessary
  26930. */
  26931. constructor(hostElement?: Nullable<HTMLElement>);
  26932. /**
  26933. * Flags the audio engine in Locked state.
  26934. * This happens due to new browser policies preventing audio to autoplay.
  26935. */
  26936. lock(): void;
  26937. /**
  26938. * Unlocks the audio engine once a user action has been done on the dom.
  26939. * This is helpful to resume play once browser policies have been satisfied.
  26940. */
  26941. unlock(): void;
  26942. private _resumeAudioContext;
  26943. private _initializeAudioContext;
  26944. private _tryToRun;
  26945. private _triggerRunningState;
  26946. private _triggerSuspendedState;
  26947. private _displayMuteButton;
  26948. private _moveButtonToTopLeft;
  26949. private _onResize;
  26950. private _hideMuteButton;
  26951. /**
  26952. * Destroy and release the resources associated with the audio ccontext.
  26953. */
  26954. dispose(): void;
  26955. /**
  26956. * Gets the global volume sets on the master gain.
  26957. * @returns the global volume if set or -1 otherwise
  26958. */
  26959. getGlobalVolume(): number;
  26960. /**
  26961. * Sets the global volume of your experience (sets on the master gain).
  26962. * @param newVolume Defines the new global volume of the application
  26963. */
  26964. setGlobalVolume(newVolume: number): void;
  26965. /**
  26966. * Connect the audio engine to an audio analyser allowing some amazing
  26967. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26969. * @param analyser The analyser to connect to the engine
  26970. */
  26971. connectToAnalyser(analyser: Analyser): void;
  26972. }
  26973. }
  26974. declare module "babylonjs/Loading/loadingScreen" {
  26975. /**
  26976. * Interface used to present a loading screen while loading a scene
  26977. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26978. */
  26979. export interface ILoadingScreen {
  26980. /**
  26981. * Function called to display the loading screen
  26982. */
  26983. displayLoadingUI: () => void;
  26984. /**
  26985. * Function called to hide the loading screen
  26986. */
  26987. hideLoadingUI: () => void;
  26988. /**
  26989. * Gets or sets the color to use for the background
  26990. */
  26991. loadingUIBackgroundColor: string;
  26992. /**
  26993. * Gets or sets the text to display while loading
  26994. */
  26995. loadingUIText: string;
  26996. }
  26997. /**
  26998. * Class used for the default loading screen
  26999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27000. */
  27001. export class DefaultLoadingScreen implements ILoadingScreen {
  27002. private _renderingCanvas;
  27003. private _loadingText;
  27004. private _loadingDivBackgroundColor;
  27005. private _loadingDiv;
  27006. private _loadingTextDiv;
  27007. /**
  27008. * Creates a new default loading screen
  27009. * @param _renderingCanvas defines the canvas used to render the scene
  27010. * @param _loadingText defines the default text to display
  27011. * @param _loadingDivBackgroundColor defines the default background color
  27012. */
  27013. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27014. /**
  27015. * Function called to display the loading screen
  27016. */
  27017. displayLoadingUI(): void;
  27018. /**
  27019. * Function called to hide the loading screen
  27020. */
  27021. hideLoadingUI(): void;
  27022. /**
  27023. * Gets or sets the text to display while loading
  27024. */
  27025. loadingUIText: string;
  27026. /**
  27027. * Gets or sets the color to use for the background
  27028. */
  27029. loadingUIBackgroundColor: string;
  27030. private _resizeLoadingUI;
  27031. }
  27032. }
  27033. declare module "babylonjs/Materials/Textures/videoTexture" {
  27034. import { Observable } from "babylonjs/Misc/observable";
  27035. import { Nullable } from "babylonjs/types";
  27036. import { Scene } from "babylonjs/scene";
  27037. import { Texture } from "babylonjs/Materials/Textures/texture";
  27038. /**
  27039. * Settings for finer control over video usage
  27040. */
  27041. export interface VideoTextureSettings {
  27042. /**
  27043. * Applies `autoplay` to video, if specified
  27044. */
  27045. autoPlay?: boolean;
  27046. /**
  27047. * Applies `loop` to video, if specified
  27048. */
  27049. loop?: boolean;
  27050. /**
  27051. * Automatically updates internal texture from video at every frame in the render loop
  27052. */
  27053. autoUpdateTexture: boolean;
  27054. /**
  27055. * Image src displayed during the video loading or until the user interacts with the video.
  27056. */
  27057. poster?: string;
  27058. }
  27059. /**
  27060. * If you want to display a video in your scene, this is the special texture for that.
  27061. * This special texture works similar to other textures, with the exception of a few parameters.
  27062. * @see https://doc.babylonjs.com/how_to/video_texture
  27063. */
  27064. export class VideoTexture extends Texture {
  27065. /**
  27066. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27067. */
  27068. readonly autoUpdateTexture: boolean;
  27069. /**
  27070. * The video instance used by the texture internally
  27071. */
  27072. readonly video: HTMLVideoElement;
  27073. private _onUserActionRequestedObservable;
  27074. /**
  27075. * Event triggerd when a dom action is required by the user to play the video.
  27076. * This happens due to recent changes in browser policies preventing video to auto start.
  27077. */
  27078. readonly onUserActionRequestedObservable: Observable<Texture>;
  27079. private _generateMipMaps;
  27080. private _engine;
  27081. private _stillImageCaptured;
  27082. private _displayingPosterTexture;
  27083. private _settings;
  27084. private _createInternalTextureOnEvent;
  27085. /**
  27086. * Creates a video texture.
  27087. * If you want to display a video in your scene, this is the special texture for that.
  27088. * This special texture works similar to other textures, with the exception of a few parameters.
  27089. * @see https://doc.babylonjs.com/how_to/video_texture
  27090. * @param name optional name, will detect from video source, if not defined
  27091. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27092. * @param scene is obviously the current scene.
  27093. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27094. * @param invertY is false by default but can be used to invert video on Y axis
  27095. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27096. * @param settings allows finer control over video usage
  27097. */
  27098. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27099. private _getName;
  27100. private _getVideo;
  27101. private _createInternalTexture;
  27102. private reset;
  27103. /**
  27104. * @hidden Internal method to initiate `update`.
  27105. */
  27106. _rebuild(): void;
  27107. /**
  27108. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27109. */
  27110. update(): void;
  27111. /**
  27112. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27113. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27114. */
  27115. updateTexture(isVisible: boolean): void;
  27116. protected _updateInternalTexture: () => void;
  27117. /**
  27118. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27119. * @param url New url.
  27120. */
  27121. updateURL(url: string): void;
  27122. /**
  27123. * Dispose the texture and release its associated resources.
  27124. */
  27125. dispose(): void;
  27126. /**
  27127. * Creates a video texture straight from a stream.
  27128. * @param scene Define the scene the texture should be created in
  27129. * @param stream Define the stream the texture should be created from
  27130. * @returns The created video texture as a promise
  27131. */
  27132. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27133. /**
  27134. * Creates a video texture straight from your WebCam video feed.
  27135. * @param scene Define the scene the texture should be created in
  27136. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27137. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27138. * @returns The created video texture as a promise
  27139. */
  27140. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27141. minWidth: number;
  27142. maxWidth: number;
  27143. minHeight: number;
  27144. maxHeight: number;
  27145. deviceId: string;
  27146. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27147. /**
  27148. * Creates a video texture straight from your WebCam video feed.
  27149. * @param scene Define the scene the texture should be created in
  27150. * @param onReady Define a callback to triggered once the texture will be ready
  27151. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27152. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27153. */
  27154. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27155. minWidth: number;
  27156. maxWidth: number;
  27157. minHeight: number;
  27158. maxHeight: number;
  27159. deviceId: string;
  27160. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27161. }
  27162. }
  27163. declare module "babylonjs/Engines/engine" {
  27164. import { Observable } from "babylonjs/Misc/observable";
  27165. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27166. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27167. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27168. import { Camera } from "babylonjs/Cameras/camera";
  27169. import { Scene } from "babylonjs/scene";
  27170. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27171. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27172. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27173. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27174. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27175. import { Material } from "babylonjs/Materials/material";
  27176. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27177. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27179. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27180. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27181. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27182. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27183. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27184. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27185. import { WebRequest } from "babylonjs/Misc/webRequest";
  27186. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27187. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27188. /**
  27189. * Interface for attribute information associated with buffer instanciation
  27190. */
  27191. export class InstancingAttributeInfo {
  27192. /**
  27193. * Index/offset of the attribute in the vertex shader
  27194. */
  27195. index: number;
  27196. /**
  27197. * size of the attribute, 1, 2, 3 or 4
  27198. */
  27199. attributeSize: number;
  27200. /**
  27201. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27202. * default is FLOAT
  27203. */
  27204. attribyteType: number;
  27205. /**
  27206. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27207. */
  27208. normalized: boolean;
  27209. /**
  27210. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27211. */
  27212. offset: number;
  27213. /**
  27214. * Name of the GLSL attribute, for debugging purpose only
  27215. */
  27216. attributeName: string;
  27217. }
  27218. /**
  27219. * Define options used to create a depth texture
  27220. */
  27221. export class DepthTextureCreationOptions {
  27222. /** Specifies whether or not a stencil should be allocated in the texture */
  27223. generateStencil?: boolean;
  27224. /** Specifies whether or not bilinear filtering is enable on the texture */
  27225. bilinearFiltering?: boolean;
  27226. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27227. comparisonFunction?: number;
  27228. /** Specifies if the created texture is a cube texture */
  27229. isCube?: boolean;
  27230. }
  27231. /**
  27232. * Class used to describe the capabilities of the engine relatively to the current browser
  27233. */
  27234. export class EngineCapabilities {
  27235. /** Maximum textures units per fragment shader */
  27236. maxTexturesImageUnits: number;
  27237. /** Maximum texture units per vertex shader */
  27238. maxVertexTextureImageUnits: number;
  27239. /** Maximum textures units in the entire pipeline */
  27240. maxCombinedTexturesImageUnits: number;
  27241. /** Maximum texture size */
  27242. maxTextureSize: number;
  27243. /** Maximum cube texture size */
  27244. maxCubemapTextureSize: number;
  27245. /** Maximum render texture size */
  27246. maxRenderTextureSize: number;
  27247. /** Maximum number of vertex attributes */
  27248. maxVertexAttribs: number;
  27249. /** Maximum number of varyings */
  27250. maxVaryingVectors: number;
  27251. /** Maximum number of uniforms per vertex shader */
  27252. maxVertexUniformVectors: number;
  27253. /** Maximum number of uniforms per fragment shader */
  27254. maxFragmentUniformVectors: number;
  27255. /** Defines if standard derivates (dx/dy) are supported */
  27256. standardDerivatives: boolean;
  27257. /** Defines if s3tc texture compression is supported */
  27258. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27259. /** Defines if pvrtc texture compression is supported */
  27260. pvrtc: any;
  27261. /** Defines if etc1 texture compression is supported */
  27262. etc1: any;
  27263. /** Defines if etc2 texture compression is supported */
  27264. etc2: any;
  27265. /** Defines if astc texture compression is supported */
  27266. astc: any;
  27267. /** Defines if float textures are supported */
  27268. textureFloat: boolean;
  27269. /** Defines if vertex array objects are supported */
  27270. vertexArrayObject: boolean;
  27271. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27272. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27273. /** Gets the maximum level of anisotropy supported */
  27274. maxAnisotropy: number;
  27275. /** Defines if instancing is supported */
  27276. instancedArrays: boolean;
  27277. /** Defines if 32 bits indices are supported */
  27278. uintIndices: boolean;
  27279. /** Defines if high precision shaders are supported */
  27280. highPrecisionShaderSupported: boolean;
  27281. /** Defines if depth reading in the fragment shader is supported */
  27282. fragmentDepthSupported: boolean;
  27283. /** Defines if float texture linear filtering is supported*/
  27284. textureFloatLinearFiltering: boolean;
  27285. /** Defines if rendering to float textures is supported */
  27286. textureFloatRender: boolean;
  27287. /** Defines if half float textures are supported*/
  27288. textureHalfFloat: boolean;
  27289. /** Defines if half float texture linear filtering is supported*/
  27290. textureHalfFloatLinearFiltering: boolean;
  27291. /** Defines if rendering to half float textures is supported */
  27292. textureHalfFloatRender: boolean;
  27293. /** Defines if textureLOD shader command is supported */
  27294. textureLOD: boolean;
  27295. /** Defines if draw buffers extension is supported */
  27296. drawBuffersExtension: boolean;
  27297. /** Defines if depth textures are supported */
  27298. depthTextureExtension: boolean;
  27299. /** Defines if float color buffer are supported */
  27300. colorBufferFloat: boolean;
  27301. /** Gets disjoint timer query extension (null if not supported) */
  27302. timerQuery: EXT_disjoint_timer_query;
  27303. /** Defines if timestamp can be used with timer query */
  27304. canUseTimestampForTimerQuery: boolean;
  27305. /** Function used to let the system compiles shaders in background */
  27306. parallelShaderCompile: {
  27307. COMPLETION_STATUS_KHR: number;
  27308. };
  27309. }
  27310. /** Interface defining initialization parameters for Engine class */
  27311. export interface EngineOptions extends WebGLContextAttributes {
  27312. /**
  27313. * Defines if the engine should no exceed a specified device ratio
  27314. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27315. */
  27316. limitDeviceRatio?: number;
  27317. /**
  27318. * Defines if webvr should be enabled automatically
  27319. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27320. */
  27321. autoEnableWebVR?: boolean;
  27322. /**
  27323. * Defines if webgl2 should be turned off even if supported
  27324. * @see http://doc.babylonjs.com/features/webgl2
  27325. */
  27326. disableWebGL2Support?: boolean;
  27327. /**
  27328. * Defines if webaudio should be initialized as well
  27329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27330. */
  27331. audioEngine?: boolean;
  27332. /**
  27333. * Defines if animations should run using a deterministic lock step
  27334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27335. */
  27336. deterministicLockstep?: boolean;
  27337. /** Defines the maximum steps to use with deterministic lock step mode */
  27338. lockstepMaxSteps?: number;
  27339. /**
  27340. * Defines that engine should ignore context lost events
  27341. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27342. */
  27343. doNotHandleContextLost?: boolean;
  27344. /**
  27345. * Defines that engine should ignore modifying touch action attribute and style
  27346. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27347. */
  27348. doNotHandleTouchAction?: boolean;
  27349. /**
  27350. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27351. */
  27352. useHighPrecisionFloats?: boolean;
  27353. }
  27354. /**
  27355. * Defines the interface used by display changed events
  27356. */
  27357. export interface IDisplayChangedEventArgs {
  27358. /** Gets the vrDisplay object (if any) */
  27359. vrDisplay: Nullable<any>;
  27360. /** Gets a boolean indicating if webVR is supported */
  27361. vrSupported: boolean;
  27362. }
  27363. /**
  27364. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27365. */
  27366. export class Engine {
  27367. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27368. static ExceptionList: ({
  27369. key: string;
  27370. capture: string;
  27371. captureConstraint: number;
  27372. targets: string[];
  27373. } | {
  27374. key: string;
  27375. capture: null;
  27376. captureConstraint: null;
  27377. targets: string[];
  27378. })[];
  27379. /** Gets the list of created engines */
  27380. static readonly Instances: Engine[];
  27381. /**
  27382. * Gets the latest created engine
  27383. */
  27384. static readonly LastCreatedEngine: Nullable<Engine>;
  27385. /**
  27386. * Gets the latest created scene
  27387. */
  27388. static readonly LastCreatedScene: Nullable<Scene>;
  27389. /**
  27390. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27391. * @param flag defines which part of the materials must be marked as dirty
  27392. * @param predicate defines a predicate used to filter which materials should be affected
  27393. */
  27394. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27395. /**
  27396. * Hidden
  27397. */
  27398. static _TextureLoaders: IInternalTextureLoader[];
  27399. /** Defines that alpha blending is disabled */
  27400. static readonly ALPHA_DISABLE: number;
  27401. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27402. static readonly ALPHA_ADD: number;
  27403. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27404. static readonly ALPHA_COMBINE: number;
  27405. /** Defines that alpha blending to DEST - SRC * DEST */
  27406. static readonly ALPHA_SUBTRACT: number;
  27407. /** Defines that alpha blending to SRC * DEST */
  27408. static readonly ALPHA_MULTIPLY: number;
  27409. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27410. static readonly ALPHA_MAXIMIZED: number;
  27411. /** Defines that alpha blending to SRC + DEST */
  27412. static readonly ALPHA_ONEONE: number;
  27413. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27414. static readonly ALPHA_PREMULTIPLIED: number;
  27415. /**
  27416. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27417. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27418. */
  27419. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27420. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27421. static readonly ALPHA_INTERPOLATE: number;
  27422. /**
  27423. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27424. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27425. */
  27426. static readonly ALPHA_SCREENMODE: number;
  27427. /** Defines that the ressource is not delayed*/
  27428. static readonly DELAYLOADSTATE_NONE: number;
  27429. /** Defines that the ressource was successfully delay loaded */
  27430. static readonly DELAYLOADSTATE_LOADED: number;
  27431. /** Defines that the ressource is currently delay loading */
  27432. static readonly DELAYLOADSTATE_LOADING: number;
  27433. /** Defines that the ressource is delayed and has not started loading */
  27434. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27435. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27436. static readonly NEVER: number;
  27437. /** 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 */
  27438. static readonly ALWAYS: number;
  27439. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27440. static readonly LESS: number;
  27441. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27442. static readonly EQUAL: number;
  27443. /** 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 */
  27444. static readonly LEQUAL: number;
  27445. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27446. static readonly GREATER: number;
  27447. /** 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 */
  27448. static readonly GEQUAL: number;
  27449. /** 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 */
  27450. static readonly NOTEQUAL: number;
  27451. /** Passed to stencilOperation to specify that stencil value must be kept */
  27452. static readonly KEEP: number;
  27453. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27454. static readonly REPLACE: number;
  27455. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27456. static readonly INCR: number;
  27457. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27458. static readonly DECR: number;
  27459. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27460. static readonly INVERT: number;
  27461. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27462. static readonly INCR_WRAP: number;
  27463. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27464. static readonly DECR_WRAP: number;
  27465. /** Texture is not repeating outside of 0..1 UVs */
  27466. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27467. /** Texture is repeating outside of 0..1 UVs */
  27468. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27469. /** Texture is repeating and mirrored */
  27470. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27471. /** ALPHA */
  27472. static readonly TEXTUREFORMAT_ALPHA: number;
  27473. /** LUMINANCE */
  27474. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27475. /** LUMINANCE_ALPHA */
  27476. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27477. /** RGB */
  27478. static readonly TEXTUREFORMAT_RGB: number;
  27479. /** RGBA */
  27480. static readonly TEXTUREFORMAT_RGBA: number;
  27481. /** RED */
  27482. static readonly TEXTUREFORMAT_RED: number;
  27483. /** RED (2nd reference) */
  27484. static readonly TEXTUREFORMAT_R: number;
  27485. /** RG */
  27486. static readonly TEXTUREFORMAT_RG: number;
  27487. /** RED_INTEGER */
  27488. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27489. /** RED_INTEGER (2nd reference) */
  27490. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27491. /** RG_INTEGER */
  27492. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27493. /** RGB_INTEGER */
  27494. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27495. /** RGBA_INTEGER */
  27496. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27497. /** UNSIGNED_BYTE */
  27498. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27499. /** UNSIGNED_BYTE (2nd reference) */
  27500. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27501. /** FLOAT */
  27502. static readonly TEXTURETYPE_FLOAT: number;
  27503. /** HALF_FLOAT */
  27504. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27505. /** BYTE */
  27506. static readonly TEXTURETYPE_BYTE: number;
  27507. /** SHORT */
  27508. static readonly TEXTURETYPE_SHORT: number;
  27509. /** UNSIGNED_SHORT */
  27510. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27511. /** INT */
  27512. static readonly TEXTURETYPE_INT: number;
  27513. /** UNSIGNED_INT */
  27514. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27515. /** UNSIGNED_SHORT_4_4_4_4 */
  27516. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27517. /** UNSIGNED_SHORT_5_5_5_1 */
  27518. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27519. /** UNSIGNED_SHORT_5_6_5 */
  27520. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27521. /** UNSIGNED_INT_2_10_10_10_REV */
  27522. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27523. /** UNSIGNED_INT_24_8 */
  27524. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27525. /** UNSIGNED_INT_10F_11F_11F_REV */
  27526. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27527. /** UNSIGNED_INT_5_9_9_9_REV */
  27528. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27529. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27530. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27531. /** nearest is mag = nearest and min = nearest and mip = linear */
  27532. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27533. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27534. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27535. /** Trilinear is mag = linear and min = linear and mip = linear */
  27536. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27537. /** nearest is mag = nearest and min = nearest and mip = linear */
  27538. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27539. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27540. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27541. /** Trilinear is mag = linear and min = linear and mip = linear */
  27542. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27543. /** mag = nearest and min = nearest and mip = nearest */
  27544. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27545. /** mag = nearest and min = linear and mip = nearest */
  27546. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27547. /** mag = nearest and min = linear and mip = linear */
  27548. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27549. /** mag = nearest and min = linear and mip = none */
  27550. static readonly TEXTURE_NEAREST_LINEAR: number;
  27551. /** mag = nearest and min = nearest and mip = none */
  27552. static readonly TEXTURE_NEAREST_NEAREST: number;
  27553. /** mag = linear and min = nearest and mip = nearest */
  27554. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27555. /** mag = linear and min = nearest and mip = linear */
  27556. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27557. /** mag = linear and min = linear and mip = none */
  27558. static readonly TEXTURE_LINEAR_LINEAR: number;
  27559. /** mag = linear and min = nearest and mip = none */
  27560. static readonly TEXTURE_LINEAR_NEAREST: number;
  27561. /** Explicit coordinates mode */
  27562. static readonly TEXTURE_EXPLICIT_MODE: number;
  27563. /** Spherical coordinates mode */
  27564. static readonly TEXTURE_SPHERICAL_MODE: number;
  27565. /** Planar coordinates mode */
  27566. static readonly TEXTURE_PLANAR_MODE: number;
  27567. /** Cubic coordinates mode */
  27568. static readonly TEXTURE_CUBIC_MODE: number;
  27569. /** Projection coordinates mode */
  27570. static readonly TEXTURE_PROJECTION_MODE: number;
  27571. /** Skybox coordinates mode */
  27572. static readonly TEXTURE_SKYBOX_MODE: number;
  27573. /** Inverse Cubic coordinates mode */
  27574. static readonly TEXTURE_INVCUBIC_MODE: number;
  27575. /** Equirectangular coordinates mode */
  27576. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27577. /** Equirectangular Fixed coordinates mode */
  27578. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27579. /** Equirectangular Fixed Mirrored coordinates mode */
  27580. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27581. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27582. static readonly SCALEMODE_FLOOR: number;
  27583. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27584. static readonly SCALEMODE_NEAREST: number;
  27585. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27586. static readonly SCALEMODE_CEILING: number;
  27587. /**
  27588. * Returns the current npm package of the sdk
  27589. */
  27590. static readonly NpmPackage: string;
  27591. /**
  27592. * Returns the current version of the framework
  27593. */
  27594. static readonly Version: string;
  27595. /**
  27596. * Returns a string describing the current engine
  27597. */
  27598. readonly description: string;
  27599. /**
  27600. * Gets or sets the epsilon value used by collision engine
  27601. */
  27602. static CollisionsEpsilon: number;
  27603. /**
  27604. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27605. */
  27606. static ShadersRepository: string;
  27607. /**
  27608. * Method called to create the default loading screen.
  27609. * This can be overriden in your own app.
  27610. * @param canvas The rendering canvas element
  27611. * @returns The loading screen
  27612. */
  27613. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27614. /**
  27615. * Method called to create the default rescale post process on each engine.
  27616. */
  27617. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27618. /**
  27619. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27620. */
  27621. forcePOTTextures: boolean;
  27622. /**
  27623. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27624. */
  27625. isFullscreen: boolean;
  27626. /**
  27627. * Gets a boolean indicating if the pointer is currently locked
  27628. */
  27629. isPointerLock: boolean;
  27630. /**
  27631. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27632. */
  27633. cullBackFaces: boolean;
  27634. /**
  27635. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27636. */
  27637. renderEvenInBackground: boolean;
  27638. /**
  27639. * Gets or sets a boolean indicating that cache can be kept between frames
  27640. */
  27641. preventCacheWipeBetweenFrames: boolean;
  27642. /**
  27643. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27644. **/
  27645. enableOfflineSupport: boolean;
  27646. /**
  27647. * 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)
  27648. **/
  27649. disableManifestCheck: boolean;
  27650. /**
  27651. * Gets the list of created scenes
  27652. */
  27653. scenes: Scene[];
  27654. /**
  27655. * Event raised when a new scene is created
  27656. */
  27657. onNewSceneAddedObservable: Observable<Scene>;
  27658. /**
  27659. * Gets the list of created postprocesses
  27660. */
  27661. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27662. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27663. validateShaderPrograms: boolean;
  27664. /**
  27665. * Observable event triggered each time the rendering canvas is resized
  27666. */
  27667. onResizeObservable: Observable<Engine>;
  27668. /**
  27669. * Observable event triggered each time the canvas loses focus
  27670. */
  27671. onCanvasBlurObservable: Observable<Engine>;
  27672. /**
  27673. * Observable event triggered each time the canvas gains focus
  27674. */
  27675. onCanvasFocusObservable: Observable<Engine>;
  27676. /**
  27677. * Observable event triggered each time the canvas receives pointerout event
  27678. */
  27679. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27680. /**
  27681. * Observable event triggered before each texture is initialized
  27682. */
  27683. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27684. private _vrDisplay;
  27685. private _vrSupported;
  27686. private _oldSize;
  27687. private _oldHardwareScaleFactor;
  27688. private _vrExclusivePointerMode;
  27689. private _webVRInitPromise;
  27690. /**
  27691. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27692. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27693. */
  27694. readonly isInVRExclusivePointerMode: boolean;
  27695. /**
  27696. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27697. */
  27698. disableUniformBuffers: boolean;
  27699. /** @hidden */
  27700. _uniformBuffers: UniformBuffer[];
  27701. /**
  27702. * Gets a boolean indicating that the engine supports uniform buffers
  27703. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27704. */
  27705. readonly supportsUniformBuffers: boolean;
  27706. /**
  27707. * Observable raised when the engine begins a new frame
  27708. */
  27709. onBeginFrameObservable: Observable<Engine>;
  27710. /**
  27711. * If set, will be used to request the next animation frame for the render loop
  27712. */
  27713. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27714. /**
  27715. * Observable raised when the engine ends the current frame
  27716. */
  27717. onEndFrameObservable: Observable<Engine>;
  27718. /**
  27719. * Observable raised when the engine is about to compile a shader
  27720. */
  27721. onBeforeShaderCompilationObservable: Observable<Engine>;
  27722. /**
  27723. * Observable raised when the engine has jsut compiled a shader
  27724. */
  27725. onAfterShaderCompilationObservable: Observable<Engine>;
  27726. /** @hidden */
  27727. _gl: WebGLRenderingContext;
  27728. private _renderingCanvas;
  27729. private _windowIsBackground;
  27730. private _webGLVersion;
  27731. protected _highPrecisionShadersAllowed: boolean;
  27732. /** @hidden */
  27733. readonly _shouldUseHighPrecisionShader: boolean;
  27734. /**
  27735. * Gets a boolean indicating that only power of 2 textures are supported
  27736. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27737. */
  27738. readonly needPOTTextures: boolean;
  27739. /** @hidden */
  27740. _badOS: boolean;
  27741. /** @hidden */
  27742. _badDesktopOS: boolean;
  27743. /**
  27744. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27745. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27746. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27747. */
  27748. disableTextureBindingOptimization: boolean;
  27749. /**
  27750. * Gets the audio engine
  27751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27752. * @ignorenaming
  27753. */
  27754. static audioEngine: IAudioEngine;
  27755. /**
  27756. * Default AudioEngine factory responsible of creating the Audio Engine.
  27757. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27758. */
  27759. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27760. /**
  27761. * Default offline support factory responsible of creating a tool used to store data locally.
  27762. * By default, this will create a Database object if the workload has been embedded.
  27763. */
  27764. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27765. private _onFocus;
  27766. private _onBlur;
  27767. private _onCanvasPointerOut;
  27768. private _onCanvasBlur;
  27769. private _onCanvasFocus;
  27770. private _onFullscreenChange;
  27771. private _onPointerLockChange;
  27772. private _onVRDisplayPointerRestricted;
  27773. private _onVRDisplayPointerUnrestricted;
  27774. private _onVrDisplayConnect;
  27775. private _onVrDisplayDisconnect;
  27776. private _onVrDisplayPresentChange;
  27777. /**
  27778. * Observable signaled when VR display mode changes
  27779. */
  27780. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27781. /**
  27782. * Observable signaled when VR request present is complete
  27783. */
  27784. onVRRequestPresentComplete: Observable<boolean>;
  27785. /**
  27786. * Observable signaled when VR request present starts
  27787. */
  27788. onVRRequestPresentStart: Observable<Engine>;
  27789. private _hardwareScalingLevel;
  27790. /** @hidden */
  27791. protected _caps: EngineCapabilities;
  27792. private _pointerLockRequested;
  27793. private _isStencilEnable;
  27794. private _colorWrite;
  27795. private _loadingScreen;
  27796. /** @hidden */
  27797. _drawCalls: PerfCounter;
  27798. /** @hidden */
  27799. _textureCollisions: PerfCounter;
  27800. private _glVersion;
  27801. private _glRenderer;
  27802. private _glVendor;
  27803. private _videoTextureSupported;
  27804. private _renderingQueueLaunched;
  27805. private _activeRenderLoops;
  27806. private _deterministicLockstep;
  27807. private _lockstepMaxSteps;
  27808. /**
  27809. * Observable signaled when a context lost event is raised
  27810. */
  27811. onContextLostObservable: Observable<Engine>;
  27812. /**
  27813. * Observable signaled when a context restored event is raised
  27814. */
  27815. onContextRestoredObservable: Observable<Engine>;
  27816. private _onContextLost;
  27817. private _onContextRestored;
  27818. private _contextWasLost;
  27819. private _doNotHandleContextLost;
  27820. /**
  27821. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27823. */
  27824. doNotHandleContextLost: boolean;
  27825. private _performanceMonitor;
  27826. private _fps;
  27827. private _deltaTime;
  27828. /**
  27829. * Turn this value on if you want to pause FPS computation when in background
  27830. */
  27831. disablePerformanceMonitorInBackground: boolean;
  27832. /**
  27833. * Gets the performance monitor attached to this engine
  27834. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27835. */
  27836. readonly performanceMonitor: PerformanceMonitor;
  27837. /** @hidden */
  27838. protected _depthCullingState: _DepthCullingState;
  27839. /** @hidden */
  27840. protected _stencilState: _StencilState;
  27841. /** @hidden */
  27842. protected _alphaState: _AlphaState;
  27843. /** @hidden */
  27844. protected _alphaMode: number;
  27845. protected _internalTexturesCache: InternalTexture[];
  27846. /** @hidden */
  27847. protected _activeChannel: number;
  27848. private _currentTextureChannel;
  27849. /** @hidden */
  27850. protected _boundTexturesCache: {
  27851. [key: string]: Nullable<InternalTexture>;
  27852. };
  27853. /** @hidden */
  27854. protected _currentEffect: Nullable<Effect>;
  27855. /** @hidden */
  27856. protected _currentProgram: Nullable<WebGLProgram>;
  27857. private _compiledEffects;
  27858. private _vertexAttribArraysEnabled;
  27859. /** @hidden */
  27860. protected _cachedViewport: Nullable<Viewport>;
  27861. private _cachedVertexArrayObject;
  27862. /** @hidden */
  27863. protected _cachedVertexBuffers: any;
  27864. /** @hidden */
  27865. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27866. /** @hidden */
  27867. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27868. /** @hidden */
  27869. protected _currentRenderTarget: Nullable<InternalTexture>;
  27870. private _uintIndicesCurrentlySet;
  27871. private _currentBoundBuffer;
  27872. /** @hidden */
  27873. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27874. private _currentBufferPointers;
  27875. private _currentInstanceLocations;
  27876. private _currentInstanceBuffers;
  27877. private _textureUnits;
  27878. private _firstBoundInternalTextureTracker;
  27879. private _lastBoundInternalTextureTracker;
  27880. private _workingCanvas;
  27881. private _workingContext;
  27882. private _rescalePostProcess;
  27883. private _dummyFramebuffer;
  27884. private _externalData;
  27885. private _bindedRenderFunction;
  27886. private _vaoRecordInProgress;
  27887. private _mustWipeVertexAttributes;
  27888. private _emptyTexture;
  27889. private _emptyCubeTexture;
  27890. private _emptyTexture3D;
  27891. /** @hidden */
  27892. _frameHandler: number;
  27893. private _nextFreeTextureSlots;
  27894. private _maxSimultaneousTextures;
  27895. private _activeRequests;
  27896. private _texturesSupported;
  27897. private _textureFormatInUse;
  27898. /**
  27899. * Gets the list of texture formats supported
  27900. */
  27901. readonly texturesSupported: Array<string>;
  27902. /**
  27903. * Gets the list of texture formats in use
  27904. */
  27905. readonly textureFormatInUse: Nullable<string>;
  27906. /**
  27907. * Gets the current viewport
  27908. */
  27909. readonly currentViewport: Nullable<Viewport>;
  27910. /**
  27911. * Gets the default empty texture
  27912. */
  27913. readonly emptyTexture: InternalTexture;
  27914. /**
  27915. * Gets the default empty 3D texture
  27916. */
  27917. readonly emptyTexture3D: InternalTexture;
  27918. /**
  27919. * Gets the default empty cube texture
  27920. */
  27921. readonly emptyCubeTexture: InternalTexture;
  27922. /**
  27923. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27924. */
  27925. readonly premultipliedAlpha: boolean;
  27926. /**
  27927. * Creates a new engine
  27928. * @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
  27929. * @param antialias defines enable antialiasing (default: false)
  27930. * @param options defines further options to be sent to the getContext() function
  27931. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27932. */
  27933. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27934. private _disableTouchAction;
  27935. private _rebuildInternalTextures;
  27936. private _rebuildEffects;
  27937. /**
  27938. * Gets a boolean indicating if all created effects are ready
  27939. * @returns true if all effects are ready
  27940. */
  27941. areAllEffectsReady(): boolean;
  27942. private _rebuildBuffers;
  27943. private _initGLContext;
  27944. /**
  27945. * Gets version of the current webGL context
  27946. */
  27947. readonly webGLVersion: number;
  27948. /**
  27949. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27950. */
  27951. readonly isStencilEnable: boolean;
  27952. private _prepareWorkingCanvas;
  27953. /**
  27954. * Reset the texture cache to empty state
  27955. */
  27956. resetTextureCache(): void;
  27957. /**
  27958. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27959. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27960. * @returns true if engine is in deterministic lock step mode
  27961. */
  27962. isDeterministicLockStep(): boolean;
  27963. /**
  27964. * Gets the max steps when engine is running in deterministic lock step
  27965. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27966. * @returns the max steps
  27967. */
  27968. getLockstepMaxSteps(): number;
  27969. /**
  27970. * Gets an object containing information about the current webGL context
  27971. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27972. */
  27973. getGlInfo(): {
  27974. vendor: string;
  27975. renderer: string;
  27976. version: string;
  27977. };
  27978. /**
  27979. * Gets current aspect ratio
  27980. * @param camera defines the camera to use to get the aspect ratio
  27981. * @param useScreen defines if screen size must be used (or the current render target if any)
  27982. * @returns a number defining the aspect ratio
  27983. */
  27984. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27985. /**
  27986. * Gets current screen aspect ratio
  27987. * @returns a number defining the aspect ratio
  27988. */
  27989. getScreenAspectRatio(): number;
  27990. /**
  27991. * Gets the current render width
  27992. * @param useScreen defines if screen size must be used (or the current render target if any)
  27993. * @returns a number defining the current render width
  27994. */
  27995. getRenderWidth(useScreen?: boolean): number;
  27996. /**
  27997. * Gets the current render height
  27998. * @param useScreen defines if screen size must be used (or the current render target if any)
  27999. * @returns a number defining the current render height
  28000. */
  28001. getRenderHeight(useScreen?: boolean): number;
  28002. /**
  28003. * Gets the HTML canvas attached with the current webGL context
  28004. * @returns a HTML canvas
  28005. */
  28006. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28007. /**
  28008. * Gets the client rect of the HTML canvas attached with the current webGL context
  28009. * @returns a client rectanglee
  28010. */
  28011. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28012. /**
  28013. * Defines the hardware scaling level.
  28014. * By default the hardware scaling level is computed from the window device ratio.
  28015. * 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.
  28016. * @param level defines the level to use
  28017. */
  28018. setHardwareScalingLevel(level: number): void;
  28019. /**
  28020. * Gets the current hardware scaling level.
  28021. * By default the hardware scaling level is computed from the window device ratio.
  28022. * 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.
  28023. * @returns a number indicating the current hardware scaling level
  28024. */
  28025. getHardwareScalingLevel(): number;
  28026. /**
  28027. * Gets the list of loaded textures
  28028. * @returns an array containing all loaded textures
  28029. */
  28030. getLoadedTexturesCache(): InternalTexture[];
  28031. /**
  28032. * Gets the object containing all engine capabilities
  28033. * @returns the EngineCapabilities object
  28034. */
  28035. getCaps(): EngineCapabilities;
  28036. /**
  28037. * Gets the current depth function
  28038. * @returns a number defining the depth function
  28039. */
  28040. getDepthFunction(): Nullable<number>;
  28041. /**
  28042. * Sets the current depth function
  28043. * @param depthFunc defines the function to use
  28044. */
  28045. setDepthFunction(depthFunc: number): void;
  28046. /**
  28047. * Sets the current depth function to GREATER
  28048. */
  28049. setDepthFunctionToGreater(): void;
  28050. /**
  28051. * Sets the current depth function to GEQUAL
  28052. */
  28053. setDepthFunctionToGreaterOrEqual(): void;
  28054. /**
  28055. * Sets the current depth function to LESS
  28056. */
  28057. setDepthFunctionToLess(): void;
  28058. /**
  28059. * Sets the current depth function to LEQUAL
  28060. */
  28061. setDepthFunctionToLessOrEqual(): void;
  28062. /**
  28063. * Gets a boolean indicating if stencil buffer is enabled
  28064. * @returns the current stencil buffer state
  28065. */
  28066. getStencilBuffer(): boolean;
  28067. /**
  28068. * Enable or disable the stencil buffer
  28069. * @param enable defines if the stencil buffer must be enabled or disabled
  28070. */
  28071. setStencilBuffer(enable: boolean): void;
  28072. /**
  28073. * Gets the current stencil mask
  28074. * @returns a number defining the new stencil mask to use
  28075. */
  28076. getStencilMask(): number;
  28077. /**
  28078. * Sets the current stencil mask
  28079. * @param mask defines the new stencil mask to use
  28080. */
  28081. setStencilMask(mask: number): void;
  28082. /**
  28083. * Gets the current stencil function
  28084. * @returns a number defining the stencil function to use
  28085. */
  28086. getStencilFunction(): number;
  28087. /**
  28088. * Gets the current stencil reference value
  28089. * @returns a number defining the stencil reference value to use
  28090. */
  28091. getStencilFunctionReference(): number;
  28092. /**
  28093. * Gets the current stencil mask
  28094. * @returns a number defining the stencil mask to use
  28095. */
  28096. getStencilFunctionMask(): number;
  28097. /**
  28098. * Sets the current stencil function
  28099. * @param stencilFunc defines the new stencil function to use
  28100. */
  28101. setStencilFunction(stencilFunc: number): void;
  28102. /**
  28103. * Sets the current stencil reference
  28104. * @param reference defines the new stencil reference to use
  28105. */
  28106. setStencilFunctionReference(reference: number): void;
  28107. /**
  28108. * Sets the current stencil mask
  28109. * @param mask defines the new stencil mask to use
  28110. */
  28111. setStencilFunctionMask(mask: number): void;
  28112. /**
  28113. * Gets the current stencil operation when stencil fails
  28114. * @returns a number defining stencil operation to use when stencil fails
  28115. */
  28116. getStencilOperationFail(): number;
  28117. /**
  28118. * Gets the current stencil operation when depth fails
  28119. * @returns a number defining stencil operation to use when depth fails
  28120. */
  28121. getStencilOperationDepthFail(): number;
  28122. /**
  28123. * Gets the current stencil operation when stencil passes
  28124. * @returns a number defining stencil operation to use when stencil passes
  28125. */
  28126. getStencilOperationPass(): number;
  28127. /**
  28128. * Sets the stencil operation to use when stencil fails
  28129. * @param operation defines the stencil operation to use when stencil fails
  28130. */
  28131. setStencilOperationFail(operation: number): void;
  28132. /**
  28133. * Sets the stencil operation to use when depth fails
  28134. * @param operation defines the stencil operation to use when depth fails
  28135. */
  28136. setStencilOperationDepthFail(operation: number): void;
  28137. /**
  28138. * Sets the stencil operation to use when stencil passes
  28139. * @param operation defines the stencil operation to use when stencil passes
  28140. */
  28141. setStencilOperationPass(operation: number): void;
  28142. /**
  28143. * Sets a boolean indicating if the dithering state is enabled or disabled
  28144. * @param value defines the dithering state
  28145. */
  28146. setDitheringState(value: boolean): void;
  28147. /**
  28148. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28149. * @param value defines the rasterizer state
  28150. */
  28151. setRasterizerState(value: boolean): void;
  28152. /**
  28153. * stop executing a render loop function and remove it from the execution array
  28154. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28155. */
  28156. stopRenderLoop(renderFunction?: () => void): void;
  28157. /** @hidden */
  28158. _renderLoop(): void;
  28159. /**
  28160. * Register and execute a render loop. The engine can have more than one render function
  28161. * @param renderFunction defines the function to continuously execute
  28162. */
  28163. runRenderLoop(renderFunction: () => void): void;
  28164. /**
  28165. * Toggle full screen mode
  28166. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28167. */
  28168. switchFullscreen(requestPointerLock: boolean): void;
  28169. /**
  28170. * Enters full screen mode
  28171. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28172. */
  28173. enterFullscreen(requestPointerLock: boolean): void;
  28174. /**
  28175. * Exits full screen mode
  28176. */
  28177. exitFullscreen(): void;
  28178. /**
  28179. * Clear the current render buffer or the current render target (if any is set up)
  28180. * @param color defines the color to use
  28181. * @param backBuffer defines if the back buffer must be cleared
  28182. * @param depth defines if the depth buffer must be cleared
  28183. * @param stencil defines if the stencil buffer must be cleared
  28184. */
  28185. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28186. /**
  28187. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28188. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28189. * @param y defines the y-coordinate of the corner of the clear rectangle
  28190. * @param width defines the width of the clear rectangle
  28191. * @param height defines the height of the clear rectangle
  28192. * @param clearColor defines the clear color
  28193. */
  28194. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28195. /**
  28196. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28197. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28198. * @param y defines the y-coordinate of the corner of the clear rectangle
  28199. * @param width defines the width of the clear rectangle
  28200. * @param height defines the height of the clear rectangle
  28201. */
  28202. enableScissor(x: number, y: number, width: number, height: number): void;
  28203. /**
  28204. * Disable previously set scissor test rectangle
  28205. */
  28206. disableScissor(): void;
  28207. private _viewportCached;
  28208. /** @hidden */
  28209. _viewport(x: number, y: number, width: number, height: number): void;
  28210. /**
  28211. * Set the WebGL's viewport
  28212. * @param viewport defines the viewport element to be used
  28213. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28214. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28215. */
  28216. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28217. /**
  28218. * Directly set the WebGL Viewport
  28219. * @param x defines the x coordinate of the viewport (in screen space)
  28220. * @param y defines the y coordinate of the viewport (in screen space)
  28221. * @param width defines the width of the viewport (in screen space)
  28222. * @param height defines the height of the viewport (in screen space)
  28223. * @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
  28224. */
  28225. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28226. /**
  28227. * Begin a new frame
  28228. */
  28229. beginFrame(): void;
  28230. /**
  28231. * Enf the current frame
  28232. */
  28233. endFrame(): void;
  28234. /**
  28235. * Resize the view according to the canvas' size
  28236. */
  28237. resize(): void;
  28238. /**
  28239. * Force a specific size of the canvas
  28240. * @param width defines the new canvas' width
  28241. * @param height defines the new canvas' height
  28242. */
  28243. setSize(width: number, height: number): void;
  28244. /**
  28245. * Gets a boolean indicating if a webVR device was detected
  28246. * @returns true if a webVR device was detected
  28247. */
  28248. isVRDevicePresent(): boolean;
  28249. /**
  28250. * Gets the current webVR device
  28251. * @returns the current webVR device (or null)
  28252. */
  28253. getVRDevice(): any;
  28254. /**
  28255. * Initializes a webVR display and starts listening to display change events
  28256. * The onVRDisplayChangedObservable will be notified upon these changes
  28257. * @returns The onVRDisplayChangedObservable
  28258. */
  28259. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28260. /**
  28261. * Initializes a webVR display and starts listening to display change events
  28262. * The onVRDisplayChangedObservable will be notified upon these changes
  28263. * @returns A promise containing a VRDisplay and if vr is supported
  28264. */
  28265. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28266. /**
  28267. * Call this function to switch to webVR mode
  28268. * Will do nothing if webVR is not supported or if there is no webVR device
  28269. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28270. */
  28271. enableVR(): void;
  28272. /**
  28273. * Call this function to leave webVR mode
  28274. * Will do nothing if webVR is not supported or if there is no webVR device
  28275. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28276. */
  28277. disableVR(): void;
  28278. private _onVRFullScreenTriggered;
  28279. private _getVRDisplaysAsync;
  28280. /**
  28281. * Binds the frame buffer to the specified texture.
  28282. * @param texture The texture to render to or null for the default canvas
  28283. * @param faceIndex The face of the texture to render to in case of cube texture
  28284. * @param requiredWidth The width of the target to render to
  28285. * @param requiredHeight The height of the target to render to
  28286. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28287. * @param depthStencilTexture The depth stencil texture to use to render
  28288. * @param lodLevel defines le lod level to bind to the frame buffer
  28289. */
  28290. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28291. private bindUnboundFramebuffer;
  28292. /**
  28293. * Unbind the current render target texture from the webGL context
  28294. * @param texture defines the render target texture to unbind
  28295. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28296. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28297. */
  28298. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28299. /**
  28300. * Unbind a list of render target textures from the webGL context
  28301. * This is used only when drawBuffer extension or webGL2 are active
  28302. * @param textures defines the render target textures to unbind
  28303. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28304. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28305. */
  28306. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28307. /**
  28308. * Force the mipmap generation for the given render target texture
  28309. * @param texture defines the render target texture to use
  28310. */
  28311. generateMipMapsForCubemap(texture: InternalTexture): void;
  28312. /**
  28313. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28314. */
  28315. flushFramebuffer(): void;
  28316. /**
  28317. * Unbind the current render target and bind the default framebuffer
  28318. */
  28319. restoreDefaultFramebuffer(): void;
  28320. /**
  28321. * Create an uniform buffer
  28322. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28323. * @param elements defines the content of the uniform buffer
  28324. * @returns the webGL uniform buffer
  28325. */
  28326. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28327. /**
  28328. * Create a dynamic uniform buffer
  28329. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28330. * @param elements defines the content of the uniform buffer
  28331. * @returns the webGL uniform buffer
  28332. */
  28333. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28334. /**
  28335. * Update an existing uniform buffer
  28336. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28337. * @param uniformBuffer defines the target uniform buffer
  28338. * @param elements defines the content to update
  28339. * @param offset defines the offset in the uniform buffer where update should start
  28340. * @param count defines the size of the data to update
  28341. */
  28342. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28343. private _resetVertexBufferBinding;
  28344. /**
  28345. * Creates a vertex buffer
  28346. * @param data the data for the vertex buffer
  28347. * @returns the new WebGL static buffer
  28348. */
  28349. createVertexBuffer(data: DataArray): WebGLBuffer;
  28350. /**
  28351. * Creates a dynamic vertex buffer
  28352. * @param data the data for the dynamic vertex buffer
  28353. * @returns the new WebGL dynamic buffer
  28354. */
  28355. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28356. /**
  28357. * Update a dynamic index buffer
  28358. * @param indexBuffer defines the target index buffer
  28359. * @param indices defines the data to update
  28360. * @param offset defines the offset in the target index buffer where update should start
  28361. */
  28362. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28363. /**
  28364. * Updates a dynamic vertex buffer.
  28365. * @param vertexBuffer the vertex buffer to update
  28366. * @param data the data used to update the vertex buffer
  28367. * @param byteOffset the byte offset of the data
  28368. * @param byteLength the byte length of the data
  28369. */
  28370. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28371. private _resetIndexBufferBinding;
  28372. /**
  28373. * Creates a new index buffer
  28374. * @param indices defines the content of the index buffer
  28375. * @param updatable defines if the index buffer must be updatable
  28376. * @returns a new webGL buffer
  28377. */
  28378. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28379. /**
  28380. * Bind a webGL buffer to the webGL context
  28381. * @param buffer defines the buffer to bind
  28382. */
  28383. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28384. /**
  28385. * Bind an uniform buffer to the current webGL context
  28386. * @param buffer defines the buffer to bind
  28387. */
  28388. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28389. /**
  28390. * Bind a buffer to the current webGL context at a given location
  28391. * @param buffer defines the buffer to bind
  28392. * @param location defines the index where to bind the buffer
  28393. */
  28394. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28395. /**
  28396. * Bind a specific block at a given index in a specific shader program
  28397. * @param shaderProgram defines the shader program
  28398. * @param blockName defines the block name
  28399. * @param index defines the index where to bind the block
  28400. */
  28401. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28402. private bindIndexBuffer;
  28403. private bindBuffer;
  28404. /**
  28405. * update the bound buffer with the given data
  28406. * @param data defines the data to update
  28407. */
  28408. updateArrayBuffer(data: Float32Array): void;
  28409. private _vertexAttribPointer;
  28410. private _bindIndexBufferWithCache;
  28411. private _bindVertexBuffersAttributes;
  28412. /**
  28413. * Records a vertex array object
  28414. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28415. * @param vertexBuffers defines the list of vertex buffers to store
  28416. * @param indexBuffer defines the index buffer to store
  28417. * @param effect defines the effect to store
  28418. * @returns the new vertex array object
  28419. */
  28420. recordVertexArrayObject(vertexBuffers: {
  28421. [key: string]: VertexBuffer;
  28422. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28423. /**
  28424. * Bind a specific vertex array object
  28425. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28426. * @param vertexArrayObject defines the vertex array object to bind
  28427. * @param indexBuffer defines the index buffer to bind
  28428. */
  28429. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28430. /**
  28431. * Bind webGl buffers directly to the webGL context
  28432. * @param vertexBuffer defines the vertex buffer to bind
  28433. * @param indexBuffer defines the index buffer to bind
  28434. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28435. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28436. * @param effect defines the effect associated with the vertex buffer
  28437. */
  28438. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28439. private _unbindVertexArrayObject;
  28440. /**
  28441. * Bind a list of vertex buffers to the webGL context
  28442. * @param vertexBuffers defines the list of vertex buffers to bind
  28443. * @param indexBuffer defines the index buffer to bind
  28444. * @param effect defines the effect associated with the vertex buffers
  28445. */
  28446. bindBuffers(vertexBuffers: {
  28447. [key: string]: Nullable<VertexBuffer>;
  28448. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28449. /**
  28450. * Unbind all instance attributes
  28451. */
  28452. unbindInstanceAttributes(): void;
  28453. /**
  28454. * Release and free the memory of a vertex array object
  28455. * @param vao defines the vertex array object to delete
  28456. */
  28457. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28458. /** @hidden */
  28459. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28460. /**
  28461. * Creates a webGL buffer to use with instanciation
  28462. * @param capacity defines the size of the buffer
  28463. * @returns the webGL buffer
  28464. */
  28465. createInstancesBuffer(capacity: number): WebGLBuffer;
  28466. /**
  28467. * Delete a webGL buffer used with instanciation
  28468. * @param buffer defines the webGL buffer to delete
  28469. */
  28470. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28471. /**
  28472. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28473. * @param instancesBuffer defines the webGL buffer to update and bind
  28474. * @param data defines the data to store in the buffer
  28475. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28476. */
  28477. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28478. /**
  28479. * Apply all cached states (depth, culling, stencil and alpha)
  28480. */
  28481. applyStates(): void;
  28482. /**
  28483. * Send a draw order
  28484. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28485. * @param indexStart defines the starting index
  28486. * @param indexCount defines the number of index to draw
  28487. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28488. */
  28489. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28490. /**
  28491. * Draw a list of points
  28492. * @param verticesStart defines the index of first vertex to draw
  28493. * @param verticesCount defines the count of vertices to draw
  28494. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28495. */
  28496. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28497. /**
  28498. * Draw a list of unindexed primitives
  28499. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28500. * @param verticesStart defines the index of first vertex to draw
  28501. * @param verticesCount defines the count of vertices to draw
  28502. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28503. */
  28504. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28505. /**
  28506. * Draw a list of indexed primitives
  28507. * @param fillMode defines the primitive to use
  28508. * @param indexStart defines the starting index
  28509. * @param indexCount defines the number of index to draw
  28510. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28511. */
  28512. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28513. /**
  28514. * Draw a list of unindexed primitives
  28515. * @param fillMode defines the primitive to use
  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. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28521. private _drawMode;
  28522. /** @hidden */
  28523. _releaseEffect(effect: Effect): void;
  28524. /** @hidden */
  28525. _deleteProgram(program: WebGLProgram): void;
  28526. /**
  28527. * Create a new effect (used to store vertex/fragment shaders)
  28528. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28529. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28530. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28531. * @param samplers defines an array of string used to represent textures
  28532. * @param defines defines the string containing the defines to use to compile the shaders
  28533. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28534. * @param onCompiled defines a function to call when the effect creation is successful
  28535. * @param onError defines a function to call when the effect creation has failed
  28536. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28537. * @returns the new Effect
  28538. */
  28539. 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;
  28540. private _compileShader;
  28541. private _compileRawShader;
  28542. /**
  28543. * Directly creates a webGL program
  28544. * @param vertexCode defines the vertex shader code to use
  28545. * @param fragmentCode defines the fragment shader code to use
  28546. * @param context defines the webGL context to use (if not set, the current one will be used)
  28547. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28548. * @returns the new webGL program
  28549. */
  28550. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28551. /**
  28552. * Creates a webGL program
  28553. * @param vertexCode defines the vertex shader code to use
  28554. * @param fragmentCode defines the fragment shader code to use
  28555. * @param defines defines the string containing the defines to use to compile the shaders
  28556. * @param context defines the webGL context to use (if not set, the current one will be used)
  28557. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28558. * @returns the new webGL program
  28559. */
  28560. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28561. private _createShaderProgram;
  28562. private _finalizeProgram;
  28563. /** @hidden */
  28564. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28565. /** @hidden */
  28566. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28567. /**
  28568. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28569. * @param shaderProgram defines the webGL program to use
  28570. * @param uniformsNames defines the list of uniform names
  28571. * @returns an array of webGL uniform locations
  28572. */
  28573. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28574. /**
  28575. * Gets the lsit of active attributes for a given webGL program
  28576. * @param shaderProgram defines the webGL program to use
  28577. * @param attributesNames defines the list of attribute names to get
  28578. * @returns an array of indices indicating the offset of each attribute
  28579. */
  28580. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28581. /**
  28582. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28583. * @param effect defines the effect to activate
  28584. */
  28585. enableEffect(effect: Nullable<Effect>): void;
  28586. /**
  28587. * Set the value of an uniform to an array of int32
  28588. * @param uniform defines the webGL uniform location where to store the value
  28589. * @param array defines the array of int32 to store
  28590. */
  28591. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28592. /**
  28593. * Set the value of an uniform to an array of int32 (stored as vec2)
  28594. * @param uniform defines the webGL uniform location where to store the value
  28595. * @param array defines the array of int32 to store
  28596. */
  28597. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28598. /**
  28599. * Set the value of an uniform to an array of int32 (stored as vec3)
  28600. * @param uniform defines the webGL uniform location where to store the value
  28601. * @param array defines the array of int32 to store
  28602. */
  28603. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28604. /**
  28605. * Set the value of an uniform to an array of int32 (stored as vec4)
  28606. * @param uniform defines the webGL uniform location where to store the value
  28607. * @param array defines the array of int32 to store
  28608. */
  28609. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28610. /**
  28611. * Set the value of an uniform to an array of float32
  28612. * @param uniform defines the webGL uniform location where to store the value
  28613. * @param array defines the array of float32 to store
  28614. */
  28615. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28616. /**
  28617. * Set the value of an uniform to an array of float32 (stored as vec2)
  28618. * @param uniform defines the webGL uniform location where to store the value
  28619. * @param array defines the array of float32 to store
  28620. */
  28621. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28622. /**
  28623. * Set the value of an uniform to an array of float32 (stored as vec3)
  28624. * @param uniform defines the webGL uniform location where to store the value
  28625. * @param array defines the array of float32 to store
  28626. */
  28627. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28628. /**
  28629. * Set the value of an uniform to an array of float32 (stored as vec4)
  28630. * @param uniform defines the webGL uniform location where to store the value
  28631. * @param array defines the array of float32 to store
  28632. */
  28633. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28634. /**
  28635. * Set the value of an uniform to an array of number
  28636. * @param uniform defines the webGL uniform location where to store the value
  28637. * @param array defines the array of number to store
  28638. */
  28639. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28640. /**
  28641. * Set the value of an uniform to an array of number (stored as vec2)
  28642. * @param uniform defines the webGL uniform location where to store the value
  28643. * @param array defines the array of number to store
  28644. */
  28645. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28646. /**
  28647. * Set the value of an uniform to an array of number (stored as vec3)
  28648. * @param uniform defines the webGL uniform location where to store the value
  28649. * @param array defines the array of number to store
  28650. */
  28651. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28652. /**
  28653. * Set the value of an uniform to an array of number (stored as vec4)
  28654. * @param uniform defines the webGL uniform location where to store the value
  28655. * @param array defines the array of number to store
  28656. */
  28657. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28658. /**
  28659. * Set the value of an uniform to an array of float32 (stored as matrices)
  28660. * @param uniform defines the webGL uniform location where to store the value
  28661. * @param matrices defines the array of float32 to store
  28662. */
  28663. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28664. /**
  28665. * Set the value of an uniform to a matrix
  28666. * @param uniform defines the webGL uniform location where to store the value
  28667. * @param matrix defines the matrix to store
  28668. */
  28669. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28670. /**
  28671. * Set the value of an uniform to a matrix (3x3)
  28672. * @param uniform defines the webGL uniform location where to store the value
  28673. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28674. */
  28675. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28676. /**
  28677. * Set the value of an uniform to a matrix (2x2)
  28678. * @param uniform defines the webGL uniform location where to store the value
  28679. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28680. */
  28681. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28682. /**
  28683. * Set the value of an uniform to a number (int)
  28684. * @param uniform defines the webGL uniform location where to store the value
  28685. * @param value defines the int number to store
  28686. */
  28687. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28688. /**
  28689. * Set the value of an uniform to a number (float)
  28690. * @param uniform defines the webGL uniform location where to store the value
  28691. * @param value defines the float number to store
  28692. */
  28693. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28694. /**
  28695. * Set the value of an uniform to a vec2
  28696. * @param uniform defines the webGL uniform location where to store the value
  28697. * @param x defines the 1st component of the value
  28698. * @param y defines the 2nd component of the value
  28699. */
  28700. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28701. /**
  28702. * Set the value of an uniform to a vec3
  28703. * @param uniform defines the webGL uniform location where to store the value
  28704. * @param x defines the 1st component of the value
  28705. * @param y defines the 2nd component of the value
  28706. * @param z defines the 3rd component of the value
  28707. */
  28708. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28709. /**
  28710. * Set the value of an uniform to a boolean
  28711. * @param uniform defines the webGL uniform location where to store the value
  28712. * @param bool defines the boolean to store
  28713. */
  28714. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28715. /**
  28716. * Set the value of an uniform to a vec4
  28717. * @param uniform defines the webGL uniform location where to store the value
  28718. * @param x defines the 1st component of the value
  28719. * @param y defines the 2nd component of the value
  28720. * @param z defines the 3rd component of the value
  28721. * @param w defines the 4th component of the value
  28722. */
  28723. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28724. /**
  28725. * Set the value of an uniform to a Color3
  28726. * @param uniform defines the webGL uniform location where to store the value
  28727. * @param color3 defines the color to store
  28728. */
  28729. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28730. /**
  28731. * Set the value of an uniform to a Color3 and an alpha value
  28732. * @param uniform defines the webGL uniform location where to store the value
  28733. * @param color3 defines the color to store
  28734. * @param alpha defines the alpha component to store
  28735. */
  28736. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28737. /**
  28738. * Sets a Color4 on a uniform variable
  28739. * @param uniform defines the uniform location
  28740. * @param color4 defines the value to be set
  28741. */
  28742. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28743. /**
  28744. * Set various states to the webGL context
  28745. * @param culling defines backface culling state
  28746. * @param zOffset defines the value to apply to zOffset (0 by default)
  28747. * @param force defines if states must be applied even if cache is up to date
  28748. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28749. */
  28750. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28751. /**
  28752. * Set the z offset to apply to current rendering
  28753. * @param value defines the offset to apply
  28754. */
  28755. setZOffset(value: number): void;
  28756. /**
  28757. * Gets the current value of the zOffset
  28758. * @returns the current zOffset state
  28759. */
  28760. getZOffset(): number;
  28761. /**
  28762. * Enable or disable depth buffering
  28763. * @param enable defines the state to set
  28764. */
  28765. setDepthBuffer(enable: boolean): void;
  28766. /**
  28767. * Gets a boolean indicating if depth writing is enabled
  28768. * @returns the current depth writing state
  28769. */
  28770. getDepthWrite(): boolean;
  28771. /**
  28772. * Enable or disable depth writing
  28773. * @param enable defines the state to set
  28774. */
  28775. setDepthWrite(enable: boolean): void;
  28776. /**
  28777. * Enable or disable color writing
  28778. * @param enable defines the state to set
  28779. */
  28780. setColorWrite(enable: boolean): void;
  28781. /**
  28782. * Gets a boolean indicating if color writing is enabled
  28783. * @returns the current color writing state
  28784. */
  28785. getColorWrite(): boolean;
  28786. /**
  28787. * Sets alpha constants used by some alpha blending modes
  28788. * @param r defines the red component
  28789. * @param g defines the green component
  28790. * @param b defines the blue component
  28791. * @param a defines the alpha component
  28792. */
  28793. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28794. /**
  28795. * Sets the current alpha mode
  28796. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28797. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28798. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28799. */
  28800. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28801. /**
  28802. * Gets the current alpha mode
  28803. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28804. * @returns the current alpha mode
  28805. */
  28806. getAlphaMode(): number;
  28807. /**
  28808. * Clears the list of texture accessible through engine.
  28809. * This can help preventing texture load conflict due to name collision.
  28810. */
  28811. clearInternalTexturesCache(): void;
  28812. /**
  28813. * Force the entire cache to be cleared
  28814. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28815. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28816. */
  28817. wipeCaches(bruteForce?: boolean): void;
  28818. /**
  28819. * Set the compressed texture format to use, based on the formats you have, and the formats
  28820. * supported by the hardware / browser.
  28821. *
  28822. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28823. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28824. * to API arguments needed to compressed textures. This puts the burden on the container
  28825. * generator to house the arcane code for determining these for current & future formats.
  28826. *
  28827. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28828. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28829. *
  28830. * Note: The result of this call is not taken into account when a texture is base64.
  28831. *
  28832. * @param formatsAvailable defines the list of those format families you have created
  28833. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28834. *
  28835. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28836. * @returns The extension selected.
  28837. */
  28838. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28839. private _getSamplingParameters;
  28840. private _partialLoadImg;
  28841. private _cascadeLoadImgs;
  28842. /** @hidden */
  28843. _createTexture(): WebGLTexture;
  28844. /**
  28845. * Usually called from Texture.ts.
  28846. * Passed information to create a WebGLTexture
  28847. * @param urlArg defines a value which contains one of the following:
  28848. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28849. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28850. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28851. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28852. * @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)
  28853. * @param scene needed for loading to the correct scene
  28854. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28855. * @param onLoad optional callback to be called upon successful completion
  28856. * @param onError optional callback to be called upon failure
  28857. * @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
  28858. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28859. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28860. * @param forcedExtension defines the extension to use to pick the right loader
  28861. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28862. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28863. */
  28864. 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;
  28865. private _rescaleTexture;
  28866. /**
  28867. * Update a raw texture
  28868. * @param texture defines the texture to update
  28869. * @param data defines the data to store in the texture
  28870. * @param format defines the format of the data
  28871. * @param invertY defines if data must be stored with Y axis inverted
  28872. * @param compression defines the compression used (null by default)
  28873. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28874. */
  28875. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28876. /**
  28877. * Creates a raw texture
  28878. * @param data defines the data to store in the texture
  28879. * @param width defines the width of the texture
  28880. * @param height defines the height of the texture
  28881. * @param format defines the format of the data
  28882. * @param generateMipMaps defines if the engine should generate the mip levels
  28883. * @param invertY defines if data must be stored with Y axis inverted
  28884. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28885. * @param compression defines the compression used (null by default)
  28886. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28887. * @returns the raw texture inside an InternalTexture
  28888. */
  28889. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28890. private _unpackFlipYCached;
  28891. /**
  28892. * In case you are sharing the context with other applications, it might
  28893. * be interested to not cache the unpack flip y state to ensure a consistent
  28894. * value would be set.
  28895. */
  28896. enableUnpackFlipYCached: boolean;
  28897. /** @hidden */
  28898. _unpackFlipY(value: boolean): void;
  28899. /** @hidden */
  28900. _getUnpackAlignement(): number;
  28901. /**
  28902. * Creates a dynamic texture
  28903. * @param width defines the width of the texture
  28904. * @param height defines the height of the texture
  28905. * @param generateMipMaps defines if the engine should generate the mip levels
  28906. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28907. * @returns the dynamic texture inside an InternalTexture
  28908. */
  28909. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28910. /**
  28911. * Update the sampling mode of a given texture
  28912. * @param samplingMode defines the required sampling mode
  28913. * @param texture defines the texture to update
  28914. */
  28915. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28916. /**
  28917. * Update the content of a dynamic texture
  28918. * @param texture defines the texture to update
  28919. * @param canvas defines the canvas containing the source
  28920. * @param invertY defines if data must be stored with Y axis inverted
  28921. * @param premulAlpha defines if alpha is stored as premultiplied
  28922. * @param format defines the format of the data
  28923. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28924. */
  28925. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28926. /**
  28927. * Update a video texture
  28928. * @param texture defines the texture to update
  28929. * @param video defines the video element to use
  28930. * @param invertY defines if data must be stored with Y axis inverted
  28931. */
  28932. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28933. /**
  28934. * Updates a depth texture Comparison Mode and Function.
  28935. * If the comparison Function is equal to 0, the mode will be set to none.
  28936. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28937. * @param texture The texture to set the comparison function for
  28938. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28939. */
  28940. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28941. private _setupDepthStencilTexture;
  28942. /**
  28943. * Creates a depth stencil texture.
  28944. * This is only available in WebGL 2 or with the depth texture extension available.
  28945. * @param size The size of face edge in the texture.
  28946. * @param options The options defining the texture.
  28947. * @returns The texture
  28948. */
  28949. createDepthStencilTexture(size: number | {
  28950. width: number;
  28951. height: number;
  28952. }, options: DepthTextureCreationOptions): InternalTexture;
  28953. /**
  28954. * Creates a depth stencil texture.
  28955. * This is only available in WebGL 2 or with the depth texture extension available.
  28956. * @param size The size of face edge in the texture.
  28957. * @param options The options defining the texture.
  28958. * @returns The texture
  28959. */
  28960. private _createDepthStencilTexture;
  28961. /**
  28962. * Creates a depth stencil cube texture.
  28963. * This is only available in WebGL 2.
  28964. * @param size The size of face edge in the cube texture.
  28965. * @param options The options defining the cube texture.
  28966. * @returns The cube texture
  28967. */
  28968. private _createDepthStencilCubeTexture;
  28969. /**
  28970. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28971. * @param renderTarget The render target to set the frame buffer for
  28972. */
  28973. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28974. /**
  28975. * Creates a new render target texture
  28976. * @param size defines the size of the texture
  28977. * @param options defines the options used to create the texture
  28978. * @returns a new render target texture stored in an InternalTexture
  28979. */
  28980. createRenderTargetTexture(size: number | {
  28981. width: number;
  28982. height: number;
  28983. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28984. /**
  28985. * Create a multi render target texture
  28986. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28987. * @param size defines the size of the texture
  28988. * @param options defines the creation options
  28989. * @returns the cube texture as an InternalTexture
  28990. */
  28991. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28992. private _setupFramebufferDepthAttachments;
  28993. /**
  28994. * Updates the sample count of a render target texture
  28995. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28996. * @param texture defines the texture to update
  28997. * @param samples defines the sample count to set
  28998. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28999. */
  29000. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29001. /**
  29002. * Update the sample count for a given multiple render target texture
  29003. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29004. * @param textures defines the textures to update
  29005. * @param samples defines the sample count to set
  29006. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29007. */
  29008. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29009. /** @hidden */
  29010. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29011. /** @hidden */
  29012. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29013. /** @hidden */
  29014. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29015. /** @hidden */
  29016. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29017. /**
  29018. * Creates a new render target cube texture
  29019. * @param size defines the size of the texture
  29020. * @param options defines the options used to create the texture
  29021. * @returns a new render target cube texture stored in an InternalTexture
  29022. */
  29023. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29024. /**
  29025. * Creates a cube texture
  29026. * @param rootUrl defines the url where the files to load is located
  29027. * @param scene defines the current scene
  29028. * @param files defines the list of files to load (1 per face)
  29029. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29030. * @param onLoad defines an optional callback raised when the texture is loaded
  29031. * @param onError defines an optional callback raised if there is an issue to load the texture
  29032. * @param format defines the format of the data
  29033. * @param forcedExtension defines the extension to use to pick the right loader
  29034. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29035. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29036. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29037. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29038. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29039. * @returns the cube texture as an InternalTexture
  29040. */
  29041. 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;
  29042. /**
  29043. * @hidden
  29044. */
  29045. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29046. /**
  29047. * Update a raw cube texture
  29048. * @param texture defines the texture to udpdate
  29049. * @param data defines the data to store
  29050. * @param format defines the data format
  29051. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29052. * @param invertY defines if data must be stored with Y axis inverted
  29053. * @param compression defines the compression used (null by default)
  29054. * @param level defines which level of the texture to update
  29055. */
  29056. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29057. /**
  29058. * Creates a new raw cube texture
  29059. * @param data defines the array of data to use to create each face
  29060. * @param size defines the size of the textures
  29061. * @param format defines the format of the data
  29062. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29063. * @param generateMipMaps defines if the engine should generate the mip levels
  29064. * @param invertY defines if data must be stored with Y axis inverted
  29065. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29066. * @param compression defines the compression used (null by default)
  29067. * @returns the cube texture as an InternalTexture
  29068. */
  29069. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29070. /**
  29071. * Creates a new raw cube texture from a specified url
  29072. * @param url defines the url where the data is located
  29073. * @param scene defines the current scene
  29074. * @param size defines the size of the textures
  29075. * @param format defines the format of the data
  29076. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29077. * @param noMipmap defines if the engine should avoid generating the mip levels
  29078. * @param callback defines a callback used to extract texture data from loaded data
  29079. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29080. * @param onLoad defines a callback called when texture is loaded
  29081. * @param onError defines a callback called if there is an error
  29082. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29083. * @param invertY defines if data must be stored with Y axis inverted
  29084. * @returns the cube texture as an InternalTexture
  29085. */
  29086. 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;
  29087. /**
  29088. * Update a raw 3D texture
  29089. * @param texture defines the texture to update
  29090. * @param data defines the data to store
  29091. * @param format defines the data format
  29092. * @param invertY defines if data must be stored with Y axis inverted
  29093. * @param compression defines the used compression (can be null)
  29094. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29095. */
  29096. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29097. /**
  29098. * Creates a new raw 3D texture
  29099. * @param data defines the data used to create the texture
  29100. * @param width defines the width of the texture
  29101. * @param height defines the height of the texture
  29102. * @param depth defines the depth of the texture
  29103. * @param format defines the format of the texture
  29104. * @param generateMipMaps defines if the engine must generate mip levels
  29105. * @param invertY defines if data must be stored with Y axis inverted
  29106. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29107. * @param compression defines the compressed used (can be null)
  29108. * @param textureType defines the compressed used (can be null)
  29109. * @returns a new raw 3D texture (stored in an InternalTexture)
  29110. */
  29111. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29112. private _prepareWebGLTextureContinuation;
  29113. private _prepareWebGLTexture;
  29114. private _convertRGBtoRGBATextureData;
  29115. /** @hidden */
  29116. _releaseFramebufferObjects(texture: InternalTexture): void;
  29117. /** @hidden */
  29118. _releaseTexture(texture: InternalTexture): void;
  29119. private setProgram;
  29120. private _boundUniforms;
  29121. /**
  29122. * Binds an effect to the webGL context
  29123. * @param effect defines the effect to bind
  29124. */
  29125. bindSamplers(effect: Effect): void;
  29126. private _moveBoundTextureOnTop;
  29127. private _getCorrectTextureChannel;
  29128. private _linkTrackers;
  29129. private _removeDesignatedSlot;
  29130. private _activateCurrentTexture;
  29131. /** @hidden */
  29132. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29133. /** @hidden */
  29134. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29135. /**
  29136. * Sets a texture to the webGL context from a postprocess
  29137. * @param channel defines the channel to use
  29138. * @param postProcess defines the source postprocess
  29139. */
  29140. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29141. /**
  29142. * Binds the output of the passed in post process to the texture channel specified
  29143. * @param channel The channel the texture should be bound to
  29144. * @param postProcess The post process which's output should be bound
  29145. */
  29146. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29147. /**
  29148. * Unbind all textures from the webGL context
  29149. */
  29150. unbindAllTextures(): void;
  29151. /**
  29152. * Sets a texture to the according uniform.
  29153. * @param channel The texture channel
  29154. * @param uniform The uniform to set
  29155. * @param texture The texture to apply
  29156. */
  29157. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29158. /**
  29159. * Sets a depth stencil texture from a render target to the according uniform.
  29160. * @param channel The texture channel
  29161. * @param uniform The uniform to set
  29162. * @param texture The render target texture containing the depth stencil texture to apply
  29163. */
  29164. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29165. private _bindSamplerUniformToChannel;
  29166. private _getTextureWrapMode;
  29167. private _setTexture;
  29168. /**
  29169. * Sets an array of texture to the webGL context
  29170. * @param channel defines the channel where the texture array must be set
  29171. * @param uniform defines the associated uniform location
  29172. * @param textures defines the array of textures to bind
  29173. */
  29174. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29175. /** @hidden */
  29176. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29177. private _setTextureParameterFloat;
  29178. private _setTextureParameterInteger;
  29179. /**
  29180. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29181. * @param x defines the x coordinate of the rectangle where pixels must be read
  29182. * @param y defines the y coordinate of the rectangle where pixels must be read
  29183. * @param width defines the width of the rectangle where pixels must be read
  29184. * @param height defines the height of the rectangle where pixels must be read
  29185. * @returns a Uint8Array containing RGBA colors
  29186. */
  29187. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29188. /**
  29189. * Add an externaly attached data from its key.
  29190. * This method call will fail and return false, if such key already exists.
  29191. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29192. * @param key the unique key that identifies the data
  29193. * @param data the data object to associate to the key for this Engine instance
  29194. * @return true if no such key were already present and the data was added successfully, false otherwise
  29195. */
  29196. addExternalData<T>(key: string, data: T): boolean;
  29197. /**
  29198. * Get an externaly attached data from its key
  29199. * @param key the unique key that identifies the data
  29200. * @return the associated data, if present (can be null), or undefined if not present
  29201. */
  29202. getExternalData<T>(key: string): T;
  29203. /**
  29204. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29205. * @param key the unique key that identifies the data
  29206. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29207. * @return the associated data, can be null if the factory returned null.
  29208. */
  29209. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29210. /**
  29211. * Remove an externaly attached data from the Engine instance
  29212. * @param key the unique key that identifies the data
  29213. * @return true if the data was successfully removed, false if it doesn't exist
  29214. */
  29215. removeExternalData(key: string): boolean;
  29216. /**
  29217. * Unbind all vertex attributes from the webGL context
  29218. */
  29219. unbindAllAttributes(): void;
  29220. /**
  29221. * 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
  29222. */
  29223. releaseEffects(): void;
  29224. /**
  29225. * Dispose and release all associated resources
  29226. */
  29227. dispose(): void;
  29228. /**
  29229. * Display the loading screen
  29230. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29231. */
  29232. displayLoadingUI(): void;
  29233. /**
  29234. * Hide the loading screen
  29235. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29236. */
  29237. hideLoadingUI(): void;
  29238. /**
  29239. * Gets the current loading screen object
  29240. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29241. */
  29242. /**
  29243. * Sets the current loading screen object
  29244. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29245. */
  29246. loadingScreen: ILoadingScreen;
  29247. /**
  29248. * Sets the current loading screen text
  29249. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29250. */
  29251. loadingUIText: string;
  29252. /**
  29253. * Sets the current loading screen background color
  29254. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29255. */
  29256. loadingUIBackgroundColor: string;
  29257. /**
  29258. * Attach a new callback raised when context lost event is fired
  29259. * @param callback defines the callback to call
  29260. */
  29261. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29262. /**
  29263. * Attach a new callback raised when context restored event is fired
  29264. * @param callback defines the callback to call
  29265. */
  29266. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29267. /**
  29268. * Gets the source code of the vertex shader associated with a specific webGL program
  29269. * @param program defines the program to use
  29270. * @returns a string containing the source code of the vertex shader associated with the program
  29271. */
  29272. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29273. /**
  29274. * Gets the source code of the fragment shader associated with a specific webGL program
  29275. * @param program defines the program to use
  29276. * @returns a string containing the source code of the fragment shader associated with the program
  29277. */
  29278. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29279. /**
  29280. * Get the current error code of the webGL context
  29281. * @returns the error code
  29282. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29283. */
  29284. getError(): number;
  29285. /**
  29286. * Gets the current framerate
  29287. * @returns a number representing the framerate
  29288. */
  29289. getFps(): number;
  29290. /**
  29291. * Gets the time spent between current and previous frame
  29292. * @returns a number representing the delta time in ms
  29293. */
  29294. getDeltaTime(): number;
  29295. private _measureFps;
  29296. /** @hidden */
  29297. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29298. private _canRenderToFloatFramebuffer;
  29299. private _canRenderToHalfFloatFramebuffer;
  29300. private _canRenderToFramebuffer;
  29301. /** @hidden */
  29302. _getWebGLTextureType(type: number): number;
  29303. private _getInternalFormat;
  29304. /** @hidden */
  29305. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29306. /** @hidden */
  29307. _getRGBAMultiSampleBufferFormat(type: number): number;
  29308. /** @hidden */
  29309. _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;
  29310. /** @hidden */
  29311. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29312. private _partialLoadFile;
  29313. private _cascadeLoadFiles;
  29314. /**
  29315. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29316. * @returns true if the engine can be created
  29317. * @ignorenaming
  29318. */
  29319. static isSupported(): boolean;
  29320. }
  29321. }
  29322. declare module "babylonjs/Materials/effect" {
  29323. import { Observable } from "babylonjs/Misc/observable";
  29324. import { Nullable } from "babylonjs/types";
  29325. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29326. import { Engine } from "babylonjs/Engines/engine";
  29327. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29328. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29329. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29330. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29332. /**
  29333. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29334. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29335. */
  29336. export class EffectFallbacks {
  29337. private _defines;
  29338. private _currentRank;
  29339. private _maxRank;
  29340. private _mesh;
  29341. /**
  29342. * Removes the fallback from the bound mesh.
  29343. */
  29344. unBindMesh(): void;
  29345. /**
  29346. * Adds a fallback on the specified property.
  29347. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29348. * @param define The name of the define in the shader
  29349. */
  29350. addFallback(rank: number, define: string): void;
  29351. /**
  29352. * Sets the mesh to use CPU skinning when needing to fallback.
  29353. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29354. * @param mesh The mesh to use the fallbacks.
  29355. */
  29356. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29357. /**
  29358. * Checks to see if more fallbacks are still availible.
  29359. */
  29360. readonly isMoreFallbacks: boolean;
  29361. /**
  29362. * Removes the defines that shoould be removed when falling back.
  29363. * @param currentDefines defines the current define statements for the shader.
  29364. * @param effect defines the current effect we try to compile
  29365. * @returns The resulting defines with defines of the current rank removed.
  29366. */
  29367. reduce(currentDefines: string, effect: Effect): string;
  29368. }
  29369. /**
  29370. * Options to be used when creating an effect.
  29371. */
  29372. export class EffectCreationOptions {
  29373. /**
  29374. * Atrributes that will be used in the shader.
  29375. */
  29376. attributes: string[];
  29377. /**
  29378. * Uniform varible names that will be set in the shader.
  29379. */
  29380. uniformsNames: string[];
  29381. /**
  29382. * Uniform buffer varible names that will be set in the shader.
  29383. */
  29384. uniformBuffersNames: string[];
  29385. /**
  29386. * Sampler texture variable names that will be set in the shader.
  29387. */
  29388. samplers: string[];
  29389. /**
  29390. * Define statements that will be set in the shader.
  29391. */
  29392. defines: any;
  29393. /**
  29394. * Possible fallbacks for this effect to improve performance when needed.
  29395. */
  29396. fallbacks: Nullable<EffectFallbacks>;
  29397. /**
  29398. * Callback that will be called when the shader is compiled.
  29399. */
  29400. onCompiled: Nullable<(effect: Effect) => void>;
  29401. /**
  29402. * Callback that will be called if an error occurs during shader compilation.
  29403. */
  29404. onError: Nullable<(effect: Effect, errors: string) => void>;
  29405. /**
  29406. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29407. */
  29408. indexParameters: any;
  29409. /**
  29410. * Max number of lights that can be used in the shader.
  29411. */
  29412. maxSimultaneousLights: number;
  29413. /**
  29414. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29415. */
  29416. transformFeedbackVaryings: Nullable<string[]>;
  29417. }
  29418. /**
  29419. * Effect containing vertex and fragment shader that can be executed on an object.
  29420. */
  29421. export class Effect {
  29422. /**
  29423. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29424. */
  29425. static ShadersRepository: string;
  29426. /**
  29427. * Name of the effect.
  29428. */
  29429. name: any;
  29430. /**
  29431. * String container all the define statements that should be set on the shader.
  29432. */
  29433. defines: string;
  29434. /**
  29435. * Callback that will be called when the shader is compiled.
  29436. */
  29437. onCompiled: Nullable<(effect: Effect) => void>;
  29438. /**
  29439. * Callback that will be called if an error occurs during shader compilation.
  29440. */
  29441. onError: Nullable<(effect: Effect, errors: string) => void>;
  29442. /**
  29443. * Callback that will be called when effect is bound.
  29444. */
  29445. onBind: Nullable<(effect: Effect) => void>;
  29446. /**
  29447. * Unique ID of the effect.
  29448. */
  29449. uniqueId: number;
  29450. /**
  29451. * Observable that will be called when the shader is compiled.
  29452. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29453. */
  29454. onCompileObservable: Observable<Effect>;
  29455. /**
  29456. * Observable that will be called if an error occurs during shader compilation.
  29457. */
  29458. onErrorObservable: Observable<Effect>;
  29459. /** @hidden */
  29460. _onBindObservable: Nullable<Observable<Effect>>;
  29461. /**
  29462. * Observable that will be called when effect is bound.
  29463. */
  29464. readonly onBindObservable: Observable<Effect>;
  29465. /** @hidden */
  29466. _bonesComputationForcedToCPU: boolean;
  29467. private static _uniqueIdSeed;
  29468. private _engine;
  29469. private _uniformBuffersNames;
  29470. private _uniformsNames;
  29471. private _samplers;
  29472. private _isReady;
  29473. private _compilationError;
  29474. private _attributesNames;
  29475. private _attributes;
  29476. private _uniforms;
  29477. /**
  29478. * Key for the effect.
  29479. * @hidden
  29480. */
  29481. _key: string;
  29482. private _indexParameters;
  29483. private _fallbacks;
  29484. private _vertexSourceCode;
  29485. private _fragmentSourceCode;
  29486. private _vertexSourceCodeOverride;
  29487. private _fragmentSourceCodeOverride;
  29488. private _transformFeedbackVaryings;
  29489. /**
  29490. * Compiled shader to webGL program.
  29491. * @hidden
  29492. */
  29493. _program: WebGLProgram;
  29494. private _valueCache;
  29495. private static _baseCache;
  29496. /**
  29497. * Instantiates an effect.
  29498. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29499. * @param baseName Name of the effect.
  29500. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29501. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29502. * @param samplers List of sampler variables that will be passed to the shader.
  29503. * @param engine Engine to be used to render the effect
  29504. * @param defines Define statements to be added to the shader.
  29505. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29506. * @param onCompiled Callback that will be called when the shader is compiled.
  29507. * @param onError Callback that will be called if an error occurs during shader compilation.
  29508. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29509. */
  29510. 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);
  29511. /**
  29512. * Unique key for this effect
  29513. */
  29514. readonly key: string;
  29515. /**
  29516. * If the effect has been compiled and prepared.
  29517. * @returns if the effect is compiled and prepared.
  29518. */
  29519. isReady(): boolean;
  29520. /**
  29521. * The engine the effect was initialized with.
  29522. * @returns the engine.
  29523. */
  29524. getEngine(): Engine;
  29525. /**
  29526. * The compiled webGL program for the effect
  29527. * @returns the webGL program.
  29528. */
  29529. getProgram(): WebGLProgram;
  29530. /**
  29531. * The set of names of attribute variables for the shader.
  29532. * @returns An array of attribute names.
  29533. */
  29534. getAttributesNames(): string[];
  29535. /**
  29536. * Returns the attribute at the given index.
  29537. * @param index The index of the attribute.
  29538. * @returns The location of the attribute.
  29539. */
  29540. getAttributeLocation(index: number): number;
  29541. /**
  29542. * Returns the attribute based on the name of the variable.
  29543. * @param name of the attribute to look up.
  29544. * @returns the attribute location.
  29545. */
  29546. getAttributeLocationByName(name: string): number;
  29547. /**
  29548. * The number of attributes.
  29549. * @returns the numnber of attributes.
  29550. */
  29551. getAttributesCount(): number;
  29552. /**
  29553. * Gets the index of a uniform variable.
  29554. * @param uniformName of the uniform to look up.
  29555. * @returns the index.
  29556. */
  29557. getUniformIndex(uniformName: string): number;
  29558. /**
  29559. * Returns the attribute based on the name of the variable.
  29560. * @param uniformName of the uniform to look up.
  29561. * @returns the location of the uniform.
  29562. */
  29563. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29564. /**
  29565. * Returns an array of sampler variable names
  29566. * @returns The array of sampler variable neames.
  29567. */
  29568. getSamplers(): string[];
  29569. /**
  29570. * The error from the last compilation.
  29571. * @returns the error string.
  29572. */
  29573. getCompilationError(): string;
  29574. /**
  29575. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29576. * @param func The callback to be used.
  29577. */
  29578. executeWhenCompiled(func: (effect: Effect) => void): void;
  29579. private _checkIsReady;
  29580. /** @hidden */
  29581. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29582. /** @hidden */
  29583. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29584. /** @hidden */
  29585. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29586. private _processShaderConversion;
  29587. private _processIncludes;
  29588. private _processPrecision;
  29589. /**
  29590. * Recompiles the webGL program
  29591. * @param vertexSourceCode The source code for the vertex shader.
  29592. * @param fragmentSourceCode The source code for the fragment shader.
  29593. * @param onCompiled Callback called when completed.
  29594. * @param onError Callback called on error.
  29595. * @hidden
  29596. */
  29597. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29598. /**
  29599. * Gets the uniform locations of the the specified variable names
  29600. * @param names THe names of the variables to lookup.
  29601. * @returns Array of locations in the same order as variable names.
  29602. */
  29603. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29604. /**
  29605. * Prepares the effect
  29606. * @hidden
  29607. */
  29608. _prepareEffect(): void;
  29609. /**
  29610. * Checks if the effect is supported. (Must be called after compilation)
  29611. */
  29612. readonly isSupported: boolean;
  29613. /**
  29614. * Binds a texture to the engine to be used as output of the shader.
  29615. * @param channel Name of the output variable.
  29616. * @param texture Texture to bind.
  29617. * @hidden
  29618. */
  29619. _bindTexture(channel: string, texture: InternalTexture): void;
  29620. /**
  29621. * Sets a texture on the engine to be used in the shader.
  29622. * @param channel Name of the sampler variable.
  29623. * @param texture Texture to set.
  29624. */
  29625. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29626. /**
  29627. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29628. * @param channel Name of the sampler variable.
  29629. * @param texture Texture to set.
  29630. */
  29631. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29632. /**
  29633. * Sets an array of textures on the engine to be used in the shader.
  29634. * @param channel Name of the variable.
  29635. * @param textures Textures to set.
  29636. */
  29637. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29638. /**
  29639. * 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)
  29640. * @param channel Name of the sampler variable.
  29641. * @param postProcess Post process to get the input texture from.
  29642. */
  29643. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29644. /**
  29645. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29646. * 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)
  29647. * @param channel Name of the sampler variable.
  29648. * @param postProcess Post process to get the output texture from.
  29649. */
  29650. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29651. /** @hidden */
  29652. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29653. /** @hidden */
  29654. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29655. /** @hidden */
  29656. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29657. /** @hidden */
  29658. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29659. /**
  29660. * Binds a buffer to a uniform.
  29661. * @param buffer Buffer to bind.
  29662. * @param name Name of the uniform variable to bind to.
  29663. */
  29664. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29665. /**
  29666. * Binds block to a uniform.
  29667. * @param blockName Name of the block to bind.
  29668. * @param index Index to bind.
  29669. */
  29670. bindUniformBlock(blockName: string, index: number): void;
  29671. /**
  29672. * Sets an interger value on a uniform variable.
  29673. * @param uniformName Name of the variable.
  29674. * @param value Value to be set.
  29675. * @returns this effect.
  29676. */
  29677. setInt(uniformName: string, value: number): Effect;
  29678. /**
  29679. * Sets an int array on a uniform variable.
  29680. * @param uniformName Name of the variable.
  29681. * @param array array to be set.
  29682. * @returns this effect.
  29683. */
  29684. setIntArray(uniformName: string, array: Int32Array): Effect;
  29685. /**
  29686. * 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)
  29687. * @param uniformName Name of the variable.
  29688. * @param array array to be set.
  29689. * @returns this effect.
  29690. */
  29691. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29692. /**
  29693. * 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)
  29694. * @param uniformName Name of the variable.
  29695. * @param array array to be set.
  29696. * @returns this effect.
  29697. */
  29698. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29699. /**
  29700. * 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)
  29701. * @param uniformName Name of the variable.
  29702. * @param array array to be set.
  29703. * @returns this effect.
  29704. */
  29705. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29706. /**
  29707. * Sets an float array on a uniform variable.
  29708. * @param uniformName Name of the variable.
  29709. * @param array array to be set.
  29710. * @returns this effect.
  29711. */
  29712. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29713. /**
  29714. * 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)
  29715. * @param uniformName Name of the variable.
  29716. * @param array array to be set.
  29717. * @returns this effect.
  29718. */
  29719. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29720. /**
  29721. * 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)
  29722. * @param uniformName Name of the variable.
  29723. * @param array array to be set.
  29724. * @returns this effect.
  29725. */
  29726. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29727. /**
  29728. * 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)
  29729. * @param uniformName Name of the variable.
  29730. * @param array array to be set.
  29731. * @returns this effect.
  29732. */
  29733. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29734. /**
  29735. * Sets an array on a uniform variable.
  29736. * @param uniformName Name of the variable.
  29737. * @param array array to be set.
  29738. * @returns this effect.
  29739. */
  29740. setArray(uniformName: string, array: number[]): Effect;
  29741. /**
  29742. * 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)
  29743. * @param uniformName Name of the variable.
  29744. * @param array array to be set.
  29745. * @returns this effect.
  29746. */
  29747. setArray2(uniformName: string, array: number[]): Effect;
  29748. /**
  29749. * 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)
  29750. * @param uniformName Name of the variable.
  29751. * @param array array to be set.
  29752. * @returns this effect.
  29753. */
  29754. setArray3(uniformName: string, array: number[]): Effect;
  29755. /**
  29756. * 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)
  29757. * @param uniformName Name of the variable.
  29758. * @param array array to be set.
  29759. * @returns this effect.
  29760. */
  29761. setArray4(uniformName: string, array: number[]): Effect;
  29762. /**
  29763. * Sets matrices on a uniform variable.
  29764. * @param uniformName Name of the variable.
  29765. * @param matrices matrices to be set.
  29766. * @returns this effect.
  29767. */
  29768. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29769. /**
  29770. * Sets matrix on a uniform variable.
  29771. * @param uniformName Name of the variable.
  29772. * @param matrix matrix to be set.
  29773. * @returns this effect.
  29774. */
  29775. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29776. /**
  29777. * 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)
  29778. * @param uniformName Name of the variable.
  29779. * @param matrix matrix to be set.
  29780. * @returns this effect.
  29781. */
  29782. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29783. /**
  29784. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29785. * @param uniformName Name of the variable.
  29786. * @param matrix matrix to be set.
  29787. * @returns this effect.
  29788. */
  29789. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29790. /**
  29791. * Sets a float on a uniform variable.
  29792. * @param uniformName Name of the variable.
  29793. * @param value value to be set.
  29794. * @returns this effect.
  29795. */
  29796. setFloat(uniformName: string, value: number): Effect;
  29797. /**
  29798. * Sets a boolean on a uniform variable.
  29799. * @param uniformName Name of the variable.
  29800. * @param bool value to be set.
  29801. * @returns this effect.
  29802. */
  29803. setBool(uniformName: string, bool: boolean): Effect;
  29804. /**
  29805. * Sets a Vector2 on a uniform variable.
  29806. * @param uniformName Name of the variable.
  29807. * @param vector2 vector2 to be set.
  29808. * @returns this effect.
  29809. */
  29810. setVector2(uniformName: string, vector2: Vector2): Effect;
  29811. /**
  29812. * Sets a float2 on a uniform variable.
  29813. * @param uniformName Name of the variable.
  29814. * @param x First float in float2.
  29815. * @param y Second float in float2.
  29816. * @returns this effect.
  29817. */
  29818. setFloat2(uniformName: string, x: number, y: number): Effect;
  29819. /**
  29820. * Sets a Vector3 on a uniform variable.
  29821. * @param uniformName Name of the variable.
  29822. * @param vector3 Value to be set.
  29823. * @returns this effect.
  29824. */
  29825. setVector3(uniformName: string, vector3: Vector3): Effect;
  29826. /**
  29827. * Sets a float3 on a uniform variable.
  29828. * @param uniformName Name of the variable.
  29829. * @param x First float in float3.
  29830. * @param y Second float in float3.
  29831. * @param z Third float in float3.
  29832. * @returns this effect.
  29833. */
  29834. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29835. /**
  29836. * Sets a Vector4 on a uniform variable.
  29837. * @param uniformName Name of the variable.
  29838. * @param vector4 Value to be set.
  29839. * @returns this effect.
  29840. */
  29841. setVector4(uniformName: string, vector4: Vector4): Effect;
  29842. /**
  29843. * Sets a float4 on a uniform variable.
  29844. * @param uniformName Name of the variable.
  29845. * @param x First float in float4.
  29846. * @param y Second float in float4.
  29847. * @param z Third float in float4.
  29848. * @param w Fourth float in float4.
  29849. * @returns this effect.
  29850. */
  29851. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29852. /**
  29853. * Sets a Color3 on a uniform variable.
  29854. * @param uniformName Name of the variable.
  29855. * @param color3 Value to be set.
  29856. * @returns this effect.
  29857. */
  29858. setColor3(uniformName: string, color3: Color3): Effect;
  29859. /**
  29860. * Sets a Color4 on a uniform variable.
  29861. * @param uniformName Name of the variable.
  29862. * @param color3 Value to be set.
  29863. * @param alpha Alpha value to be set.
  29864. * @returns this effect.
  29865. */
  29866. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29867. /**
  29868. * Sets a Color4 on a uniform variable
  29869. * @param uniformName defines the name of the variable
  29870. * @param color4 defines the value to be set
  29871. * @returns this effect.
  29872. */
  29873. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29874. /**
  29875. * This function will add a new shader to the shader store
  29876. * @param name the name of the shader
  29877. * @param pixelShader optional pixel shader content
  29878. * @param vertexShader optional vertex shader content
  29879. */
  29880. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29881. /**
  29882. * Store of each shader (The can be looked up using effect.key)
  29883. */
  29884. static ShadersStore: {
  29885. [key: string]: string;
  29886. };
  29887. /**
  29888. * Store of each included file for a shader (The can be looked up using effect.key)
  29889. */
  29890. static IncludesShadersStore: {
  29891. [key: string]: string;
  29892. };
  29893. /**
  29894. * Resets the cache of effects.
  29895. */
  29896. static ResetCache(): void;
  29897. }
  29898. }
  29899. declare module "babylonjs/Materials/colorCurves" {
  29900. import { Effect } from "babylonjs/Materials/effect";
  29901. /**
  29902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29904. * 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;
  29905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29906. */
  29907. export class ColorCurves {
  29908. private _dirty;
  29909. private _tempColor;
  29910. private _globalCurve;
  29911. private _highlightsCurve;
  29912. private _midtonesCurve;
  29913. private _shadowsCurve;
  29914. private _positiveCurve;
  29915. private _negativeCurve;
  29916. private _globalHue;
  29917. private _globalDensity;
  29918. private _globalSaturation;
  29919. private _globalExposure;
  29920. /**
  29921. * Gets the global Hue value.
  29922. * 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).
  29923. */
  29924. /**
  29925. * Sets the global Hue value.
  29926. * 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).
  29927. */
  29928. globalHue: number;
  29929. /**
  29930. * Gets the global Density value.
  29931. * 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.
  29932. * Values less than zero provide a filter of opposite hue.
  29933. */
  29934. /**
  29935. * Sets the global Density value.
  29936. * 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.
  29937. * Values less than zero provide a filter of opposite hue.
  29938. */
  29939. globalDensity: number;
  29940. /**
  29941. * Gets the global Saturation value.
  29942. * 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.
  29943. */
  29944. /**
  29945. * Sets the global Saturation value.
  29946. * 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.
  29947. */
  29948. globalSaturation: number;
  29949. /**
  29950. * Gets the global Exposure value.
  29951. * 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.
  29952. */
  29953. /**
  29954. * Sets the global Exposure value.
  29955. * 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.
  29956. */
  29957. globalExposure: number;
  29958. private _highlightsHue;
  29959. private _highlightsDensity;
  29960. private _highlightsSaturation;
  29961. private _highlightsExposure;
  29962. /**
  29963. * Gets the highlights Hue value.
  29964. * 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).
  29965. */
  29966. /**
  29967. * Sets the highlights Hue value.
  29968. * 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).
  29969. */
  29970. highlightsHue: number;
  29971. /**
  29972. * Gets the highlights Density value.
  29973. * 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.
  29974. * Values less than zero provide a filter of opposite hue.
  29975. */
  29976. /**
  29977. * Sets the highlights Density value.
  29978. * 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.
  29979. * Values less than zero provide a filter of opposite hue.
  29980. */
  29981. highlightsDensity: number;
  29982. /**
  29983. * Gets the highlights Saturation value.
  29984. * 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.
  29985. */
  29986. /**
  29987. * Sets the highlights Saturation value.
  29988. * 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.
  29989. */
  29990. highlightsSaturation: number;
  29991. /**
  29992. * Gets the highlights Exposure value.
  29993. * 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.
  29994. */
  29995. /**
  29996. * Sets the highlights Exposure value.
  29997. * 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.
  29998. */
  29999. highlightsExposure: number;
  30000. private _midtonesHue;
  30001. private _midtonesDensity;
  30002. private _midtonesSaturation;
  30003. private _midtonesExposure;
  30004. /**
  30005. * Gets the midtones Hue value.
  30006. * 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).
  30007. */
  30008. /**
  30009. * Sets the midtones Hue value.
  30010. * 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).
  30011. */
  30012. midtonesHue: number;
  30013. /**
  30014. * Gets the midtones Density value.
  30015. * 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.
  30016. * Values less than zero provide a filter of opposite hue.
  30017. */
  30018. /**
  30019. * Sets the midtones Density value.
  30020. * 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.
  30021. * Values less than zero provide a filter of opposite hue.
  30022. */
  30023. midtonesDensity: number;
  30024. /**
  30025. * Gets the midtones Saturation value.
  30026. * 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.
  30027. */
  30028. /**
  30029. * Sets the midtones Saturation value.
  30030. * 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.
  30031. */
  30032. midtonesSaturation: number;
  30033. /**
  30034. * Gets the midtones Exposure value.
  30035. * 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.
  30036. */
  30037. /**
  30038. * Sets the midtones Exposure value.
  30039. * 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.
  30040. */
  30041. midtonesExposure: number;
  30042. private _shadowsHue;
  30043. private _shadowsDensity;
  30044. private _shadowsSaturation;
  30045. private _shadowsExposure;
  30046. /**
  30047. * Gets the shadows Hue value.
  30048. * 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).
  30049. */
  30050. /**
  30051. * Sets the shadows Hue value.
  30052. * 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).
  30053. */
  30054. shadowsHue: number;
  30055. /**
  30056. * Gets the shadows Density value.
  30057. * 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.
  30058. * Values less than zero provide a filter of opposite hue.
  30059. */
  30060. /**
  30061. * Sets the shadows Density value.
  30062. * 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.
  30063. * Values less than zero provide a filter of opposite hue.
  30064. */
  30065. shadowsDensity: number;
  30066. /**
  30067. * Gets the shadows Saturation value.
  30068. * 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.
  30069. */
  30070. /**
  30071. * Sets the shadows Saturation value.
  30072. * 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.
  30073. */
  30074. shadowsSaturation: number;
  30075. /**
  30076. * Gets the shadows Exposure value.
  30077. * 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.
  30078. */
  30079. /**
  30080. * Sets the shadows Exposure value.
  30081. * 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.
  30082. */
  30083. shadowsExposure: number;
  30084. /**
  30085. * Returns the class name
  30086. * @returns The class name
  30087. */
  30088. getClassName(): string;
  30089. /**
  30090. * Binds the color curves to the shader.
  30091. * @param colorCurves The color curve to bind
  30092. * @param effect The effect to bind to
  30093. * @param positiveUniform The positive uniform shader parameter
  30094. * @param neutralUniform The neutral uniform shader parameter
  30095. * @param negativeUniform The negative uniform shader parameter
  30096. */
  30097. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30098. /**
  30099. * Prepare the list of uniforms associated with the ColorCurves effects.
  30100. * @param uniformsList The list of uniforms used in the effect
  30101. */
  30102. static PrepareUniforms(uniformsList: string[]): void;
  30103. /**
  30104. * Returns color grading data based on a hue, density, saturation and exposure value.
  30105. * @param filterHue The hue of the color filter.
  30106. * @param filterDensity The density of the color filter.
  30107. * @param saturation The saturation.
  30108. * @param exposure The exposure.
  30109. * @param result The result data container.
  30110. */
  30111. private getColorGradingDataToRef;
  30112. /**
  30113. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30114. * @param value The input slider value in range [-100,100].
  30115. * @returns Adjusted value.
  30116. */
  30117. private static applyColorGradingSliderNonlinear;
  30118. /**
  30119. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30120. * @param hue The hue (H) input.
  30121. * @param saturation The saturation (S) input.
  30122. * @param brightness The brightness (B) input.
  30123. * @result An RGBA color represented as Vector4.
  30124. */
  30125. private static fromHSBToRef;
  30126. /**
  30127. * Returns a value clamped between min and max
  30128. * @param value The value to clamp
  30129. * @param min The minimum of value
  30130. * @param max The maximum of value
  30131. * @returns The clamped value.
  30132. */
  30133. private static clamp;
  30134. /**
  30135. * Clones the current color curve instance.
  30136. * @return The cloned curves
  30137. */
  30138. clone(): ColorCurves;
  30139. /**
  30140. * Serializes the current color curve instance to a json representation.
  30141. * @return a JSON representation
  30142. */
  30143. serialize(): any;
  30144. /**
  30145. * Parses the color curve from a json representation.
  30146. * @param source the JSON source to parse
  30147. * @return The parsed curves
  30148. */
  30149. static Parse(source: any): ColorCurves;
  30150. }
  30151. }
  30152. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30153. import { Observable } from "babylonjs/Misc/observable";
  30154. import { Nullable } from "babylonjs/types";
  30155. import { Color4 } from "babylonjs/Maths/math";
  30156. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30157. import { Effect } from "babylonjs/Materials/effect";
  30158. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30159. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30160. /**
  30161. * Interface to follow in your material defines to integrate easily the
  30162. * Image proccessing functions.
  30163. * @hidden
  30164. */
  30165. export interface IImageProcessingConfigurationDefines {
  30166. IMAGEPROCESSING: boolean;
  30167. VIGNETTE: boolean;
  30168. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30169. VIGNETTEBLENDMODEOPAQUE: boolean;
  30170. TONEMAPPING: boolean;
  30171. TONEMAPPING_ACES: boolean;
  30172. CONTRAST: boolean;
  30173. EXPOSURE: boolean;
  30174. COLORCURVES: boolean;
  30175. COLORGRADING: boolean;
  30176. COLORGRADING3D: boolean;
  30177. SAMPLER3DGREENDEPTH: boolean;
  30178. SAMPLER3DBGRMAP: boolean;
  30179. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30180. }
  30181. /**
  30182. * @hidden
  30183. */
  30184. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30185. IMAGEPROCESSING: boolean;
  30186. VIGNETTE: boolean;
  30187. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30188. VIGNETTEBLENDMODEOPAQUE: boolean;
  30189. TONEMAPPING: boolean;
  30190. TONEMAPPING_ACES: boolean;
  30191. CONTRAST: boolean;
  30192. COLORCURVES: boolean;
  30193. COLORGRADING: boolean;
  30194. COLORGRADING3D: boolean;
  30195. SAMPLER3DGREENDEPTH: boolean;
  30196. SAMPLER3DBGRMAP: boolean;
  30197. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30198. EXPOSURE: boolean;
  30199. constructor();
  30200. }
  30201. /**
  30202. * This groups together the common properties used for image processing either in direct forward pass
  30203. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30204. * or not.
  30205. */
  30206. export class ImageProcessingConfiguration {
  30207. /**
  30208. * Default tone mapping applied in BabylonJS.
  30209. */
  30210. static readonly TONEMAPPING_STANDARD: number;
  30211. /**
  30212. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30213. * to other engines rendering to increase portability.
  30214. */
  30215. static readonly TONEMAPPING_ACES: number;
  30216. /**
  30217. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30218. */
  30219. colorCurves: Nullable<ColorCurves>;
  30220. private _colorCurvesEnabled;
  30221. /**
  30222. * Gets wether the color curves effect is enabled.
  30223. */
  30224. /**
  30225. * Sets wether the color curves effect is enabled.
  30226. */
  30227. colorCurvesEnabled: boolean;
  30228. private _colorGradingTexture;
  30229. /**
  30230. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30231. */
  30232. /**
  30233. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30234. */
  30235. colorGradingTexture: Nullable<BaseTexture>;
  30236. private _colorGradingEnabled;
  30237. /**
  30238. * Gets wether the color grading effect is enabled.
  30239. */
  30240. /**
  30241. * Sets wether the color grading effect is enabled.
  30242. */
  30243. colorGradingEnabled: boolean;
  30244. private _colorGradingWithGreenDepth;
  30245. /**
  30246. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30247. */
  30248. /**
  30249. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30250. */
  30251. colorGradingWithGreenDepth: boolean;
  30252. private _colorGradingBGR;
  30253. /**
  30254. * Gets wether the color grading texture contains BGR values.
  30255. */
  30256. /**
  30257. * Sets wether the color grading texture contains BGR values.
  30258. */
  30259. colorGradingBGR: boolean;
  30260. /** @hidden */
  30261. _exposure: number;
  30262. /**
  30263. * Gets the Exposure used in the effect.
  30264. */
  30265. /**
  30266. * Sets the Exposure used in the effect.
  30267. */
  30268. exposure: number;
  30269. private _toneMappingEnabled;
  30270. /**
  30271. * Gets wether the tone mapping effect is enabled.
  30272. */
  30273. /**
  30274. * Sets wether the tone mapping effect is enabled.
  30275. */
  30276. toneMappingEnabled: boolean;
  30277. private _toneMappingType;
  30278. /**
  30279. * Gets the type of tone mapping effect.
  30280. */
  30281. /**
  30282. * Sets the type of tone mapping effect used in BabylonJS.
  30283. */
  30284. toneMappingType: number;
  30285. protected _contrast: number;
  30286. /**
  30287. * Gets the contrast used in the effect.
  30288. */
  30289. /**
  30290. * Sets the contrast used in the effect.
  30291. */
  30292. contrast: number;
  30293. /**
  30294. * Vignette stretch size.
  30295. */
  30296. vignetteStretch: number;
  30297. /**
  30298. * Vignette centre X Offset.
  30299. */
  30300. vignetteCentreX: number;
  30301. /**
  30302. * Vignette centre Y Offset.
  30303. */
  30304. vignetteCentreY: number;
  30305. /**
  30306. * Vignette weight or intensity of the vignette effect.
  30307. */
  30308. vignetteWeight: number;
  30309. /**
  30310. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30311. * if vignetteEnabled is set to true.
  30312. */
  30313. vignetteColor: Color4;
  30314. /**
  30315. * Camera field of view used by the Vignette effect.
  30316. */
  30317. vignetteCameraFov: number;
  30318. private _vignetteBlendMode;
  30319. /**
  30320. * Gets the vignette blend mode allowing different kind of effect.
  30321. */
  30322. /**
  30323. * Sets the vignette blend mode allowing different kind of effect.
  30324. */
  30325. vignetteBlendMode: number;
  30326. private _vignetteEnabled;
  30327. /**
  30328. * Gets wether the vignette effect is enabled.
  30329. */
  30330. /**
  30331. * Sets wether the vignette effect is enabled.
  30332. */
  30333. vignetteEnabled: boolean;
  30334. private _applyByPostProcess;
  30335. /**
  30336. * Gets wether the image processing is applied through a post process or not.
  30337. */
  30338. /**
  30339. * Sets wether the image processing is applied through a post process or not.
  30340. */
  30341. applyByPostProcess: boolean;
  30342. private _isEnabled;
  30343. /**
  30344. * Gets wether the image processing is enabled or not.
  30345. */
  30346. /**
  30347. * Sets wether the image processing is enabled or not.
  30348. */
  30349. isEnabled: boolean;
  30350. /**
  30351. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30352. */
  30353. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30354. /**
  30355. * Method called each time the image processing information changes requires to recompile the effect.
  30356. */
  30357. protected _updateParameters(): void;
  30358. /**
  30359. * Gets the current class name.
  30360. * @return "ImageProcessingConfiguration"
  30361. */
  30362. getClassName(): string;
  30363. /**
  30364. * Prepare the list of uniforms associated with the Image Processing effects.
  30365. * @param uniforms The list of uniforms used in the effect
  30366. * @param defines the list of defines currently in use
  30367. */
  30368. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30369. /**
  30370. * Prepare the list of samplers associated with the Image Processing effects.
  30371. * @param samplersList The list of uniforms used in the effect
  30372. * @param defines the list of defines currently in use
  30373. */
  30374. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30375. /**
  30376. * Prepare the list of defines associated to the shader.
  30377. * @param defines the list of defines to complete
  30378. * @param forPostProcess Define if we are currently in post process mode or not
  30379. */
  30380. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30381. /**
  30382. * Returns true if all the image processing information are ready.
  30383. * @returns True if ready, otherwise, false
  30384. */
  30385. isReady(): boolean;
  30386. /**
  30387. * Binds the image processing to the shader.
  30388. * @param effect The effect to bind to
  30389. * @param aspectRatio Define the current aspect ratio of the effect
  30390. */
  30391. bind(effect: Effect, aspectRatio?: number): void;
  30392. /**
  30393. * Clones the current image processing instance.
  30394. * @return The cloned image processing
  30395. */
  30396. clone(): ImageProcessingConfiguration;
  30397. /**
  30398. * Serializes the current image processing instance to a json representation.
  30399. * @return a JSON representation
  30400. */
  30401. serialize(): any;
  30402. /**
  30403. * Parses the image processing from a json representation.
  30404. * @param source the JSON source to parse
  30405. * @return The parsed image processing
  30406. */
  30407. static Parse(source: any): ImageProcessingConfiguration;
  30408. private static _VIGNETTEMODE_MULTIPLY;
  30409. private static _VIGNETTEMODE_OPAQUE;
  30410. /**
  30411. * Used to apply the vignette as a mix with the pixel color.
  30412. */
  30413. static readonly VIGNETTEMODE_MULTIPLY: number;
  30414. /**
  30415. * Used to apply the vignette as a replacement of the pixel color.
  30416. */
  30417. static readonly VIGNETTEMODE_OPAQUE: number;
  30418. }
  30419. }
  30420. declare module "babylonjs/Materials/fresnelParameters" {
  30421. import { Color3 } from "babylonjs/Maths/math";
  30422. /**
  30423. * This represents all the required information to add a fresnel effect on a material:
  30424. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30425. */
  30426. export class FresnelParameters {
  30427. private _isEnabled;
  30428. /**
  30429. * Define if the fresnel effect is enable or not.
  30430. */
  30431. isEnabled: boolean;
  30432. /**
  30433. * Define the color used on edges (grazing angle)
  30434. */
  30435. leftColor: Color3;
  30436. /**
  30437. * Define the color used on center
  30438. */
  30439. rightColor: Color3;
  30440. /**
  30441. * Define bias applied to computed fresnel term
  30442. */
  30443. bias: number;
  30444. /**
  30445. * Defined the power exponent applied to fresnel term
  30446. */
  30447. power: number;
  30448. /**
  30449. * Clones the current fresnel and its valuues
  30450. * @returns a clone fresnel configuration
  30451. */
  30452. clone(): FresnelParameters;
  30453. /**
  30454. * Serializes the current fresnel parameters to a JSON representation.
  30455. * @return the JSON serialization
  30456. */
  30457. serialize(): any;
  30458. /**
  30459. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30460. * @param parsedFresnelParameters Define the JSON representation
  30461. * @returns the parsed parameters
  30462. */
  30463. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30464. }
  30465. }
  30466. declare module "babylonjs/Misc/decorators" {
  30467. import { Nullable } from "babylonjs/types";
  30468. import { Scene } from "babylonjs/scene";
  30469. import { IAnimatable } from "babylonjs/Misc/tools";
  30470. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30471. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30472. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30473. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30474. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30475. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30476. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30477. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30478. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30479. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30480. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30481. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30482. /**
  30483. * Decorator used to define property that can be serialized as reference to a camera
  30484. * @param sourceName defines the name of the property to decorate
  30485. */
  30486. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30487. /**
  30488. * Class used to help serialization objects
  30489. */
  30490. export class SerializationHelper {
  30491. /** hidden */
  30492. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30493. /** hidden */
  30494. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30495. /** hidden */
  30496. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30497. /** hidden */
  30498. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30499. /**
  30500. * Appends the serialized animations from the source animations
  30501. * @param source Source containing the animations
  30502. * @param destination Target to store the animations
  30503. */
  30504. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30505. /**
  30506. * Static function used to serialized a specific entity
  30507. * @param entity defines the entity to serialize
  30508. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30509. * @returns a JSON compatible object representing the serialization of the entity
  30510. */
  30511. static Serialize<T>(entity: T, serializationObject?: any): any;
  30512. /**
  30513. * Creates a new entity from a serialization data object
  30514. * @param creationFunction defines a function used to instanciated the new entity
  30515. * @param source defines the source serialization data
  30516. * @param scene defines the hosting scene
  30517. * @param rootUrl defines the root url for resources
  30518. * @returns a new entity
  30519. */
  30520. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30521. /**
  30522. * Clones an object
  30523. * @param creationFunction defines the function used to instanciate the new object
  30524. * @param source defines the source object
  30525. * @returns the cloned object
  30526. */
  30527. static Clone<T>(creationFunction: () => T, source: T): T;
  30528. /**
  30529. * Instanciates a new object based on a source one (some data will be shared between both object)
  30530. * @param creationFunction defines the function used to instanciate the new object
  30531. * @param source defines the source object
  30532. * @returns the new object
  30533. */
  30534. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30535. }
  30536. }
  30537. declare module "babylonjs/Cameras/camera" {
  30538. import { SmartArray } from "babylonjs/Misc/smartArray";
  30539. import { Observable } from "babylonjs/Misc/observable";
  30540. import { Nullable } from "babylonjs/types";
  30541. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30542. import { Scene } from "babylonjs/scene";
  30543. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30544. import { Node } from "babylonjs/node";
  30545. import { Mesh } from "babylonjs/Meshes/mesh";
  30546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30547. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30548. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30549. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30550. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30551. import { Ray } from "babylonjs/Culling/ray";
  30552. /**
  30553. * This is the base class of all the camera used in the application.
  30554. * @see http://doc.babylonjs.com/features/cameras
  30555. */
  30556. export class Camera extends Node {
  30557. /** @hidden */
  30558. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30559. /**
  30560. * This is the default projection mode used by the cameras.
  30561. * It helps recreating a feeling of perspective and better appreciate depth.
  30562. * This is the best way to simulate real life cameras.
  30563. */
  30564. static readonly PERSPECTIVE_CAMERA: number;
  30565. /**
  30566. * This helps creating camera with an orthographic mode.
  30567. * 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.
  30568. */
  30569. static readonly ORTHOGRAPHIC_CAMERA: number;
  30570. /**
  30571. * This is the default FOV mode for perspective cameras.
  30572. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30573. */
  30574. static readonly FOVMODE_VERTICAL_FIXED: number;
  30575. /**
  30576. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30577. */
  30578. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30579. /**
  30580. * This specifies ther is no need for a camera rig.
  30581. * Basically only one eye is rendered corresponding to the camera.
  30582. */
  30583. static readonly RIG_MODE_NONE: number;
  30584. /**
  30585. * Simulates a camera Rig with one blue eye and one red eye.
  30586. * This can be use with 3d blue and red glasses.
  30587. */
  30588. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30589. /**
  30590. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30591. */
  30592. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30593. /**
  30594. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30595. */
  30596. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30597. /**
  30598. * Defines that both eyes of the camera will be rendered over under each other.
  30599. */
  30600. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30601. /**
  30602. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30603. */
  30604. static readonly RIG_MODE_VR: number;
  30605. /**
  30606. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30607. */
  30608. static readonly RIG_MODE_WEBVR: number;
  30609. /**
  30610. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30611. */
  30612. static readonly RIG_MODE_CUSTOM: number;
  30613. /**
  30614. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30615. */
  30616. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30617. /**
  30618. * @hidden
  30619. * Might be removed once multiview will be a thing
  30620. */
  30621. static UseAlternateWebVRRendering: boolean;
  30622. /**
  30623. * Define the input manager associated with the camera.
  30624. */
  30625. inputs: CameraInputsManager<Camera>;
  30626. /** @hidden */
  30627. _position: Vector3;
  30628. /**
  30629. * Define the current local position of the camera in the scene
  30630. */
  30631. position: Vector3;
  30632. /**
  30633. * The vector the camera should consider as up.
  30634. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30635. */
  30636. upVector: Vector3;
  30637. /**
  30638. * Define the current limit on the left side for an orthographic camera
  30639. * In scene unit
  30640. */
  30641. orthoLeft: Nullable<number>;
  30642. /**
  30643. * Define the current limit on the right side for an orthographic camera
  30644. * In scene unit
  30645. */
  30646. orthoRight: Nullable<number>;
  30647. /**
  30648. * Define the current limit on the bottom side for an orthographic camera
  30649. * In scene unit
  30650. */
  30651. orthoBottom: Nullable<number>;
  30652. /**
  30653. * Define the current limit on the top side for an orthographic camera
  30654. * In scene unit
  30655. */
  30656. orthoTop: Nullable<number>;
  30657. /**
  30658. * Field Of View is set in Radians. (default is 0.8)
  30659. */
  30660. fov: number;
  30661. /**
  30662. * Define the minimum distance the camera can see from.
  30663. * This is important to note that the depth buffer are not infinite and the closer it starts
  30664. * the more your scene might encounter depth fighting issue.
  30665. */
  30666. minZ: number;
  30667. /**
  30668. * Define the maximum distance the camera can see to.
  30669. * This is important to note that the depth buffer are not infinite and the further it end
  30670. * the more your scene might encounter depth fighting issue.
  30671. */
  30672. maxZ: number;
  30673. /**
  30674. * Define the default inertia of the camera.
  30675. * This helps giving a smooth feeling to the camera movement.
  30676. */
  30677. inertia: number;
  30678. /**
  30679. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30680. */
  30681. mode: number;
  30682. /**
  30683. * Define wether the camera is intermediate.
  30684. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30685. */
  30686. isIntermediate: boolean;
  30687. /**
  30688. * Define the viewport of the camera.
  30689. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30690. */
  30691. viewport: Viewport;
  30692. /**
  30693. * Restricts the camera to viewing objects with the same layerMask.
  30694. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30695. */
  30696. layerMask: number;
  30697. /**
  30698. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30699. */
  30700. fovMode: number;
  30701. /**
  30702. * Rig mode of the camera.
  30703. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30704. * This is normally controlled byt the camera themselves as internal use.
  30705. */
  30706. cameraRigMode: number;
  30707. /**
  30708. * Defines the distance between both "eyes" in case of a RIG
  30709. */
  30710. interaxialDistance: number;
  30711. /**
  30712. * Defines if stereoscopic rendering is done side by side or over under.
  30713. */
  30714. isStereoscopicSideBySide: boolean;
  30715. /**
  30716. * 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
  30717. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30718. * else in the scene.
  30719. */
  30720. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30721. /**
  30722. * When set, the camera will render to this render target instead of the default canvas
  30723. */
  30724. outputRenderTarget: Nullable<RenderTargetTexture>;
  30725. /**
  30726. * Observable triggered when the camera view matrix has changed.
  30727. */
  30728. onViewMatrixChangedObservable: Observable<Camera>;
  30729. /**
  30730. * Observable triggered when the camera Projection matrix has changed.
  30731. */
  30732. onProjectionMatrixChangedObservable: Observable<Camera>;
  30733. /**
  30734. * Observable triggered when the inputs have been processed.
  30735. */
  30736. onAfterCheckInputsObservable: Observable<Camera>;
  30737. /**
  30738. * Observable triggered when reset has been called and applied to the camera.
  30739. */
  30740. onRestoreStateObservable: Observable<Camera>;
  30741. /** @hidden */
  30742. _cameraRigParams: any;
  30743. /** @hidden */
  30744. _rigCameras: Camera[];
  30745. /** @hidden */
  30746. _rigPostProcess: Nullable<PostProcess>;
  30747. protected _webvrViewMatrix: Matrix;
  30748. /** @hidden */
  30749. _skipRendering: boolean;
  30750. /** @hidden */
  30751. _alternateCamera: Camera;
  30752. /** @hidden */
  30753. _projectionMatrix: Matrix;
  30754. /** @hidden */
  30755. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30756. /** @hidden */
  30757. _activeMeshes: SmartArray<AbstractMesh>;
  30758. protected _globalPosition: Vector3;
  30759. /** hidden */
  30760. _computedViewMatrix: Matrix;
  30761. private _doNotComputeProjectionMatrix;
  30762. private _transformMatrix;
  30763. private _frustumPlanes;
  30764. private _refreshFrustumPlanes;
  30765. private _storedFov;
  30766. private _stateStored;
  30767. /**
  30768. * Instantiates a new camera object.
  30769. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30770. * @see http://doc.babylonjs.com/features/cameras
  30771. * @param name Defines the name of the camera in the scene
  30772. * @param position Defines the position of the camera
  30773. * @param scene Defines the scene the camera belongs too
  30774. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30775. */
  30776. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30777. /**
  30778. * Store current camera state (fov, position, etc..)
  30779. * @returns the camera
  30780. */
  30781. storeState(): Camera;
  30782. /**
  30783. * Restores the camera state values if it has been stored. You must call storeState() first
  30784. */
  30785. protected _restoreStateValues(): boolean;
  30786. /**
  30787. * Restored camera state. You must call storeState() first.
  30788. * @returns true if restored and false otherwise
  30789. */
  30790. restoreState(): boolean;
  30791. /**
  30792. * Gets the class name of the camera.
  30793. * @returns the class name
  30794. */
  30795. getClassName(): string;
  30796. /** @hidden */
  30797. readonly _isCamera: boolean;
  30798. /**
  30799. * Gets a string representation of the camera useful for debug purpose.
  30800. * @param fullDetails Defines that a more verboe level of logging is required
  30801. * @returns the string representation
  30802. */
  30803. toString(fullDetails?: boolean): string;
  30804. /**
  30805. * Gets the current world space position of the camera.
  30806. */
  30807. readonly globalPosition: Vector3;
  30808. /**
  30809. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30810. * @returns the active meshe list
  30811. */
  30812. getActiveMeshes(): SmartArray<AbstractMesh>;
  30813. /**
  30814. * Check wether a mesh is part of the current active mesh list of the camera
  30815. * @param mesh Defines the mesh to check
  30816. * @returns true if active, false otherwise
  30817. */
  30818. isActiveMesh(mesh: Mesh): boolean;
  30819. /**
  30820. * Is this camera ready to be used/rendered
  30821. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30822. * @return true if the camera is ready
  30823. */
  30824. isReady(completeCheck?: boolean): boolean;
  30825. /** @hidden */
  30826. _initCache(): void;
  30827. /** @hidden */
  30828. _updateCache(ignoreParentClass?: boolean): void;
  30829. /** @hidden */
  30830. _isSynchronized(): boolean;
  30831. /** @hidden */
  30832. _isSynchronizedViewMatrix(): boolean;
  30833. /** @hidden */
  30834. _isSynchronizedProjectionMatrix(): boolean;
  30835. /**
  30836. * Attach the input controls to a specific dom element to get the input from.
  30837. * @param element Defines the element the controls should be listened from
  30838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30839. */
  30840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30841. /**
  30842. * Detach the current controls from the specified dom element.
  30843. * @param element Defines the element to stop listening the inputs from
  30844. */
  30845. detachControl(element: HTMLElement): void;
  30846. /**
  30847. * Update the camera state according to the different inputs gathered during the frame.
  30848. */
  30849. update(): void;
  30850. /** @hidden */
  30851. _checkInputs(): void;
  30852. /** @hidden */
  30853. readonly rigCameras: Camera[];
  30854. /**
  30855. * Gets the post process used by the rig cameras
  30856. */
  30857. readonly rigPostProcess: Nullable<PostProcess>;
  30858. /**
  30859. * Internal, gets the first post proces.
  30860. * @returns the first post process to be run on this camera.
  30861. */
  30862. _getFirstPostProcess(): Nullable<PostProcess>;
  30863. private _cascadePostProcessesToRigCams;
  30864. /**
  30865. * Attach a post process to the camera.
  30866. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30867. * @param postProcess The post process to attach to the camera
  30868. * @param insertAt The position of the post process in case several of them are in use in the scene
  30869. * @returns the position the post process has been inserted at
  30870. */
  30871. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30872. /**
  30873. * Detach a post process to the camera.
  30874. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30875. * @param postProcess The post process to detach from the camera
  30876. */
  30877. detachPostProcess(postProcess: PostProcess): void;
  30878. /**
  30879. * Gets the current world matrix of the camera
  30880. */
  30881. getWorldMatrix(): Matrix;
  30882. /** @hidden */
  30883. _getViewMatrix(): Matrix;
  30884. /**
  30885. * Gets the current view matrix of the camera.
  30886. * @param force forces the camera to recompute the matrix without looking at the cached state
  30887. * @returns the view matrix
  30888. */
  30889. getViewMatrix(force?: boolean): Matrix;
  30890. /**
  30891. * Freeze the projection matrix.
  30892. * It will prevent the cache check of the camera projection compute and can speed up perf
  30893. * if no parameter of the camera are meant to change
  30894. * @param projection Defines manually a projection if necessary
  30895. */
  30896. freezeProjectionMatrix(projection?: Matrix): void;
  30897. /**
  30898. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30899. */
  30900. unfreezeProjectionMatrix(): void;
  30901. /**
  30902. * Gets the current projection matrix of the camera.
  30903. * @param force forces the camera to recompute the matrix without looking at the cached state
  30904. * @returns the projection matrix
  30905. */
  30906. getProjectionMatrix(force?: boolean): Matrix;
  30907. /**
  30908. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30909. * @returns a Matrix
  30910. */
  30911. getTransformationMatrix(): Matrix;
  30912. private _updateFrustumPlanes;
  30913. /**
  30914. * Checks if a cullable object (mesh...) is in the camera frustum
  30915. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30916. * @param target The object to check
  30917. * @returns true if the object is in frustum otherwise false
  30918. */
  30919. isInFrustum(target: ICullable): boolean;
  30920. /**
  30921. * Checks if a cullable object (mesh...) is in the camera frustum
  30922. * Unlike isInFrustum this cheks the full bounding box
  30923. * @param target The object to check
  30924. * @returns true if the object is in frustum otherwise false
  30925. */
  30926. isCompletelyInFrustum(target: ICullable): boolean;
  30927. /**
  30928. * Gets a ray in the forward direction from the camera.
  30929. * @param length Defines the length of the ray to create
  30930. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30931. * @param origin Defines the start point of the ray which defaults to the camera position
  30932. * @returns the forward ray
  30933. */
  30934. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30935. /**
  30936. * Releases resources associated with this node.
  30937. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30938. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30939. */
  30940. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30941. /** @hidden */
  30942. _isLeftCamera: boolean;
  30943. /**
  30944. * Gets the left camera of a rig setup in case of Rigged Camera
  30945. */
  30946. readonly isLeftCamera: boolean;
  30947. /** @hidden */
  30948. _isRightCamera: boolean;
  30949. /**
  30950. * Gets the right camera of a rig setup in case of Rigged Camera
  30951. */
  30952. readonly isRightCamera: boolean;
  30953. /**
  30954. * Gets the left camera of a rig setup in case of Rigged Camera
  30955. */
  30956. readonly leftCamera: Nullable<FreeCamera>;
  30957. /**
  30958. * Gets the right camera of a rig setup in case of Rigged Camera
  30959. */
  30960. readonly rightCamera: Nullable<FreeCamera>;
  30961. /**
  30962. * Gets the left camera target of a rig setup in case of Rigged Camera
  30963. * @returns the target position
  30964. */
  30965. getLeftTarget(): Nullable<Vector3>;
  30966. /**
  30967. * Gets the right camera target of a rig setup in case of Rigged Camera
  30968. * @returns the target position
  30969. */
  30970. getRightTarget(): Nullable<Vector3>;
  30971. /**
  30972. * @hidden
  30973. */
  30974. setCameraRigMode(mode: number, rigParams: any): void;
  30975. /** @hidden */
  30976. static _setStereoscopicRigMode(camera: Camera): void;
  30977. /** @hidden */
  30978. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30979. /** @hidden */
  30980. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30981. /** @hidden */
  30982. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30983. /** @hidden */
  30984. _getVRProjectionMatrix(): Matrix;
  30985. protected _updateCameraRotationMatrix(): void;
  30986. protected _updateWebVRCameraRotationMatrix(): void;
  30987. /**
  30988. * This function MUST be overwritten by the different WebVR cameras available.
  30989. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30990. * @hidden
  30991. */
  30992. _getWebVRProjectionMatrix(): Matrix;
  30993. /**
  30994. * This function MUST be overwritten by the different WebVR cameras available.
  30995. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30996. * @hidden
  30997. */
  30998. _getWebVRViewMatrix(): Matrix;
  30999. /** @hidden */
  31000. setCameraRigParameter(name: string, value: any): void;
  31001. /**
  31002. * needs to be overridden by children so sub has required properties to be copied
  31003. * @hidden
  31004. */
  31005. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31006. /**
  31007. * May need to be overridden by children
  31008. * @hidden
  31009. */
  31010. _updateRigCameras(): void;
  31011. /** @hidden */
  31012. _setupInputs(): void;
  31013. /**
  31014. * Serialiaze the camera setup to a json represention
  31015. * @returns the JSON representation
  31016. */
  31017. serialize(): any;
  31018. /**
  31019. * Clones the current camera.
  31020. * @param name The cloned camera name
  31021. * @returns the cloned camera
  31022. */
  31023. clone(name: string): Camera;
  31024. /**
  31025. * Gets the direction of the camera relative to a given local axis.
  31026. * @param localAxis Defines the reference axis to provide a relative direction.
  31027. * @return the direction
  31028. */
  31029. getDirection(localAxis: Vector3): Vector3;
  31030. /**
  31031. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31032. * @param localAxis Defines the reference axis to provide a relative direction.
  31033. * @param result Defines the vector to store the result in
  31034. */
  31035. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31036. /**
  31037. * Gets a camera constructor for a given camera type
  31038. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31039. * @param name The name of the camera the result will be able to instantiate
  31040. * @param scene The scene the result will construct the camera in
  31041. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31042. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31043. * @returns a factory method to construc the camera
  31044. */
  31045. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31046. /**
  31047. * Compute the world matrix of the camera.
  31048. * @returns the camera workd matrix
  31049. */
  31050. computeWorldMatrix(): Matrix;
  31051. /**
  31052. * Parse a JSON and creates the camera from the parsed information
  31053. * @param parsedCamera The JSON to parse
  31054. * @param scene The scene to instantiate the camera in
  31055. * @returns the newly constructed camera
  31056. */
  31057. static Parse(parsedCamera: any, scene: Scene): Camera;
  31058. }
  31059. }
  31060. declare module "babylonjs/Misc/tools" {
  31061. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31062. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31063. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31064. import { Observable } from "babylonjs/Misc/observable";
  31065. import { DomManagement } from "babylonjs/Misc/domManagement";
  31066. import { WebRequest } from "babylonjs/Misc/webRequest";
  31067. import { Camera } from "babylonjs/Cameras/camera";
  31068. import { Engine } from "babylonjs/Engines/engine";
  31069. import { Animation } from "babylonjs/Animations/animation";
  31070. /**
  31071. * Interface for any object that can request an animation frame
  31072. */
  31073. export interface ICustomAnimationFrameRequester {
  31074. /**
  31075. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31076. */
  31077. renderFunction?: Function;
  31078. /**
  31079. * Called to request the next frame to render to
  31080. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31081. */
  31082. requestAnimationFrame: Function;
  31083. /**
  31084. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31085. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31086. */
  31087. requestID?: number;
  31088. }
  31089. /**
  31090. * Interface containing an array of animations
  31091. */
  31092. export interface IAnimatable {
  31093. /**
  31094. * Array of animations
  31095. */
  31096. animations: Array<Animation>;
  31097. }
  31098. /** Interface used by value gradients (color, factor, ...) */
  31099. export interface IValueGradient {
  31100. /**
  31101. * Gets or sets the gradient value (between 0 and 1)
  31102. */
  31103. gradient: number;
  31104. }
  31105. /** Class used to store color4 gradient */
  31106. export class ColorGradient implements IValueGradient {
  31107. /**
  31108. * Gets or sets the gradient value (between 0 and 1)
  31109. */
  31110. gradient: number;
  31111. /**
  31112. * Gets or sets first associated color
  31113. */
  31114. color1: Color4;
  31115. /**
  31116. * Gets or sets second associated color
  31117. */
  31118. color2?: Color4;
  31119. /**
  31120. * Will get a color picked randomly between color1 and color2.
  31121. * If color2 is undefined then color1 will be used
  31122. * @param result defines the target Color4 to store the result in
  31123. */
  31124. getColorToRef(result: Color4): void;
  31125. }
  31126. /** Class used to store color 3 gradient */
  31127. export class Color3Gradient implements IValueGradient {
  31128. /**
  31129. * Gets or sets the gradient value (between 0 and 1)
  31130. */
  31131. gradient: number;
  31132. /**
  31133. * Gets or sets the associated color
  31134. */
  31135. color: Color3;
  31136. }
  31137. /** Class used to store factor gradient */
  31138. export class FactorGradient implements IValueGradient {
  31139. /**
  31140. * Gets or sets the gradient value (between 0 and 1)
  31141. */
  31142. gradient: number;
  31143. /**
  31144. * Gets or sets first associated factor
  31145. */
  31146. factor1: number;
  31147. /**
  31148. * Gets or sets second associated factor
  31149. */
  31150. factor2?: number;
  31151. /**
  31152. * Will get a number picked randomly between factor1 and factor2.
  31153. * If factor2 is undefined then factor1 will be used
  31154. * @returns the picked number
  31155. */
  31156. getFactor(): number;
  31157. }
  31158. /**
  31159. * @ignore
  31160. * Application error to support additional information when loading a file
  31161. */
  31162. export class LoadFileError extends Error {
  31163. /** defines the optional web request */
  31164. request?: WebRequest | undefined;
  31165. private static _setPrototypeOf;
  31166. /**
  31167. * Creates a new LoadFileError
  31168. * @param message defines the message of the error
  31169. * @param request defines the optional web request
  31170. */
  31171. constructor(message: string,
  31172. /** defines the optional web request */
  31173. request?: WebRequest | undefined);
  31174. }
  31175. /**
  31176. * Class used to define a retry strategy when error happens while loading assets
  31177. */
  31178. export class RetryStrategy {
  31179. /**
  31180. * Function used to defines an exponential back off strategy
  31181. * @param maxRetries defines the maximum number of retries (3 by default)
  31182. * @param baseInterval defines the interval between retries
  31183. * @returns the strategy function to use
  31184. */
  31185. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31186. }
  31187. /**
  31188. * File request interface
  31189. */
  31190. export interface IFileRequest {
  31191. /**
  31192. * Raised when the request is complete (success or error).
  31193. */
  31194. onCompleteObservable: Observable<IFileRequest>;
  31195. /**
  31196. * Aborts the request for a file.
  31197. */
  31198. abort: () => void;
  31199. }
  31200. /**
  31201. * Class containing a set of static utilities functions
  31202. */
  31203. export class Tools {
  31204. /**
  31205. * Gets or sets the base URL to use to load assets
  31206. */
  31207. static BaseUrl: string;
  31208. /**
  31209. * Enable/Disable Custom HTTP Request Headers globally.
  31210. * default = false
  31211. * @see CustomRequestHeaders
  31212. */
  31213. static UseCustomRequestHeaders: boolean;
  31214. /**
  31215. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31216. * i.e. when loading files, where the server/service expects an Authorization header
  31217. */
  31218. static CustomRequestHeaders: {
  31219. [key: string]: string;
  31220. };
  31221. /**
  31222. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31223. */
  31224. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31225. /**
  31226. * Default behaviour for cors in the application.
  31227. * It can be a string if the expected behavior is identical in the entire app.
  31228. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31229. */
  31230. static CorsBehavior: string | ((url: string | string[]) => string);
  31231. /**
  31232. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31233. * @ignorenaming
  31234. */
  31235. static UseFallbackTexture: boolean;
  31236. /**
  31237. * Use this object to register external classes like custom textures or material
  31238. * to allow the laoders to instantiate them
  31239. */
  31240. static RegisteredExternalClasses: {
  31241. [key: string]: Object;
  31242. };
  31243. /**
  31244. * Texture content used if a texture cannot loaded
  31245. * @ignorenaming
  31246. */
  31247. static fallbackTexture: string;
  31248. /**
  31249. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31250. * @param u defines the coordinate on X axis
  31251. * @param v defines the coordinate on Y axis
  31252. * @param width defines the width of the source data
  31253. * @param height defines the height of the source data
  31254. * @param pixels defines the source byte array
  31255. * @param color defines the output color
  31256. */
  31257. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31258. /**
  31259. * Interpolates between a and b via alpha
  31260. * @param a The lower value (returned when alpha = 0)
  31261. * @param b The upper value (returned when alpha = 1)
  31262. * @param alpha The interpolation-factor
  31263. * @return The mixed value
  31264. */
  31265. static Mix(a: number, b: number, alpha: number): number;
  31266. /**
  31267. * Tries to instantiate a new object from a given class name
  31268. * @param className defines the class name to instantiate
  31269. * @returns the new object or null if the system was not able to do the instantiation
  31270. */
  31271. static Instantiate(className: string): any;
  31272. /**
  31273. * Provides a slice function that will work even on IE
  31274. * @param data defines the array to slice
  31275. * @param start defines the start of the data (optional)
  31276. * @param end defines the end of the data (optional)
  31277. * @returns the new sliced array
  31278. */
  31279. static Slice<T>(data: T, start?: number, end?: number): T;
  31280. /**
  31281. * Polyfill for setImmediate
  31282. * @param action defines the action to execute after the current execution block
  31283. */
  31284. static SetImmediate(action: () => void): void;
  31285. /**
  31286. * Function indicating if a number is an exponent of 2
  31287. * @param value defines the value to test
  31288. * @returns true if the value is an exponent of 2
  31289. */
  31290. static IsExponentOfTwo(value: number): boolean;
  31291. private static _tmpFloatArray;
  31292. /**
  31293. * Returns the nearest 32-bit single precision float representation of a Number
  31294. * @param value A Number. If the parameter is of a different type, it will get converted
  31295. * to a number or to NaN if it cannot be converted
  31296. * @returns number
  31297. */
  31298. static FloatRound(value: number): number;
  31299. /**
  31300. * Find the next highest power of two.
  31301. * @param x Number to start search from.
  31302. * @return Next highest power of two.
  31303. */
  31304. static CeilingPOT(x: number): number;
  31305. /**
  31306. * Find the next lowest power of two.
  31307. * @param x Number to start search from.
  31308. * @return Next lowest power of two.
  31309. */
  31310. static FloorPOT(x: number): number;
  31311. /**
  31312. * Find the nearest power of two.
  31313. * @param x Number to start search from.
  31314. * @return Next nearest power of two.
  31315. */
  31316. static NearestPOT(x: number): number;
  31317. /**
  31318. * Get the closest exponent of two
  31319. * @param value defines the value to approximate
  31320. * @param max defines the maximum value to return
  31321. * @param mode defines how to define the closest value
  31322. * @returns closest exponent of two of the given value
  31323. */
  31324. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31325. /**
  31326. * Extracts the filename from a path
  31327. * @param path defines the path to use
  31328. * @returns the filename
  31329. */
  31330. static GetFilename(path: string): string;
  31331. /**
  31332. * Extracts the "folder" part of a path (everything before the filename).
  31333. * @param uri The URI to extract the info from
  31334. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31335. * @returns The "folder" part of the path
  31336. */
  31337. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31338. /**
  31339. * Extracts text content from a DOM element hierarchy
  31340. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31341. */
  31342. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31343. /**
  31344. * Convert an angle in radians to degrees
  31345. * @param angle defines the angle to convert
  31346. * @returns the angle in degrees
  31347. */
  31348. static ToDegrees(angle: number): number;
  31349. /**
  31350. * Convert an angle in degrees to radians
  31351. * @param angle defines the angle to convert
  31352. * @returns the angle in radians
  31353. */
  31354. static ToRadians(angle: number): number;
  31355. /**
  31356. * Encode a buffer to a base64 string
  31357. * @param buffer defines the buffer to encode
  31358. * @returns the encoded string
  31359. */
  31360. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31361. /**
  31362. * Extracts minimum and maximum values from a list of indexed positions
  31363. * @param positions defines the positions to use
  31364. * @param indices defines the indices to the positions
  31365. * @param indexStart defines the start index
  31366. * @param indexCount defines the end index
  31367. * @param bias defines bias value to add to the result
  31368. * @return minimum and maximum values
  31369. */
  31370. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31371. minimum: Vector3;
  31372. maximum: Vector3;
  31373. };
  31374. /**
  31375. * Extracts minimum and maximum values from a list of positions
  31376. * @param positions defines the positions to use
  31377. * @param start defines the start index in the positions array
  31378. * @param count defines the number of positions to handle
  31379. * @param bias defines bias value to add to the result
  31380. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31381. * @return minimum and maximum values
  31382. */
  31383. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31384. minimum: Vector3;
  31385. maximum: Vector3;
  31386. };
  31387. /**
  31388. * Returns an array if obj is not an array
  31389. * @param obj defines the object to evaluate as an array
  31390. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31391. * @returns either obj directly if obj is an array or a new array containing obj
  31392. */
  31393. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31394. /**
  31395. * Gets the pointer prefix to use
  31396. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31397. */
  31398. static GetPointerPrefix(): string;
  31399. /**
  31400. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31401. * @param func - the function to be called
  31402. * @param requester - the object that will request the next frame. Falls back to window.
  31403. * @returns frame number
  31404. */
  31405. static QueueNewFrame(func: () => void, requester?: any): number;
  31406. /**
  31407. * Ask the browser to promote the current element to fullscreen rendering mode
  31408. * @param element defines the DOM element to promote
  31409. */
  31410. static RequestFullscreen(element: HTMLElement): void;
  31411. /**
  31412. * Asks the browser to exit fullscreen mode
  31413. */
  31414. static ExitFullscreen(): void;
  31415. /**
  31416. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31417. * @param url define the url we are trying
  31418. * @param element define the dom element where to configure the cors policy
  31419. */
  31420. static SetCorsBehavior(url: string | string[], element: {
  31421. crossOrigin: string | null;
  31422. }): void;
  31423. /**
  31424. * Removes unwanted characters from an url
  31425. * @param url defines the url to clean
  31426. * @returns the cleaned url
  31427. */
  31428. static CleanUrl(url: string): string;
  31429. /**
  31430. * Gets or sets a function used to pre-process url before using them to load assets
  31431. */
  31432. static PreprocessUrl: (url: string) => string;
  31433. /**
  31434. * Loads an image as an HTMLImageElement.
  31435. * @param input url string, ArrayBuffer, or Blob to load
  31436. * @param onLoad callback called when the image successfully loads
  31437. * @param onError callback called when the image fails to load
  31438. * @param offlineProvider offline provider for caching
  31439. * @returns the HTMLImageElement of the loaded image
  31440. */
  31441. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31442. /**
  31443. * Loads a file
  31444. * @param url url string, ArrayBuffer, or Blob to load
  31445. * @param onSuccess callback called when the file successfully loads
  31446. * @param onProgress callback called while file is loading (if the server supports this mode)
  31447. * @param offlineProvider defines the offline provider for caching
  31448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31449. * @param onError callback called when the file fails to load
  31450. * @returns a file request object
  31451. */
  31452. 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;
  31453. /**
  31454. * Load a script (identified by an url). When the url returns, the
  31455. * content of this file is added into a new script element, attached to the DOM (body element)
  31456. * @param scriptUrl defines the url of the script to laod
  31457. * @param onSuccess defines the callback called when the script is loaded
  31458. * @param onError defines the callback to call if an error occurs
  31459. */
  31460. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31461. /**
  31462. * Loads a file from a blob
  31463. * @param fileToLoad defines the blob to use
  31464. * @param callback defines the callback to call when data is loaded
  31465. * @param progressCallback defines the callback to call during loading process
  31466. * @returns a file request object
  31467. */
  31468. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31469. /**
  31470. * Loads a file
  31471. * @param fileToLoad defines the file to load
  31472. * @param callback defines the callback to call when data is loaded
  31473. * @param progressCallBack defines the callback to call during loading process
  31474. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31475. * @returns a file request object
  31476. */
  31477. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31478. /**
  31479. * Creates a data url from a given string content
  31480. * @param content defines the content to convert
  31481. * @returns the new data url link
  31482. */
  31483. static FileAsURL(content: string): string;
  31484. /**
  31485. * Format the given number to a specific decimal format
  31486. * @param value defines the number to format
  31487. * @param decimals defines the number of decimals to use
  31488. * @returns the formatted string
  31489. */
  31490. static Format(value: number, decimals?: number): string;
  31491. /**
  31492. * Checks if a given vector is inside a specific range
  31493. * @param v defines the vector to test
  31494. * @param min defines the minimum range
  31495. * @param max defines the maximum range
  31496. */
  31497. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31498. /**
  31499. * Tries to copy an object by duplicating every property
  31500. * @param source defines the source object
  31501. * @param destination defines the target object
  31502. * @param doNotCopyList defines a list of properties to avoid
  31503. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31504. */
  31505. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31506. /**
  31507. * Gets a boolean indicating if the given object has no own property
  31508. * @param obj defines the object to test
  31509. * @returns true if object has no own property
  31510. */
  31511. static IsEmpty(obj: any): boolean;
  31512. /**
  31513. * Function used to register events at window level
  31514. * @param events defines the events to register
  31515. */
  31516. static RegisterTopRootEvents(events: {
  31517. name: string;
  31518. handler: Nullable<(e: FocusEvent) => any>;
  31519. }[]): void;
  31520. /**
  31521. * Function used to unregister events from window level
  31522. * @param events defines the events to unregister
  31523. */
  31524. static UnregisterTopRootEvents(events: {
  31525. name: string;
  31526. handler: Nullable<(e: FocusEvent) => any>;
  31527. }[]): void;
  31528. /**
  31529. * @ignore
  31530. */
  31531. static _ScreenshotCanvas: HTMLCanvasElement;
  31532. /**
  31533. * Dumps the current bound framebuffer
  31534. * @param width defines the rendering width
  31535. * @param height defines the rendering height
  31536. * @param engine defines the hosting engine
  31537. * @param successCallback defines the callback triggered once the data are available
  31538. * @param mimeType defines the mime type of the result
  31539. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31540. */
  31541. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31542. /**
  31543. * Converts the canvas data to blob.
  31544. * This acts as a polyfill for browsers not supporting the to blob function.
  31545. * @param canvas Defines the canvas to extract the data from
  31546. * @param successCallback Defines the callback triggered once the data are available
  31547. * @param mimeType Defines the mime type of the result
  31548. */
  31549. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31550. /**
  31551. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31552. * @param successCallback defines the callback triggered once the data are available
  31553. * @param mimeType defines the mime type of the result
  31554. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31555. */
  31556. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31557. /**
  31558. * Downloads a blob in the browser
  31559. * @param blob defines the blob to download
  31560. * @param fileName defines the name of the downloaded file
  31561. */
  31562. static Download(blob: Blob, fileName: string): void;
  31563. /**
  31564. * Captures a screenshot of the current rendering
  31565. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31566. * @param engine defines the rendering engine
  31567. * @param camera defines the source camera
  31568. * @param size This parameter can be set to a single number or to an object with the
  31569. * following (optional) properties: precision, width, height. If a single number is passed,
  31570. * it will be used for both width and height. If an object is passed, the screenshot size
  31571. * will be derived from the parameters. The precision property is a multiplier allowing
  31572. * rendering at a higher or lower resolution
  31573. * @param successCallback defines the callback receives a single parameter which contains the
  31574. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31575. * src parameter of an <img> to display it
  31576. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31577. * Check your browser for supported MIME types
  31578. */
  31579. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31580. /**
  31581. * Generates an image screenshot from the specified camera.
  31582. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31583. * @param engine The engine to use for rendering
  31584. * @param camera The camera to use for rendering
  31585. * @param size This parameter can be set to a single number or to an object with the
  31586. * following (optional) properties: precision, width, height. If a single number is passed,
  31587. * it will be used for both width and height. If an object is passed, the screenshot size
  31588. * will be derived from the parameters. The precision property is a multiplier allowing
  31589. * rendering at a higher or lower resolution
  31590. * @param successCallback The callback receives a single parameter which contains the
  31591. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31592. * src parameter of an <img> to display it
  31593. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31594. * Check your browser for supported MIME types
  31595. * @param samples Texture samples (default: 1)
  31596. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31597. * @param fileName A name for for the downloaded file.
  31598. */
  31599. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31600. /**
  31601. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31602. * Be aware Math.random() could cause collisions, but:
  31603. * "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"
  31604. * @returns a pseudo random id
  31605. */
  31606. static RandomId(): string;
  31607. /**
  31608. * Test if the given uri is a base64 string
  31609. * @param uri The uri to test
  31610. * @return True if the uri is a base64 string or false otherwise
  31611. */
  31612. static IsBase64(uri: string): boolean;
  31613. /**
  31614. * Decode the given base64 uri.
  31615. * @param uri The uri to decode
  31616. * @return The decoded base64 data.
  31617. */
  31618. static DecodeBase64(uri: string): ArrayBuffer;
  31619. /**
  31620. * No log
  31621. */
  31622. static readonly NoneLogLevel: number;
  31623. /**
  31624. * Only message logs
  31625. */
  31626. static readonly MessageLogLevel: number;
  31627. /**
  31628. * Only warning logs
  31629. */
  31630. static readonly WarningLogLevel: number;
  31631. /**
  31632. * Only error logs
  31633. */
  31634. static readonly ErrorLogLevel: number;
  31635. /**
  31636. * All logs
  31637. */
  31638. static readonly AllLogLevel: number;
  31639. /**
  31640. * Gets a value indicating the number of loading errors
  31641. * @ignorenaming
  31642. */
  31643. static readonly errorsCount: number;
  31644. /**
  31645. * Callback called when a new log is added
  31646. */
  31647. static OnNewCacheEntry: (entry: string) => void;
  31648. /**
  31649. * Log a message to the console
  31650. * @param message defines the message to log
  31651. */
  31652. static Log(message: string): void;
  31653. /**
  31654. * Write a warning message to the console
  31655. * @param message defines the message to log
  31656. */
  31657. static Warn(message: string): void;
  31658. /**
  31659. * Write an error message to the console
  31660. * @param message defines the message to log
  31661. */
  31662. static Error(message: string): void;
  31663. /**
  31664. * Gets current log cache (list of logs)
  31665. */
  31666. static readonly LogCache: string;
  31667. /**
  31668. * Clears the log cache
  31669. */
  31670. static ClearLogCache(): void;
  31671. /**
  31672. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31673. */
  31674. static LogLevels: number;
  31675. /**
  31676. * Checks if the loaded document was accessed via `file:`-Protocol.
  31677. * @returns boolean
  31678. */
  31679. static IsFileURL(): boolean;
  31680. /**
  31681. * Checks if the window object exists
  31682. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31683. */
  31684. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31685. /**
  31686. * No performance log
  31687. */
  31688. static readonly PerformanceNoneLogLevel: number;
  31689. /**
  31690. * Use user marks to log performance
  31691. */
  31692. static readonly PerformanceUserMarkLogLevel: number;
  31693. /**
  31694. * Log performance to the console
  31695. */
  31696. static readonly PerformanceConsoleLogLevel: number;
  31697. private static _performance;
  31698. /**
  31699. * Sets the current performance log level
  31700. */
  31701. static PerformanceLogLevel: number;
  31702. private static _StartPerformanceCounterDisabled;
  31703. private static _EndPerformanceCounterDisabled;
  31704. private static _StartUserMark;
  31705. private static _EndUserMark;
  31706. private static _StartPerformanceConsole;
  31707. private static _EndPerformanceConsole;
  31708. /**
  31709. * Starts a performance counter
  31710. */
  31711. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31712. /**
  31713. * Ends a specific performance coutner
  31714. */
  31715. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31716. /**
  31717. * Gets either window.performance.now() if supported or Date.now() else
  31718. */
  31719. static readonly Now: number;
  31720. /**
  31721. * This method will return the name of the class used to create the instance of the given object.
  31722. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31723. * @param object the object to get the class name from
  31724. * @param isType defines if the object is actually a type
  31725. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31726. */
  31727. static GetClassName(object: any, isType?: boolean): string;
  31728. /**
  31729. * Gets the first element of an array satisfying a given predicate
  31730. * @param array defines the array to browse
  31731. * @param predicate defines the predicate to use
  31732. * @returns null if not found or the element
  31733. */
  31734. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31735. /**
  31736. * This method will return the name of the full name of the class, including its owning module (if any).
  31737. * 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).
  31738. * @param object the object to get the class name from
  31739. * @param isType defines if the object is actually a type
  31740. * @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.
  31741. * @ignorenaming
  31742. */
  31743. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31744. /**
  31745. * Returns a promise that resolves after the given amount of time.
  31746. * @param delay Number of milliseconds to delay
  31747. * @returns Promise that resolves after the given amount of time
  31748. */
  31749. static DelayAsync(delay: number): Promise<void>;
  31750. /**
  31751. * Gets the current gradient from an array of IValueGradient
  31752. * @param ratio defines the current ratio to get
  31753. * @param gradients defines the array of IValueGradient
  31754. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31755. */
  31756. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31757. }
  31758. /**
  31759. * This class is used to track a performance counter which is number based.
  31760. * The user has access to many properties which give statistics of different nature.
  31761. *
  31762. * The implementer can track two kinds of Performance Counter: time and count.
  31763. * 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.
  31764. * 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.
  31765. */
  31766. export class PerfCounter {
  31767. /**
  31768. * Gets or sets a global boolean to turn on and off all the counters
  31769. */
  31770. static Enabled: boolean;
  31771. /**
  31772. * Returns the smallest value ever
  31773. */
  31774. readonly min: number;
  31775. /**
  31776. * Returns the biggest value ever
  31777. */
  31778. readonly max: number;
  31779. /**
  31780. * Returns the average value since the performance counter is running
  31781. */
  31782. readonly average: number;
  31783. /**
  31784. * Returns the average value of the last second the counter was monitored
  31785. */
  31786. readonly lastSecAverage: number;
  31787. /**
  31788. * Returns the current value
  31789. */
  31790. readonly current: number;
  31791. /**
  31792. * Gets the accumulated total
  31793. */
  31794. readonly total: number;
  31795. /**
  31796. * Gets the total value count
  31797. */
  31798. readonly count: number;
  31799. /**
  31800. * Creates a new counter
  31801. */
  31802. constructor();
  31803. /**
  31804. * Call this method to start monitoring a new frame.
  31805. * 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.
  31806. */
  31807. fetchNewFrame(): void;
  31808. /**
  31809. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31810. * @param newCount the count value to add to the monitored count
  31811. * @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.
  31812. */
  31813. addCount(newCount: number, fetchResult: boolean): void;
  31814. /**
  31815. * Start monitoring this performance counter
  31816. */
  31817. beginMonitoring(): void;
  31818. /**
  31819. * Compute the time lapsed since the previous beginMonitoring() call.
  31820. * @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
  31821. */
  31822. endMonitoring(newFrame?: boolean): void;
  31823. private _fetchResult;
  31824. private _startMonitoringTime;
  31825. private _min;
  31826. private _max;
  31827. private _average;
  31828. private _current;
  31829. private _totalValueCount;
  31830. private _totalAccumulated;
  31831. private _lastSecAverage;
  31832. private _lastSecAccumulated;
  31833. private _lastSecTime;
  31834. private _lastSecValueCount;
  31835. }
  31836. /**
  31837. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31838. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31839. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31840. * @param name The name of the class, case should be preserved
  31841. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31842. */
  31843. export function className(name: string, module?: string): (target: Object) => void;
  31844. /**
  31845. * An implementation of a loop for asynchronous functions.
  31846. */
  31847. export class AsyncLoop {
  31848. /**
  31849. * Defines the number of iterations for the loop
  31850. */
  31851. iterations: number;
  31852. /**
  31853. * Defines the current index of the loop.
  31854. */
  31855. index: number;
  31856. private _done;
  31857. private _fn;
  31858. private _successCallback;
  31859. /**
  31860. * Constructor.
  31861. * @param iterations the number of iterations.
  31862. * @param func the function to run each iteration
  31863. * @param successCallback the callback that will be called upon succesful execution
  31864. * @param offset starting offset.
  31865. */
  31866. constructor(
  31867. /**
  31868. * Defines the number of iterations for the loop
  31869. */
  31870. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31871. /**
  31872. * Execute the next iteration. Must be called after the last iteration was finished.
  31873. */
  31874. executeNext(): void;
  31875. /**
  31876. * Break the loop and run the success callback.
  31877. */
  31878. breakLoop(): void;
  31879. /**
  31880. * Create and run an async loop.
  31881. * @param iterations the number of iterations.
  31882. * @param fn the function to run each iteration
  31883. * @param successCallback the callback that will be called upon succesful execution
  31884. * @param offset starting offset.
  31885. * @returns the created async loop object
  31886. */
  31887. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31888. /**
  31889. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31890. * @param iterations total number of iterations
  31891. * @param syncedIterations number of synchronous iterations in each async iteration.
  31892. * @param fn the function to call each iteration.
  31893. * @param callback a success call back that will be called when iterating stops.
  31894. * @param breakFunction a break condition (optional)
  31895. * @param timeout timeout settings for the setTimeout function. default - 0.
  31896. * @returns the created async loop object
  31897. */
  31898. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31899. }
  31900. }
  31901. declare module "babylonjs/Collisions/collisionCoordinator" {
  31902. import { Nullable } from "babylonjs/types";
  31903. import { Scene } from "babylonjs/scene";
  31904. import { Vector3 } from "babylonjs/Maths/math";
  31905. import { Collider } from "babylonjs/Collisions/collider";
  31906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31907. /** @hidden */
  31908. export interface ICollisionCoordinator {
  31909. createCollider(): Collider;
  31910. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31911. init(scene: Scene): void;
  31912. }
  31913. /** @hidden */
  31914. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31915. private _scene;
  31916. private _scaledPosition;
  31917. private _scaledVelocity;
  31918. private _finalPosition;
  31919. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31920. createCollider(): Collider;
  31921. init(scene: Scene): void;
  31922. private _collideWithWorld;
  31923. }
  31924. }
  31925. declare module "babylonjs/Animations/animationGroup" {
  31926. import { Animatable } from "babylonjs/Animations/animatable";
  31927. import { Animation } from "babylonjs/Animations/animation";
  31928. import { Scene, IDisposable } from "babylonjs/scene";
  31929. import { Observable } from "babylonjs/Misc/observable";
  31930. import { Nullable } from "babylonjs/types";
  31931. /**
  31932. * This class defines the direct association between an animation and a target
  31933. */
  31934. export class TargetedAnimation {
  31935. /**
  31936. * Animation to perform
  31937. */
  31938. animation: Animation;
  31939. /**
  31940. * Target to animate
  31941. */
  31942. target: any;
  31943. }
  31944. /**
  31945. * Use this class to create coordinated animations on multiple targets
  31946. */
  31947. export class AnimationGroup implements IDisposable {
  31948. /** The name of the animation group */
  31949. name: string;
  31950. private _scene;
  31951. private _targetedAnimations;
  31952. private _animatables;
  31953. private _from;
  31954. private _to;
  31955. private _isStarted;
  31956. private _isPaused;
  31957. private _speedRatio;
  31958. /**
  31959. * Gets or sets the unique id of the node
  31960. */
  31961. uniqueId: number;
  31962. /**
  31963. * This observable will notify when one animation have ended
  31964. */
  31965. onAnimationEndObservable: Observable<TargetedAnimation>;
  31966. /**
  31967. * Observer raised when one animation loops
  31968. */
  31969. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31970. /**
  31971. * This observable will notify when all animations have ended.
  31972. */
  31973. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31974. /**
  31975. * This observable will notify when all animations have paused.
  31976. */
  31977. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31978. /**
  31979. * This observable will notify when all animations are playing.
  31980. */
  31981. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31982. /**
  31983. * Gets the first frame
  31984. */
  31985. readonly from: number;
  31986. /**
  31987. * Gets the last frame
  31988. */
  31989. readonly to: number;
  31990. /**
  31991. * Define if the animations are started
  31992. */
  31993. readonly isStarted: boolean;
  31994. /**
  31995. * Gets a value indicating that the current group is playing
  31996. */
  31997. readonly isPlaying: boolean;
  31998. /**
  31999. * Gets or sets the speed ratio to use for all animations
  32000. */
  32001. /**
  32002. * Gets or sets the speed ratio to use for all animations
  32003. */
  32004. speedRatio: number;
  32005. /**
  32006. * Gets the targeted animations for this animation group
  32007. */
  32008. readonly targetedAnimations: Array<TargetedAnimation>;
  32009. /**
  32010. * returning the list of animatables controlled by this animation group.
  32011. */
  32012. readonly animatables: Array<Animatable>;
  32013. /**
  32014. * Instantiates a new Animation Group.
  32015. * This helps managing several animations at once.
  32016. * @see http://doc.babylonjs.com/how_to/group
  32017. * @param name Defines the name of the group
  32018. * @param scene Defines the scene the group belongs to
  32019. */
  32020. constructor(
  32021. /** The name of the animation group */
  32022. name: string, scene?: Nullable<Scene>);
  32023. /**
  32024. * Add an animation (with its target) in the group
  32025. * @param animation defines the animation we want to add
  32026. * @param target defines the target of the animation
  32027. * @returns the TargetedAnimation object
  32028. */
  32029. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32030. /**
  32031. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32032. * It can add constant keys at begin or end
  32033. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32034. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32035. * @returns the animation group
  32036. */
  32037. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32038. /**
  32039. * Start all animations on given targets
  32040. * @param loop defines if animations must loop
  32041. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32042. * @param from defines the from key (optional)
  32043. * @param to defines the to key (optional)
  32044. * @returns the current animation group
  32045. */
  32046. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32047. /**
  32048. * Pause all animations
  32049. * @returns the animation group
  32050. */
  32051. pause(): AnimationGroup;
  32052. /**
  32053. * Play all animations to initial state
  32054. * This function will start() the animations if they were not started or will restart() them if they were paused
  32055. * @param loop defines if animations must loop
  32056. * @returns the animation group
  32057. */
  32058. play(loop?: boolean): AnimationGroup;
  32059. /**
  32060. * Reset all animations to initial state
  32061. * @returns the animation group
  32062. */
  32063. reset(): AnimationGroup;
  32064. /**
  32065. * Restart animations from key 0
  32066. * @returns the animation group
  32067. */
  32068. restart(): AnimationGroup;
  32069. /**
  32070. * Stop all animations
  32071. * @returns the animation group
  32072. */
  32073. stop(): AnimationGroup;
  32074. /**
  32075. * Set animation weight for all animatables
  32076. * @param weight defines the weight to use
  32077. * @return the animationGroup
  32078. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32079. */
  32080. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32081. /**
  32082. * Synchronize and normalize all animatables with a source animatable
  32083. * @param root defines the root animatable to synchronize with
  32084. * @return the animationGroup
  32085. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32086. */
  32087. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32088. /**
  32089. * Goes to a specific frame in this animation group
  32090. * @param frame the frame number to go to
  32091. * @return the animationGroup
  32092. */
  32093. goToFrame(frame: number): AnimationGroup;
  32094. /**
  32095. * Dispose all associated resources
  32096. */
  32097. dispose(): void;
  32098. private _checkAnimationGroupEnded;
  32099. /**
  32100. * Clone the current animation group and returns a copy
  32101. * @param newName defines the name of the new group
  32102. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32103. * @returns the new aniamtion group
  32104. */
  32105. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32106. /**
  32107. * Returns a new AnimationGroup object parsed from the source provided.
  32108. * @param parsedAnimationGroup defines the source
  32109. * @param scene defines the scene that will receive the animationGroup
  32110. * @returns a new AnimationGroup
  32111. */
  32112. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32113. /**
  32114. * Returns the string "AnimationGroup"
  32115. * @returns "AnimationGroup"
  32116. */
  32117. getClassName(): string;
  32118. /**
  32119. * Creates a detailled string about the object
  32120. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32121. * @returns a string representing the object
  32122. */
  32123. toString(fullDetails?: boolean): string;
  32124. }
  32125. }
  32126. declare module "babylonjs/scene" {
  32127. import { Nullable } from "babylonjs/types";
  32128. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32129. import { Observable } from "babylonjs/Misc/observable";
  32130. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32131. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32132. import { Geometry } from "babylonjs/Meshes/geometry";
  32133. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32136. import { Mesh } from "babylonjs/Meshes/mesh";
  32137. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32138. import { Bone } from "babylonjs/Bones/bone";
  32139. import { Skeleton } from "babylonjs/Bones/skeleton";
  32140. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32141. import { Camera } from "babylonjs/Cameras/camera";
  32142. import { AbstractScene } from "babylonjs/abstractScene";
  32143. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32144. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32145. import { Material } from "babylonjs/Materials/material";
  32146. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32147. import { Effect } from "babylonjs/Materials/effect";
  32148. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32149. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32150. import { Light } from "babylonjs/Lights/light";
  32151. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32152. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32153. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32154. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32155. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32156. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32157. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32158. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32159. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32160. import { Engine } from "babylonjs/Engines/engine";
  32161. import { Node } from "babylonjs/node";
  32162. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32163. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32164. import { WebRequest } from "babylonjs/Misc/webRequest";
  32165. import { Ray } from "babylonjs/Culling/ray";
  32166. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32167. import { Animation } from "babylonjs/Animations/animation";
  32168. import { Animatable } from "babylonjs/Animations/animatable";
  32169. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32170. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32171. import { Collider } from "babylonjs/Collisions/collider";
  32172. /**
  32173. * Define an interface for all classes that will hold resources
  32174. */
  32175. export interface IDisposable {
  32176. /**
  32177. * Releases all held resources
  32178. */
  32179. dispose(): void;
  32180. }
  32181. /** Interface defining initialization parameters for Scene class */
  32182. export interface SceneOptions {
  32183. /**
  32184. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32185. * It will improve performance when the number of geometries becomes important.
  32186. */
  32187. useGeometryUniqueIdsMap?: boolean;
  32188. /**
  32189. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32190. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32191. */
  32192. useMaterialMeshMap?: boolean;
  32193. /**
  32194. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32195. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32196. */
  32197. useClonedMeshhMap?: boolean;
  32198. }
  32199. /**
  32200. * Represents a scene to be rendered by the engine.
  32201. * @see http://doc.babylonjs.com/features/scene
  32202. */
  32203. export class Scene extends AbstractScene implements IAnimatable {
  32204. private static _uniqueIdCounter;
  32205. /** The fog is deactivated */
  32206. static readonly FOGMODE_NONE: number;
  32207. /** The fog density is following an exponential function */
  32208. static readonly FOGMODE_EXP: number;
  32209. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32210. static readonly FOGMODE_EXP2: number;
  32211. /** The fog density is following a linear function. */
  32212. static readonly FOGMODE_LINEAR: number;
  32213. /**
  32214. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32215. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32216. */
  32217. static MinDeltaTime: number;
  32218. /**
  32219. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32220. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32221. */
  32222. static MaxDeltaTime: number;
  32223. /**
  32224. * Factory used to create the default material.
  32225. * @param name The name of the material to create
  32226. * @param scene The scene to create the material for
  32227. * @returns The default material
  32228. */
  32229. static DefaultMaterialFactory(scene: Scene): Material;
  32230. /**
  32231. * Factory used to create the a collision coordinator.
  32232. * @returns The collision coordinator
  32233. */
  32234. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32235. /** @hidden */
  32236. readonly _isScene: boolean;
  32237. /**
  32238. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32239. */
  32240. autoClear: boolean;
  32241. /**
  32242. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32243. */
  32244. autoClearDepthAndStencil: boolean;
  32245. /**
  32246. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32247. */
  32248. clearColor: Color4;
  32249. /**
  32250. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32251. */
  32252. ambientColor: Color3;
  32253. /** @hidden */
  32254. _environmentBRDFTexture: BaseTexture;
  32255. /** @hidden */
  32256. protected _environmentTexture: Nullable<BaseTexture>;
  32257. /**
  32258. * Texture used in all pbr material as the reflection texture.
  32259. * As in the majority of the scene they are the same (exception for multi room and so on),
  32260. * this is easier to reference from here than from all the materials.
  32261. */
  32262. /**
  32263. * Texture used in all pbr material as the reflection texture.
  32264. * As in the majority of the scene they are the same (exception for multi room and so on),
  32265. * this is easier to set here than in all the materials.
  32266. */
  32267. environmentTexture: Nullable<BaseTexture>;
  32268. /** @hidden */
  32269. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32270. /**
  32271. * Default image processing configuration used either in the rendering
  32272. * Forward main pass or through the imageProcessingPostProcess if present.
  32273. * As in the majority of the scene they are the same (exception for multi camera),
  32274. * this is easier to reference from here than from all the materials and post process.
  32275. *
  32276. * No setter as we it is a shared configuration, you can set the values instead.
  32277. */
  32278. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32279. private _forceWireframe;
  32280. /**
  32281. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32282. */
  32283. forceWireframe: boolean;
  32284. private _forcePointsCloud;
  32285. /**
  32286. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32287. */
  32288. forcePointsCloud: boolean;
  32289. /**
  32290. * Gets or sets the active clipplane 1
  32291. */
  32292. clipPlane: Nullable<Plane>;
  32293. /**
  32294. * Gets or sets the active clipplane 2
  32295. */
  32296. clipPlane2: Nullable<Plane>;
  32297. /**
  32298. * Gets or sets the active clipplane 3
  32299. */
  32300. clipPlane3: Nullable<Plane>;
  32301. /**
  32302. * Gets or sets the active clipplane 4
  32303. */
  32304. clipPlane4: Nullable<Plane>;
  32305. /**
  32306. * Gets or sets a boolean indicating if animations are enabled
  32307. */
  32308. animationsEnabled: boolean;
  32309. private _animationPropertiesOverride;
  32310. /**
  32311. * Gets or sets the animation properties override
  32312. */
  32313. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32314. /**
  32315. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32316. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32317. */
  32318. useConstantAnimationDeltaTime: boolean;
  32319. /**
  32320. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32321. * Please note that it requires to run a ray cast through the scene on every frame
  32322. */
  32323. constantlyUpdateMeshUnderPointer: boolean;
  32324. /**
  32325. * Defines the HTML cursor to use when hovering over interactive elements
  32326. */
  32327. hoverCursor: string;
  32328. /**
  32329. * Defines the HTML default cursor to use (empty by default)
  32330. */
  32331. defaultCursor: string;
  32332. /**
  32333. * This is used to call preventDefault() on pointer down
  32334. * in order to block unwanted artifacts like system double clicks
  32335. */
  32336. preventDefaultOnPointerDown: boolean;
  32337. /**
  32338. * This is used to call preventDefault() on pointer up
  32339. * in order to block unwanted artifacts like system double clicks
  32340. */
  32341. preventDefaultOnPointerUp: boolean;
  32342. /**
  32343. * Gets or sets user defined metadata
  32344. */
  32345. metadata: any;
  32346. /**
  32347. * For internal use only. Please do not use.
  32348. */
  32349. reservedDataStore: any;
  32350. /**
  32351. * Gets the name of the plugin used to load this scene (null by default)
  32352. */
  32353. loadingPluginName: string;
  32354. /**
  32355. * Use this array to add regular expressions used to disable offline support for specific urls
  32356. */
  32357. disableOfflineSupportExceptionRules: RegExp[];
  32358. /**
  32359. * An event triggered when the scene is disposed.
  32360. */
  32361. onDisposeObservable: Observable<Scene>;
  32362. private _onDisposeObserver;
  32363. /** Sets a function to be executed when this scene is disposed. */
  32364. onDispose: () => void;
  32365. /**
  32366. * An event triggered before rendering the scene (right after animations and physics)
  32367. */
  32368. onBeforeRenderObservable: Observable<Scene>;
  32369. private _onBeforeRenderObserver;
  32370. /** Sets a function to be executed before rendering this scene */
  32371. beforeRender: Nullable<() => void>;
  32372. /**
  32373. * An event triggered after rendering the scene
  32374. */
  32375. onAfterRenderObservable: Observable<Scene>;
  32376. private _onAfterRenderObserver;
  32377. /** Sets a function to be executed after rendering this scene */
  32378. afterRender: Nullable<() => void>;
  32379. /**
  32380. * An event triggered before animating the scene
  32381. */
  32382. onBeforeAnimationsObservable: Observable<Scene>;
  32383. /**
  32384. * An event triggered after animations processing
  32385. */
  32386. onAfterAnimationsObservable: Observable<Scene>;
  32387. /**
  32388. * An event triggered before draw calls are ready to be sent
  32389. */
  32390. onBeforeDrawPhaseObservable: Observable<Scene>;
  32391. /**
  32392. * An event triggered after draw calls have been sent
  32393. */
  32394. onAfterDrawPhaseObservable: Observable<Scene>;
  32395. /**
  32396. * An event triggered when the scene is ready
  32397. */
  32398. onReadyObservable: Observable<Scene>;
  32399. /**
  32400. * An event triggered before rendering a camera
  32401. */
  32402. onBeforeCameraRenderObservable: Observable<Camera>;
  32403. private _onBeforeCameraRenderObserver;
  32404. /** Sets a function to be executed before rendering a camera*/
  32405. beforeCameraRender: () => void;
  32406. /**
  32407. * An event triggered after rendering a camera
  32408. */
  32409. onAfterCameraRenderObservable: Observable<Camera>;
  32410. private _onAfterCameraRenderObserver;
  32411. /** Sets a function to be executed after rendering a camera*/
  32412. afterCameraRender: () => void;
  32413. /**
  32414. * An event triggered when active meshes evaluation is about to start
  32415. */
  32416. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32417. /**
  32418. * An event triggered when active meshes evaluation is done
  32419. */
  32420. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32421. /**
  32422. * An event triggered when particles rendering is about to start
  32423. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32424. */
  32425. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32426. /**
  32427. * An event triggered when particles rendering is done
  32428. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32429. */
  32430. onAfterParticlesRenderingObservable: Observable<Scene>;
  32431. /**
  32432. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32433. */
  32434. onDataLoadedObservable: Observable<Scene>;
  32435. /**
  32436. * An event triggered when a camera is created
  32437. */
  32438. onNewCameraAddedObservable: Observable<Camera>;
  32439. /**
  32440. * An event triggered when a camera is removed
  32441. */
  32442. onCameraRemovedObservable: Observable<Camera>;
  32443. /**
  32444. * An event triggered when a light is created
  32445. */
  32446. onNewLightAddedObservable: Observable<Light>;
  32447. /**
  32448. * An event triggered when a light is removed
  32449. */
  32450. onLightRemovedObservable: Observable<Light>;
  32451. /**
  32452. * An event triggered when a geometry is created
  32453. */
  32454. onNewGeometryAddedObservable: Observable<Geometry>;
  32455. /**
  32456. * An event triggered when a geometry is removed
  32457. */
  32458. onGeometryRemovedObservable: Observable<Geometry>;
  32459. /**
  32460. * An event triggered when a transform node is created
  32461. */
  32462. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32463. /**
  32464. * An event triggered when a transform node is removed
  32465. */
  32466. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32467. /**
  32468. * An event triggered when a mesh is created
  32469. */
  32470. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32471. /**
  32472. * An event triggered when a mesh is removed
  32473. */
  32474. onMeshRemovedObservable: Observable<AbstractMesh>;
  32475. /**
  32476. * An event triggered when a skeleton is created
  32477. */
  32478. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32479. /**
  32480. * An event triggered when a skeleton is removed
  32481. */
  32482. onSkeletonRemovedObservable: Observable<Skeleton>;
  32483. /**
  32484. * An event triggered when a material is created
  32485. */
  32486. onNewMaterialAddedObservable: Observable<Material>;
  32487. /**
  32488. * An event triggered when a material is removed
  32489. */
  32490. onMaterialRemovedObservable: Observable<Material>;
  32491. /**
  32492. * An event triggered when a texture is created
  32493. */
  32494. onNewTextureAddedObservable: Observable<BaseTexture>;
  32495. /**
  32496. * An event triggered when a texture is removed
  32497. */
  32498. onTextureRemovedObservable: Observable<BaseTexture>;
  32499. /**
  32500. * An event triggered when render targets are about to be rendered
  32501. * Can happen multiple times per frame.
  32502. */
  32503. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32504. /**
  32505. * An event triggered when render targets were rendered.
  32506. * Can happen multiple times per frame.
  32507. */
  32508. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32509. /**
  32510. * An event triggered before calculating deterministic simulation step
  32511. */
  32512. onBeforeStepObservable: Observable<Scene>;
  32513. /**
  32514. * An event triggered after calculating deterministic simulation step
  32515. */
  32516. onAfterStepObservable: Observable<Scene>;
  32517. /**
  32518. * An event triggered when the activeCamera property is updated
  32519. */
  32520. onActiveCameraChanged: Observable<Scene>;
  32521. /**
  32522. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32523. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32524. * 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)
  32525. */
  32526. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32527. /**
  32528. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32529. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32530. * 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)
  32531. */
  32532. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32533. /**
  32534. * This Observable will when a mesh has been imported into the scene.
  32535. */
  32536. onMeshImportedObservable: Observable<AbstractMesh>;
  32537. /**
  32538. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32539. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32540. */
  32541. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32542. /** @hidden */
  32543. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32544. /**
  32545. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32546. */
  32547. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32548. /**
  32549. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32550. */
  32551. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32552. /**
  32553. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32554. */
  32555. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32556. private _onPointerMove;
  32557. private _onPointerDown;
  32558. private _onPointerUp;
  32559. /** Callback called when a pointer move is detected */
  32560. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32561. /** Callback called when a pointer down is detected */
  32562. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32563. /** Callback called when a pointer up is detected */
  32564. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32565. /** Callback called when a pointer pick is detected */
  32566. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32567. /**
  32568. * 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).
  32569. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32570. */
  32571. onPrePointerObservable: Observable<PointerInfoPre>;
  32572. /**
  32573. * Observable event triggered each time an input event is received from the rendering canvas
  32574. */
  32575. onPointerObservable: Observable<PointerInfo>;
  32576. /**
  32577. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32578. */
  32579. readonly unTranslatedPointer: Vector2;
  32580. /** The distance in pixel that you have to move to prevent some events */
  32581. static DragMovementThreshold: number;
  32582. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32583. static LongPressDelay: number;
  32584. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32585. static DoubleClickDelay: number;
  32586. /** If you need to check double click without raising a single click at first click, enable this flag */
  32587. static ExclusiveDoubleClickMode: boolean;
  32588. private _initClickEvent;
  32589. private _initActionManager;
  32590. private _delayedSimpleClick;
  32591. private _delayedSimpleClickTimeout;
  32592. private _previousDelayedSimpleClickTimeout;
  32593. private _meshPickProceed;
  32594. private _previousButtonPressed;
  32595. private _currentPickResult;
  32596. private _previousPickResult;
  32597. private _totalPointersPressed;
  32598. private _doubleClickOccured;
  32599. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32600. cameraToUseForPointers: Nullable<Camera>;
  32601. private _pointerX;
  32602. private _pointerY;
  32603. private _unTranslatedPointerX;
  32604. private _unTranslatedPointerY;
  32605. private _startingPointerPosition;
  32606. private _previousStartingPointerPosition;
  32607. private _startingPointerTime;
  32608. private _previousStartingPointerTime;
  32609. private _pointerCaptures;
  32610. private _timeAccumulator;
  32611. private _currentStepId;
  32612. private _currentInternalStep;
  32613. /** @hidden */
  32614. _mirroredCameraPosition: Nullable<Vector3>;
  32615. /**
  32616. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32617. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32618. */
  32619. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32620. /**
  32621. * Observable event triggered each time an keyboard event is received from the hosting window
  32622. */
  32623. onKeyboardObservable: Observable<KeyboardInfo>;
  32624. private _onKeyDown;
  32625. private _onKeyUp;
  32626. private _onCanvasFocusObserver;
  32627. private _onCanvasBlurObserver;
  32628. private _useRightHandedSystem;
  32629. /**
  32630. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32631. */
  32632. useRightHandedSystem: boolean;
  32633. /**
  32634. * Sets the step Id used by deterministic lock step
  32635. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32636. * @param newStepId defines the step Id
  32637. */
  32638. setStepId(newStepId: number): void;
  32639. /**
  32640. * Gets the step Id used by deterministic lock step
  32641. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32642. * @returns the step Id
  32643. */
  32644. getStepId(): number;
  32645. /**
  32646. * Gets the internal step used by deterministic lock step
  32647. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32648. * @returns the internal step
  32649. */
  32650. getInternalStep(): number;
  32651. private _fogEnabled;
  32652. /**
  32653. * Gets or sets a boolean indicating if fog is enabled on this scene
  32654. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32655. * (Default is true)
  32656. */
  32657. fogEnabled: boolean;
  32658. private _fogMode;
  32659. /**
  32660. * Gets or sets the fog mode to use
  32661. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32662. * | mode | value |
  32663. * | --- | --- |
  32664. * | FOGMODE_NONE | 0 |
  32665. * | FOGMODE_EXP | 1 |
  32666. * | FOGMODE_EXP2 | 2 |
  32667. * | FOGMODE_LINEAR | 3 |
  32668. */
  32669. fogMode: number;
  32670. /**
  32671. * Gets or sets the fog color to use
  32672. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32673. * (Default is Color3(0.2, 0.2, 0.3))
  32674. */
  32675. fogColor: Color3;
  32676. /**
  32677. * Gets or sets the fog density to use
  32678. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32679. * (Default is 0.1)
  32680. */
  32681. fogDensity: number;
  32682. /**
  32683. * Gets or sets the fog start distance to use
  32684. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32685. * (Default is 0)
  32686. */
  32687. fogStart: number;
  32688. /**
  32689. * Gets or sets the fog end distance to use
  32690. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32691. * (Default is 1000)
  32692. */
  32693. fogEnd: number;
  32694. private _shadowsEnabled;
  32695. /**
  32696. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32697. */
  32698. shadowsEnabled: boolean;
  32699. private _lightsEnabled;
  32700. /**
  32701. * Gets or sets a boolean indicating if lights are enabled on this scene
  32702. */
  32703. lightsEnabled: boolean;
  32704. /** All of the active cameras added to this scene. */
  32705. activeCameras: Camera[];
  32706. private _activeCamera;
  32707. /** Gets or sets the current active camera */
  32708. activeCamera: Nullable<Camera>;
  32709. private _defaultMaterial;
  32710. /** The default material used on meshes when no material is affected */
  32711. /** The default material used on meshes when no material is affected */
  32712. defaultMaterial: Material;
  32713. private _texturesEnabled;
  32714. /**
  32715. * Gets or sets a boolean indicating if textures are enabled on this scene
  32716. */
  32717. texturesEnabled: boolean;
  32718. /**
  32719. * Gets or sets a boolean indicating if particles are enabled on this scene
  32720. */
  32721. particlesEnabled: boolean;
  32722. /**
  32723. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32724. */
  32725. spritesEnabled: boolean;
  32726. private _skeletonsEnabled;
  32727. /**
  32728. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32729. */
  32730. skeletonsEnabled: boolean;
  32731. /**
  32732. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32733. */
  32734. lensFlaresEnabled: boolean;
  32735. /**
  32736. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32737. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32738. */
  32739. collisionsEnabled: boolean;
  32740. private _collisionCoordinator;
  32741. /** @hidden */
  32742. readonly collisionCoordinator: ICollisionCoordinator;
  32743. /**
  32744. * Defines the gravity applied to this scene (used only for collisions)
  32745. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32746. */
  32747. gravity: Vector3;
  32748. /**
  32749. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32750. */
  32751. postProcessesEnabled: boolean;
  32752. /**
  32753. * The list of postprocesses added to the scene
  32754. */
  32755. postProcesses: PostProcess[];
  32756. /**
  32757. * Gets the current postprocess manager
  32758. */
  32759. postProcessManager: PostProcessManager;
  32760. /**
  32761. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32762. */
  32763. renderTargetsEnabled: boolean;
  32764. /**
  32765. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32766. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32767. */
  32768. dumpNextRenderTargets: boolean;
  32769. /**
  32770. * The list of user defined render targets added to the scene
  32771. */
  32772. customRenderTargets: RenderTargetTexture[];
  32773. /**
  32774. * Defines if texture loading must be delayed
  32775. * If true, textures will only be loaded when they need to be rendered
  32776. */
  32777. useDelayedTextureLoading: boolean;
  32778. /**
  32779. * Gets the list of meshes imported to the scene through SceneLoader
  32780. */
  32781. importedMeshesFiles: String[];
  32782. /**
  32783. * Gets or sets a boolean indicating if probes are enabled on this scene
  32784. */
  32785. probesEnabled: boolean;
  32786. /**
  32787. * Gets or sets the current offline provider to use to store scene data
  32788. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32789. */
  32790. offlineProvider: IOfflineProvider;
  32791. /**
  32792. * Gets or sets the action manager associated with the scene
  32793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32794. */
  32795. actionManager: AbstractActionManager;
  32796. private _meshesForIntersections;
  32797. /**
  32798. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32799. */
  32800. proceduralTexturesEnabled: boolean;
  32801. private _engine;
  32802. private _totalVertices;
  32803. /** @hidden */
  32804. _activeIndices: PerfCounter;
  32805. /** @hidden */
  32806. _activeParticles: PerfCounter;
  32807. /** @hidden */
  32808. _activeBones: PerfCounter;
  32809. private _animationRatio;
  32810. /** @hidden */
  32811. _animationTimeLast: number;
  32812. /** @hidden */
  32813. _animationTime: number;
  32814. /**
  32815. * Gets or sets a general scale for animation speed
  32816. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32817. */
  32818. animationTimeScale: number;
  32819. /** @hidden */
  32820. _cachedMaterial: Nullable<Material>;
  32821. /** @hidden */
  32822. _cachedEffect: Nullable<Effect>;
  32823. /** @hidden */
  32824. _cachedVisibility: Nullable<number>;
  32825. private _renderId;
  32826. private _frameId;
  32827. private _executeWhenReadyTimeoutId;
  32828. private _intermediateRendering;
  32829. private _viewUpdateFlag;
  32830. private _projectionUpdateFlag;
  32831. private _alternateViewUpdateFlag;
  32832. private _alternateProjectionUpdateFlag;
  32833. /** @hidden */
  32834. _toBeDisposed: Nullable<IDisposable>[];
  32835. private _activeRequests;
  32836. /** @hidden */
  32837. _pendingData: any[];
  32838. private _isDisposed;
  32839. /**
  32840. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32841. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32842. */
  32843. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32844. private _activeMeshes;
  32845. private _processedMaterials;
  32846. private _renderTargets;
  32847. /** @hidden */
  32848. _activeParticleSystems: SmartArray<IParticleSystem>;
  32849. private _activeSkeletons;
  32850. private _softwareSkinnedMeshes;
  32851. private _renderingManager;
  32852. /** @hidden */
  32853. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32854. private _transformMatrix;
  32855. private _sceneUbo;
  32856. private _alternateSceneUbo;
  32857. private _viewMatrix;
  32858. private _projectionMatrix;
  32859. private _alternateViewMatrix;
  32860. private _alternateProjectionMatrix;
  32861. private _alternateTransformMatrix;
  32862. private _useAlternateCameraConfiguration;
  32863. private _alternateRendering;
  32864. private _wheelEventName;
  32865. /** @hidden */
  32866. _forcedViewPosition: Nullable<Vector3>;
  32867. /** @hidden */
  32868. readonly _isAlternateRenderingEnabled: boolean;
  32869. private _frustumPlanes;
  32870. /**
  32871. * Gets the list of frustum planes (built from the active camera)
  32872. */
  32873. readonly frustumPlanes: Plane[];
  32874. /**
  32875. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32876. * This is useful if there are more lights that the maximum simulteanous authorized
  32877. */
  32878. requireLightSorting: boolean;
  32879. /** @hidden */
  32880. readonly useMaterialMeshMap: boolean;
  32881. /** @hidden */
  32882. readonly useClonedMeshhMap: boolean;
  32883. private _pointerOverMesh;
  32884. private _pickedDownMesh;
  32885. private _pickedUpMesh;
  32886. private _externalData;
  32887. private _uid;
  32888. /**
  32889. * @hidden
  32890. * Backing store of defined scene components.
  32891. */
  32892. _components: ISceneComponent[];
  32893. /**
  32894. * @hidden
  32895. * Backing store of defined scene components.
  32896. */
  32897. _serializableComponents: ISceneSerializableComponent[];
  32898. /**
  32899. * List of components to register on the next registration step.
  32900. */
  32901. private _transientComponents;
  32902. /**
  32903. * Registers the transient components if needed.
  32904. */
  32905. private _registerTransientComponents;
  32906. /**
  32907. * @hidden
  32908. * Add a component to the scene.
  32909. * Note that the ccomponent could be registered on th next frame if this is called after
  32910. * the register component stage.
  32911. * @param component Defines the component to add to the scene
  32912. */
  32913. _addComponent(component: ISceneComponent): void;
  32914. /**
  32915. * @hidden
  32916. * Gets a component from the scene.
  32917. * @param name defines the name of the component to retrieve
  32918. * @returns the component or null if not present
  32919. */
  32920. _getComponent(name: string): Nullable<ISceneComponent>;
  32921. /**
  32922. * @hidden
  32923. * Defines the actions happening before camera updates.
  32924. */
  32925. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32926. /**
  32927. * @hidden
  32928. * Defines the actions happening before clear the canvas.
  32929. */
  32930. _beforeClearStage: Stage<SimpleStageAction>;
  32931. /**
  32932. * @hidden
  32933. * Defines the actions when collecting render targets for the frame.
  32934. */
  32935. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32936. /**
  32937. * @hidden
  32938. * Defines the actions happening for one camera in the frame.
  32939. */
  32940. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32941. /**
  32942. * @hidden
  32943. * Defines the actions happening during the per mesh ready checks.
  32944. */
  32945. _isReadyForMeshStage: Stage<MeshStageAction>;
  32946. /**
  32947. * @hidden
  32948. * Defines the actions happening before evaluate active mesh checks.
  32949. */
  32950. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32951. /**
  32952. * @hidden
  32953. * Defines the actions happening during the evaluate sub mesh checks.
  32954. */
  32955. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32956. /**
  32957. * @hidden
  32958. * Defines the actions happening during the active mesh stage.
  32959. */
  32960. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32961. /**
  32962. * @hidden
  32963. * Defines the actions happening during the per camera render target step.
  32964. */
  32965. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32966. /**
  32967. * @hidden
  32968. * Defines the actions happening just before the active camera is drawing.
  32969. */
  32970. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32971. /**
  32972. * @hidden
  32973. * Defines the actions happening just before a render target is drawing.
  32974. */
  32975. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32976. /**
  32977. * @hidden
  32978. * Defines the actions happening just before a rendering group is drawing.
  32979. */
  32980. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32981. /**
  32982. * @hidden
  32983. * Defines the actions happening just before a mesh is drawing.
  32984. */
  32985. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32986. /**
  32987. * @hidden
  32988. * Defines the actions happening just after a mesh has been drawn.
  32989. */
  32990. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32991. /**
  32992. * @hidden
  32993. * Defines the actions happening just after a rendering group has been drawn.
  32994. */
  32995. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32996. /**
  32997. * @hidden
  32998. * Defines the actions happening just after the active camera has been drawn.
  32999. */
  33000. _afterCameraDrawStage: Stage<CameraStageAction>;
  33001. /**
  33002. * @hidden
  33003. * Defines the actions happening just after a render target has been drawn.
  33004. */
  33005. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33006. /**
  33007. * @hidden
  33008. * Defines the actions happening just after rendering all cameras and computing intersections.
  33009. */
  33010. _afterRenderStage: Stage<SimpleStageAction>;
  33011. /**
  33012. * @hidden
  33013. * Defines the actions happening when a pointer move event happens.
  33014. */
  33015. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33016. /**
  33017. * @hidden
  33018. * Defines the actions happening when a pointer down event happens.
  33019. */
  33020. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33021. /**
  33022. * @hidden
  33023. * Defines the actions happening when a pointer up event happens.
  33024. */
  33025. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33026. /**
  33027. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33028. */
  33029. private geometriesByUniqueId;
  33030. /**
  33031. * Creates a new Scene
  33032. * @param engine defines the engine to use to render this scene
  33033. * @param options defines the scene options
  33034. */
  33035. constructor(engine: Engine, options?: SceneOptions);
  33036. private _defaultMeshCandidates;
  33037. /**
  33038. * @hidden
  33039. */
  33040. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33041. private _defaultSubMeshCandidates;
  33042. /**
  33043. * @hidden
  33044. */
  33045. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33046. /**
  33047. * Sets the default candidate providers for the scene.
  33048. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33049. * and getCollidingSubMeshCandidates to their default function
  33050. */
  33051. setDefaultCandidateProviders(): void;
  33052. /**
  33053. * Gets the mesh that is currently under the pointer
  33054. */
  33055. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33056. /**
  33057. * Gets or sets the current on-screen X position of the pointer
  33058. */
  33059. pointerX: number;
  33060. /**
  33061. * Gets or sets the current on-screen Y position of the pointer
  33062. */
  33063. pointerY: number;
  33064. /**
  33065. * Gets the cached material (ie. the latest rendered one)
  33066. * @returns the cached material
  33067. */
  33068. getCachedMaterial(): Nullable<Material>;
  33069. /**
  33070. * Gets the cached effect (ie. the latest rendered one)
  33071. * @returns the cached effect
  33072. */
  33073. getCachedEffect(): Nullable<Effect>;
  33074. /**
  33075. * Gets the cached visibility state (ie. the latest rendered one)
  33076. * @returns the cached visibility state
  33077. */
  33078. getCachedVisibility(): Nullable<number>;
  33079. /**
  33080. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33081. * @param material defines the current material
  33082. * @param effect defines the current effect
  33083. * @param visibility defines the current visibility state
  33084. * @returns true if one parameter is not cached
  33085. */
  33086. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33087. /**
  33088. * Gets the engine associated with the scene
  33089. * @returns an Engine
  33090. */
  33091. getEngine(): Engine;
  33092. /**
  33093. * Gets the total number of vertices rendered per frame
  33094. * @returns the total number of vertices rendered per frame
  33095. */
  33096. getTotalVertices(): number;
  33097. /**
  33098. * Gets the performance counter for total vertices
  33099. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33100. */
  33101. readonly totalVerticesPerfCounter: PerfCounter;
  33102. /**
  33103. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33104. * @returns the total number of active indices rendered per frame
  33105. */
  33106. getActiveIndices(): number;
  33107. /**
  33108. * Gets the performance counter for active indices
  33109. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33110. */
  33111. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33112. /**
  33113. * Gets the total number of active particles rendered per frame
  33114. * @returns the total number of active particles rendered per frame
  33115. */
  33116. getActiveParticles(): number;
  33117. /**
  33118. * Gets the performance counter for active particles
  33119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33120. */
  33121. readonly activeParticlesPerfCounter: PerfCounter;
  33122. /**
  33123. * Gets the total number of active bones rendered per frame
  33124. * @returns the total number of active bones rendered per frame
  33125. */
  33126. getActiveBones(): number;
  33127. /**
  33128. * Gets the performance counter for active bones
  33129. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33130. */
  33131. readonly activeBonesPerfCounter: PerfCounter;
  33132. /**
  33133. * Gets the array of active meshes
  33134. * @returns an array of AbstractMesh
  33135. */
  33136. getActiveMeshes(): SmartArray<AbstractMesh>;
  33137. /**
  33138. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33139. * @returns a number
  33140. */
  33141. getAnimationRatio(): number;
  33142. /**
  33143. * Gets an unique Id for the current render phase
  33144. * @returns a number
  33145. */
  33146. getRenderId(): number;
  33147. /**
  33148. * Gets an unique Id for the current frame
  33149. * @returns a number
  33150. */
  33151. getFrameId(): number;
  33152. /** Call this function if you want to manually increment the render Id*/
  33153. incrementRenderId(): void;
  33154. private _updatePointerPosition;
  33155. private _createUbo;
  33156. private _createAlternateUbo;
  33157. private _setRayOnPointerInfo;
  33158. /**
  33159. * Use this method to simulate a pointer move on a mesh
  33160. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33161. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33162. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33163. * @returns the current scene
  33164. */
  33165. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33166. private _processPointerMove;
  33167. private _checkPrePointerObservable;
  33168. /**
  33169. * Use this method to simulate a pointer down on a mesh
  33170. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33171. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33172. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33173. * @returns the current scene
  33174. */
  33175. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33176. private _processPointerDown;
  33177. /**
  33178. * Use this method to simulate a pointer up on a mesh
  33179. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33180. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33181. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33182. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33183. * @returns the current scene
  33184. */
  33185. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33186. private _processPointerUp;
  33187. /**
  33188. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33189. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33190. * @returns true if the pointer was captured
  33191. */
  33192. isPointerCaptured(pointerId?: number): boolean;
  33193. /** @hidden */
  33194. _isPointerSwiping(): boolean;
  33195. /**
  33196. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33197. * @param attachUp defines if you want to attach events to pointerup
  33198. * @param attachDown defines if you want to attach events to pointerdown
  33199. * @param attachMove defines if you want to attach events to pointermove
  33200. */
  33201. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33202. /** Detaches all event handlers*/
  33203. detachControl(): void;
  33204. /**
  33205. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33206. * Delay loaded resources are not taking in account
  33207. * @return true if all required resources are ready
  33208. */
  33209. isReady(): boolean;
  33210. /** Resets all cached information relative to material (including effect and visibility) */
  33211. resetCachedMaterial(): void;
  33212. /**
  33213. * Registers a function to be called before every frame render
  33214. * @param func defines the function to register
  33215. */
  33216. registerBeforeRender(func: () => void): void;
  33217. /**
  33218. * Unregisters a function called before every frame render
  33219. * @param func defines the function to unregister
  33220. */
  33221. unregisterBeforeRender(func: () => void): void;
  33222. /**
  33223. * Registers a function to be called after every frame render
  33224. * @param func defines the function to register
  33225. */
  33226. registerAfterRender(func: () => void): void;
  33227. /**
  33228. * Unregisters a function called after every frame render
  33229. * @param func defines the function to unregister
  33230. */
  33231. unregisterAfterRender(func: () => void): void;
  33232. private _executeOnceBeforeRender;
  33233. /**
  33234. * The provided function will run before render once and will be disposed afterwards.
  33235. * A timeout delay can be provided so that the function will be executed in N ms.
  33236. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33237. * @param func The function to be executed.
  33238. * @param timeout optional delay in ms
  33239. */
  33240. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33241. /** @hidden */
  33242. _addPendingData(data: any): void;
  33243. /** @hidden */
  33244. _removePendingData(data: any): void;
  33245. /**
  33246. * Returns the number of items waiting to be loaded
  33247. * @returns the number of items waiting to be loaded
  33248. */
  33249. getWaitingItemsCount(): number;
  33250. /**
  33251. * Returns a boolean indicating if the scene is still loading data
  33252. */
  33253. readonly isLoading: boolean;
  33254. /**
  33255. * Registers a function to be executed when the scene is ready
  33256. * @param {Function} func - the function to be executed
  33257. */
  33258. executeWhenReady(func: () => void): void;
  33259. /**
  33260. * Returns a promise that resolves when the scene is ready
  33261. * @returns A promise that resolves when the scene is ready
  33262. */
  33263. whenReadyAsync(): Promise<void>;
  33264. /** @hidden */
  33265. _checkIsReady(): void;
  33266. /**
  33267. * Gets all animatable attached to the scene
  33268. */
  33269. readonly animatables: Animatable[];
  33270. /**
  33271. * Resets the last animation time frame.
  33272. * Useful to override when animations start running when loading a scene for the first time.
  33273. */
  33274. resetLastAnimationTimeFrame(): void;
  33275. /** @hidden */
  33276. _switchToAlternateCameraConfiguration(active: boolean): void;
  33277. /**
  33278. * Gets the current view matrix
  33279. * @returns a Matrix
  33280. */
  33281. getViewMatrix(): Matrix;
  33282. /**
  33283. * Gets the current projection matrix
  33284. * @returns a Matrix
  33285. */
  33286. getProjectionMatrix(): Matrix;
  33287. /**
  33288. * Gets the current transform matrix
  33289. * @returns a Matrix made of View * Projection
  33290. */
  33291. getTransformMatrix(): Matrix;
  33292. /**
  33293. * Sets the current transform matrix
  33294. * @param view defines the View matrix to use
  33295. * @param projection defines the Projection matrix to use
  33296. */
  33297. setTransformMatrix(view: Matrix, projection: Matrix): void;
  33298. /** @hidden */
  33299. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  33300. /**
  33301. * Gets the uniform buffer used to store scene data
  33302. * @returns a UniformBuffer
  33303. */
  33304. getSceneUniformBuffer(): UniformBuffer;
  33305. /**
  33306. * Gets an unique (relatively to the current scene) Id
  33307. * @returns an unique number for the scene
  33308. */
  33309. getUniqueId(): number;
  33310. /**
  33311. * Add a mesh to the list of scene's meshes
  33312. * @param newMesh defines the mesh to add
  33313. * @param recursive if all child meshes should also be added to the scene
  33314. */
  33315. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33316. /**
  33317. * Remove a mesh for the list of scene's meshes
  33318. * @param toRemove defines the mesh to remove
  33319. * @param recursive if all child meshes should also be removed from the scene
  33320. * @returns the index where the mesh was in the mesh list
  33321. */
  33322. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33323. /**
  33324. * Add a transform node to the list of scene's transform nodes
  33325. * @param newTransformNode defines the transform node to add
  33326. */
  33327. addTransformNode(newTransformNode: TransformNode): void;
  33328. /**
  33329. * Remove a transform node for the list of scene's transform nodes
  33330. * @param toRemove defines the transform node to remove
  33331. * @returns the index where the transform node was in the transform node list
  33332. */
  33333. removeTransformNode(toRemove: TransformNode): number;
  33334. /**
  33335. * Remove a skeleton for the list of scene's skeletons
  33336. * @param toRemove defines the skeleton to remove
  33337. * @returns the index where the skeleton was in the skeleton list
  33338. */
  33339. removeSkeleton(toRemove: Skeleton): number;
  33340. /**
  33341. * Remove a morph target for the list of scene's morph targets
  33342. * @param toRemove defines the morph target to remove
  33343. * @returns the index where the morph target was in the morph target list
  33344. */
  33345. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33346. /**
  33347. * Remove a light for the list of scene's lights
  33348. * @param toRemove defines the light to remove
  33349. * @returns the index where the light was in the light list
  33350. */
  33351. removeLight(toRemove: Light): number;
  33352. /**
  33353. * Remove a camera for the list of scene's cameras
  33354. * @param toRemove defines the camera to remove
  33355. * @returns the index where the camera was in the camera list
  33356. */
  33357. removeCamera(toRemove: Camera): number;
  33358. /**
  33359. * Remove a particle system for the list of scene's particle systems
  33360. * @param toRemove defines the particle system to remove
  33361. * @returns the index where the particle system was in the particle system list
  33362. */
  33363. removeParticleSystem(toRemove: IParticleSystem): number;
  33364. /**
  33365. * Remove a animation for the list of scene's animations
  33366. * @param toRemove defines the animation to remove
  33367. * @returns the index where the animation was in the animation list
  33368. */
  33369. removeAnimation(toRemove: Animation): number;
  33370. /**
  33371. * Removes the given animation group from this scene.
  33372. * @param toRemove The animation group to remove
  33373. * @returns The index of the removed animation group
  33374. */
  33375. removeAnimationGroup(toRemove: AnimationGroup): number;
  33376. /**
  33377. * Removes the given multi-material from this scene.
  33378. * @param toRemove The multi-material to remove
  33379. * @returns The index of the removed multi-material
  33380. */
  33381. removeMultiMaterial(toRemove: MultiMaterial): number;
  33382. /**
  33383. * Removes the given material from this scene.
  33384. * @param toRemove The material to remove
  33385. * @returns The index of the removed material
  33386. */
  33387. removeMaterial(toRemove: Material): number;
  33388. /**
  33389. * Removes the given action manager from this scene.
  33390. * @param toRemove The action manager to remove
  33391. * @returns The index of the removed action manager
  33392. */
  33393. removeActionManager(toRemove: AbstractActionManager): number;
  33394. /**
  33395. * Removes the given texture from this scene.
  33396. * @param toRemove The texture to remove
  33397. * @returns The index of the removed texture
  33398. */
  33399. removeTexture(toRemove: BaseTexture): number;
  33400. /**
  33401. * Adds the given light to this scene
  33402. * @param newLight The light to add
  33403. */
  33404. addLight(newLight: Light): void;
  33405. /**
  33406. * Sorts the list list based on light priorities
  33407. */
  33408. sortLightsByPriority(): void;
  33409. /**
  33410. * Adds the given camera to this scene
  33411. * @param newCamera The camera to add
  33412. */
  33413. addCamera(newCamera: Camera): void;
  33414. /**
  33415. * Adds the given skeleton to this scene
  33416. * @param newSkeleton The skeleton to add
  33417. */
  33418. addSkeleton(newSkeleton: Skeleton): void;
  33419. /**
  33420. * Adds the given particle system to this scene
  33421. * @param newParticleSystem The particle system to add
  33422. */
  33423. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33424. /**
  33425. * Adds the given animation to this scene
  33426. * @param newAnimation The animation to add
  33427. */
  33428. addAnimation(newAnimation: Animation): void;
  33429. /**
  33430. * Adds the given animation group to this scene.
  33431. * @param newAnimationGroup The animation group to add
  33432. */
  33433. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33434. /**
  33435. * Adds the given multi-material to this scene
  33436. * @param newMultiMaterial The multi-material to add
  33437. */
  33438. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33439. /**
  33440. * Adds the given material to this scene
  33441. * @param newMaterial The material to add
  33442. */
  33443. addMaterial(newMaterial: Material): void;
  33444. /**
  33445. * Adds the given morph target to this scene
  33446. * @param newMorphTargetManager The morph target to add
  33447. */
  33448. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33449. /**
  33450. * Adds the given geometry to this scene
  33451. * @param newGeometry The geometry to add
  33452. */
  33453. addGeometry(newGeometry: Geometry): void;
  33454. /**
  33455. * Adds the given action manager to this scene
  33456. * @param newActionManager The action manager to add
  33457. */
  33458. addActionManager(newActionManager: AbstractActionManager): void;
  33459. /**
  33460. * Adds the given texture to this scene.
  33461. * @param newTexture The texture to add
  33462. */
  33463. addTexture(newTexture: BaseTexture): void;
  33464. /**
  33465. * Switch active camera
  33466. * @param newCamera defines the new active camera
  33467. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33468. */
  33469. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33470. /**
  33471. * sets the active camera of the scene using its ID
  33472. * @param id defines the camera's ID
  33473. * @return the new active camera or null if none found.
  33474. */
  33475. setActiveCameraByID(id: string): Nullable<Camera>;
  33476. /**
  33477. * sets the active camera of the scene using its name
  33478. * @param name defines the camera's name
  33479. * @returns the new active camera or null if none found.
  33480. */
  33481. setActiveCameraByName(name: string): Nullable<Camera>;
  33482. /**
  33483. * get an animation group using its name
  33484. * @param name defines the material's name
  33485. * @return the animation group or null if none found.
  33486. */
  33487. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33488. /**
  33489. * Get a material using its unique id
  33490. * @param uniqueId defines the material's unique id
  33491. * @return the material or null if none found.
  33492. */
  33493. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33494. /**
  33495. * get a material using its id
  33496. * @param id defines the material's ID
  33497. * @return the material or null if none found.
  33498. */
  33499. getMaterialByID(id: string): Nullable<Material>;
  33500. /**
  33501. * Gets a material using its name
  33502. * @param name defines the material's name
  33503. * @return the material or null if none found.
  33504. */
  33505. getMaterialByName(name: string): Nullable<Material>;
  33506. /**
  33507. * Gets a camera using its id
  33508. * @param id defines the id to look for
  33509. * @returns the camera or null if not found
  33510. */
  33511. getCameraByID(id: string): Nullable<Camera>;
  33512. /**
  33513. * Gets a camera using its unique id
  33514. * @param uniqueId defines the unique id to look for
  33515. * @returns the camera or null if not found
  33516. */
  33517. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33518. /**
  33519. * Gets a camera using its name
  33520. * @param name defines the camera's name
  33521. * @return the camera or null if none found.
  33522. */
  33523. getCameraByName(name: string): Nullable<Camera>;
  33524. /**
  33525. * Gets a bone using its id
  33526. * @param id defines the bone's id
  33527. * @return the bone or null if not found
  33528. */
  33529. getBoneByID(id: string): Nullable<Bone>;
  33530. /**
  33531. * Gets a bone using its id
  33532. * @param name defines the bone's name
  33533. * @return the bone or null if not found
  33534. */
  33535. getBoneByName(name: string): Nullable<Bone>;
  33536. /**
  33537. * Gets a light node using its name
  33538. * @param name defines the the light's name
  33539. * @return the light or null if none found.
  33540. */
  33541. getLightByName(name: string): Nullable<Light>;
  33542. /**
  33543. * Gets a light node using its id
  33544. * @param id defines the light's id
  33545. * @return the light or null if none found.
  33546. */
  33547. getLightByID(id: string): Nullable<Light>;
  33548. /**
  33549. * Gets a light node using its scene-generated unique ID
  33550. * @param uniqueId defines the light's unique id
  33551. * @return the light or null if none found.
  33552. */
  33553. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33554. /**
  33555. * Gets a particle system by id
  33556. * @param id defines the particle system id
  33557. * @return the corresponding system or null if none found
  33558. */
  33559. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33560. /**
  33561. * Gets a geometry using its ID
  33562. * @param id defines the geometry's id
  33563. * @return the geometry or null if none found.
  33564. */
  33565. getGeometryByID(id: string): Nullable<Geometry>;
  33566. private _getGeometryByUniqueID;
  33567. /**
  33568. * Add a new geometry to this scene
  33569. * @param geometry defines the geometry to be added to the scene.
  33570. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33571. * @return a boolean defining if the geometry was added or not
  33572. */
  33573. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33574. /**
  33575. * Removes an existing geometry
  33576. * @param geometry defines the geometry to be removed from the scene
  33577. * @return a boolean defining if the geometry was removed or not
  33578. */
  33579. removeGeometry(geometry: Geometry): boolean;
  33580. /**
  33581. * Gets the list of geometries attached to the scene
  33582. * @returns an array of Geometry
  33583. */
  33584. getGeometries(): Geometry[];
  33585. /**
  33586. * Gets the first added mesh found of a given ID
  33587. * @param id defines the id to search for
  33588. * @return the mesh found or null if not found at all
  33589. */
  33590. getMeshByID(id: string): Nullable<AbstractMesh>;
  33591. /**
  33592. * Gets a list of meshes using their id
  33593. * @param id defines the id to search for
  33594. * @returns a list of meshes
  33595. */
  33596. getMeshesByID(id: string): Array<AbstractMesh>;
  33597. /**
  33598. * Gets the first added transform node found of a given ID
  33599. * @param id defines the id to search for
  33600. * @return the found transform node or null if not found at all.
  33601. */
  33602. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33603. /**
  33604. * Gets a transform node with its auto-generated unique id
  33605. * @param uniqueId efines the unique id to search for
  33606. * @return the found transform node or null if not found at all.
  33607. */
  33608. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33609. /**
  33610. * Gets a list of transform nodes using their id
  33611. * @param id defines the id to search for
  33612. * @returns a list of transform nodes
  33613. */
  33614. getTransformNodesByID(id: string): Array<TransformNode>;
  33615. /**
  33616. * Gets a mesh with its auto-generated unique id
  33617. * @param uniqueId defines the unique id to search for
  33618. * @return the found mesh or null if not found at all.
  33619. */
  33620. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33621. /**
  33622. * Gets a the last added mesh using a given id
  33623. * @param id defines the id to search for
  33624. * @return the found mesh or null if not found at all.
  33625. */
  33626. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33627. /**
  33628. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33629. * @param id defines the id to search for
  33630. * @return the found node or null if not found at all
  33631. */
  33632. getLastEntryByID(id: string): Nullable<Node>;
  33633. /**
  33634. * Gets a node (Mesh, Camera, Light) using a given id
  33635. * @param id defines the id to search for
  33636. * @return the found node or null if not found at all
  33637. */
  33638. getNodeByID(id: string): Nullable<Node>;
  33639. /**
  33640. * Gets a node (Mesh, Camera, Light) using a given name
  33641. * @param name defines the name to search for
  33642. * @return the found node or null if not found at all.
  33643. */
  33644. getNodeByName(name: string): Nullable<Node>;
  33645. /**
  33646. * Gets a mesh using a given name
  33647. * @param name defines the name to search for
  33648. * @return the found mesh or null if not found at all.
  33649. */
  33650. getMeshByName(name: string): Nullable<AbstractMesh>;
  33651. /**
  33652. * Gets a transform node using a given name
  33653. * @param name defines the name to search for
  33654. * @return the found transform node or null if not found at all.
  33655. */
  33656. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33657. /**
  33658. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33659. * @param id defines the id to search for
  33660. * @return the found skeleton or null if not found at all.
  33661. */
  33662. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33663. /**
  33664. * Gets a skeleton using a given auto generated unique id
  33665. * @param uniqueId defines the unique id to search for
  33666. * @return the found skeleton or null if not found at all.
  33667. */
  33668. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33669. /**
  33670. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33671. * @param id defines the id to search for
  33672. * @return the found skeleton or null if not found at all.
  33673. */
  33674. getSkeletonById(id: string): Nullable<Skeleton>;
  33675. /**
  33676. * Gets a skeleton using a given name
  33677. * @param name defines the name to search for
  33678. * @return the found skeleton or null if not found at all.
  33679. */
  33680. getSkeletonByName(name: string): Nullable<Skeleton>;
  33681. /**
  33682. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33683. * @param id defines the id to search for
  33684. * @return the found morph target manager or null if not found at all.
  33685. */
  33686. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33687. /**
  33688. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33689. * @param id defines the id to search for
  33690. * @return the found morph target or null if not found at all.
  33691. */
  33692. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33693. /**
  33694. * Gets a boolean indicating if the given mesh is active
  33695. * @param mesh defines the mesh to look for
  33696. * @returns true if the mesh is in the active list
  33697. */
  33698. isActiveMesh(mesh: AbstractMesh): boolean;
  33699. /**
  33700. * Return a unique id as a string which can serve as an identifier for the scene
  33701. */
  33702. readonly uid: string;
  33703. /**
  33704. * Add an externaly attached data from its key.
  33705. * This method call will fail and return false, if such key already exists.
  33706. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33707. * @param key the unique key that identifies the data
  33708. * @param data the data object to associate to the key for this Engine instance
  33709. * @return true if no such key were already present and the data was added successfully, false otherwise
  33710. */
  33711. addExternalData<T>(key: string, data: T): boolean;
  33712. /**
  33713. * Get an externaly attached data from its key
  33714. * @param key the unique key that identifies the data
  33715. * @return the associated data, if present (can be null), or undefined if not present
  33716. */
  33717. getExternalData<T>(key: string): Nullable<T>;
  33718. /**
  33719. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33720. * @param key the unique key that identifies the data
  33721. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33722. * @return the associated data, can be null if the factory returned null.
  33723. */
  33724. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33725. /**
  33726. * Remove an externaly attached data from the Engine instance
  33727. * @param key the unique key that identifies the data
  33728. * @return true if the data was successfully removed, false if it doesn't exist
  33729. */
  33730. removeExternalData(key: string): boolean;
  33731. private _evaluateSubMesh;
  33732. /**
  33733. * Clear the processed materials smart array preventing retention point in material dispose.
  33734. */
  33735. freeProcessedMaterials(): void;
  33736. private _preventFreeActiveMeshesAndRenderingGroups;
  33737. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33738. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33739. * when disposing several meshes in a row or a hierarchy of meshes.
  33740. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33741. */
  33742. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33743. /**
  33744. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33745. */
  33746. freeActiveMeshes(): void;
  33747. /**
  33748. * Clear the info related to rendering groups preventing retention points during dispose.
  33749. */
  33750. freeRenderingGroups(): void;
  33751. /** @hidden */
  33752. _isInIntermediateRendering(): boolean;
  33753. /**
  33754. * Lambda returning the list of potentially active meshes.
  33755. */
  33756. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33757. /**
  33758. * Lambda returning the list of potentially active sub meshes.
  33759. */
  33760. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33761. /**
  33762. * Lambda returning the list of potentially intersecting sub meshes.
  33763. */
  33764. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33765. /**
  33766. * Lambda returning the list of potentially colliding sub meshes.
  33767. */
  33768. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33769. private _activeMeshesFrozen;
  33770. /**
  33771. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33772. * @returns the current scene
  33773. */
  33774. freezeActiveMeshes(): Scene;
  33775. /**
  33776. * Use this function to restart evaluating active meshes on every frame
  33777. * @returns the current scene
  33778. */
  33779. unfreezeActiveMeshes(): Scene;
  33780. private _evaluateActiveMeshes;
  33781. private _activeMesh;
  33782. /**
  33783. * Update the transform matrix to update from the current active camera
  33784. * @param force defines a boolean used to force the update even if cache is up to date
  33785. */
  33786. updateTransformMatrix(force?: boolean): void;
  33787. /**
  33788. * 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)
  33789. * @param alternateCamera defines the camera to use
  33790. */
  33791. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33792. /** @hidden */
  33793. _allowPostProcessClearColor: boolean;
  33794. private _renderForCamera;
  33795. private _processSubCameras;
  33796. private _checkIntersections;
  33797. /** @hidden */
  33798. _advancePhysicsEngineStep(step: number): void;
  33799. /**
  33800. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33801. */
  33802. getDeterministicFrameTime: () => number;
  33803. /** @hidden */
  33804. _animate(): void;
  33805. /**
  33806. * Render the scene
  33807. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33808. */
  33809. render(updateCameras?: boolean): void;
  33810. /**
  33811. * Freeze all materials
  33812. * A frozen material will not be updatable but should be faster to render
  33813. */
  33814. freezeMaterials(): void;
  33815. /**
  33816. * Unfreeze all materials
  33817. * A frozen material will not be updatable but should be faster to render
  33818. */
  33819. unfreezeMaterials(): void;
  33820. /**
  33821. * Releases all held ressources
  33822. */
  33823. dispose(): void;
  33824. /**
  33825. * Gets if the scene is already disposed
  33826. */
  33827. readonly isDisposed: boolean;
  33828. /**
  33829. * Call this function to reduce memory footprint of the scene.
  33830. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33831. */
  33832. clearCachedVertexData(): void;
  33833. /**
  33834. * This function will remove the local cached buffer data from texture.
  33835. * It will save memory but will prevent the texture from being rebuilt
  33836. */
  33837. cleanCachedTextureBuffer(): void;
  33838. /**
  33839. * Get the world extend vectors with an optional filter
  33840. *
  33841. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33842. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33843. */
  33844. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33845. min: Vector3;
  33846. max: Vector3;
  33847. };
  33848. /**
  33849. * Creates a ray that can be used to pick in the scene
  33850. * @param x defines the x coordinate of the origin (on-screen)
  33851. * @param y defines the y coordinate of the origin (on-screen)
  33852. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33853. * @param camera defines the camera to use for the picking
  33854. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33855. * @returns a Ray
  33856. */
  33857. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33858. /**
  33859. * Creates a ray that can be used to pick in the scene
  33860. * @param x defines the x coordinate of the origin (on-screen)
  33861. * @param y defines the y coordinate of the origin (on-screen)
  33862. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33863. * @param result defines the ray where to store the picking ray
  33864. * @param camera defines the camera to use for the picking
  33865. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33866. * @returns the current scene
  33867. */
  33868. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33869. /**
  33870. * Creates a ray that can be used to pick in the scene
  33871. * @param x defines the x coordinate of the origin (on-screen)
  33872. * @param y defines the y coordinate of the origin (on-screen)
  33873. * @param camera defines the camera to use for the picking
  33874. * @returns a Ray
  33875. */
  33876. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33877. /**
  33878. * Creates a ray that can be used to pick in the scene
  33879. * @param x defines the x coordinate of the origin (on-screen)
  33880. * @param y defines the y coordinate of the origin (on-screen)
  33881. * @param result defines the ray where to store the picking ray
  33882. * @param camera defines the camera to use for the picking
  33883. * @returns the current scene
  33884. */
  33885. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33886. /** Launch a ray to try to pick a mesh in the scene
  33887. * @param x position on screen
  33888. * @param y position on screen
  33889. * @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
  33890. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33891. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33892. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33893. * @returns a PickingInfo
  33894. */
  33895. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33896. /** Use the given ray to pick a mesh in the scene
  33897. * @param ray The ray to use to pick meshes
  33898. * @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
  33899. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33900. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33901. * @returns a PickingInfo
  33902. */
  33903. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33904. /**
  33905. * Launch a ray to try to pick a mesh in the scene
  33906. * @param x X position on screen
  33907. * @param y Y position on screen
  33908. * @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
  33909. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33910. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33911. * @returns an array of PickingInfo
  33912. */
  33913. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33914. /**
  33915. * Launch a ray to try to pick a mesh in the scene
  33916. * @param ray Ray to use
  33917. * @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
  33918. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33919. * @returns an array of PickingInfo
  33920. */
  33921. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33922. /**
  33923. * Force the value of meshUnderPointer
  33924. * @param mesh defines the mesh to use
  33925. */
  33926. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33927. /**
  33928. * Gets the mesh under the pointer
  33929. * @returns a Mesh or null if no mesh is under the pointer
  33930. */
  33931. getPointerOverMesh(): Nullable<AbstractMesh>;
  33932. /** @hidden */
  33933. _rebuildGeometries(): void;
  33934. /** @hidden */
  33935. _rebuildTextures(): void;
  33936. private _getByTags;
  33937. /**
  33938. * Get a list of meshes by tags
  33939. * @param tagsQuery defines the tags query to use
  33940. * @param forEach defines a predicate used to filter results
  33941. * @returns an array of Mesh
  33942. */
  33943. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33944. /**
  33945. * Get a list of cameras by tags
  33946. * @param tagsQuery defines the tags query to use
  33947. * @param forEach defines a predicate used to filter results
  33948. * @returns an array of Camera
  33949. */
  33950. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33951. /**
  33952. * Get a list of lights by tags
  33953. * @param tagsQuery defines the tags query to use
  33954. * @param forEach defines a predicate used to filter results
  33955. * @returns an array of Light
  33956. */
  33957. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33958. /**
  33959. * Get a list of materials by tags
  33960. * @param tagsQuery defines the tags query to use
  33961. * @param forEach defines a predicate used to filter results
  33962. * @returns an array of Material
  33963. */
  33964. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33965. /**
  33966. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33967. * This allowed control for front to back rendering or reversly depending of the special needs.
  33968. *
  33969. * @param renderingGroupId The rendering group id corresponding to its index
  33970. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33971. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33972. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33973. */
  33974. 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;
  33975. /**
  33976. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33977. *
  33978. * @param renderingGroupId The rendering group id corresponding to its index
  33979. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33980. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33981. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33982. */
  33983. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33984. /**
  33985. * Gets the current auto clear configuration for one rendering group of the rendering
  33986. * manager.
  33987. * @param index the rendering group index to get the information for
  33988. * @returns The auto clear setup for the requested rendering group
  33989. */
  33990. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33991. private _blockMaterialDirtyMechanism;
  33992. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33993. blockMaterialDirtyMechanism: boolean;
  33994. /**
  33995. * Will flag all materials as dirty to trigger new shader compilation
  33996. * @param flag defines the flag used to specify which material part must be marked as dirty
  33997. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33998. */
  33999. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34000. /** @hidden */
  34001. _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;
  34002. /** @hidden */
  34003. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34004. }
  34005. }
  34006. declare module "babylonjs/assetContainer" {
  34007. import { AbstractScene } from "babylonjs/abstractScene";
  34008. import { Scene } from "babylonjs/scene";
  34009. import { Mesh } from "babylonjs/Meshes/mesh";
  34010. /**
  34011. * Set of assets to keep when moving a scene into an asset container.
  34012. */
  34013. export class KeepAssets extends AbstractScene {
  34014. }
  34015. /**
  34016. * Container with a set of assets that can be added or removed from a scene.
  34017. */
  34018. export class AssetContainer extends AbstractScene {
  34019. /**
  34020. * The scene the AssetContainer belongs to.
  34021. */
  34022. scene: Scene;
  34023. /**
  34024. * Instantiates an AssetContainer.
  34025. * @param scene The scene the AssetContainer belongs to.
  34026. */
  34027. constructor(scene: Scene);
  34028. /**
  34029. * Adds all the assets from the container to the scene.
  34030. */
  34031. addAllToScene(): void;
  34032. /**
  34033. * Removes all the assets in the container from the scene
  34034. */
  34035. removeAllFromScene(): void;
  34036. /**
  34037. * Disposes all the assets in the container
  34038. */
  34039. dispose(): void;
  34040. private _moveAssets;
  34041. /**
  34042. * Removes all the assets contained in the scene and adds them to the container.
  34043. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34044. */
  34045. moveAllFromScene(keepAssets?: KeepAssets): void;
  34046. /**
  34047. * 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.
  34048. * @returns the root mesh
  34049. */
  34050. createRootMesh(): Mesh;
  34051. }
  34052. }
  34053. declare module "babylonjs/abstractScene" {
  34054. import { Scene } from "babylonjs/scene";
  34055. import { Nullable } from "babylonjs/types";
  34056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34057. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34058. import { Geometry } from "babylonjs/Meshes/geometry";
  34059. import { Skeleton } from "babylonjs/Bones/skeleton";
  34060. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34061. import { AssetContainer } from "babylonjs/assetContainer";
  34062. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34063. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34064. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34065. import { Material } from "babylonjs/Materials/material";
  34066. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34067. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34068. import { Camera } from "babylonjs/Cameras/camera";
  34069. import { Light } from "babylonjs/Lights/light";
  34070. import { Node } from "babylonjs/node";
  34071. import { Animation } from "babylonjs/Animations/animation";
  34072. /**
  34073. * Defines how the parser contract is defined.
  34074. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34075. */
  34076. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34077. /**
  34078. * Defines how the individual parser contract is defined.
  34079. * These parser can parse an individual asset
  34080. */
  34081. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34082. /**
  34083. * Base class of the scene acting as a container for the different elements composing a scene.
  34084. * This class is dynamically extended by the different components of the scene increasing
  34085. * flexibility and reducing coupling
  34086. */
  34087. export abstract class AbstractScene {
  34088. /**
  34089. * Stores the list of available parsers in the application.
  34090. */
  34091. private static _BabylonFileParsers;
  34092. /**
  34093. * Stores the list of available individual parsers in the application.
  34094. */
  34095. private static _IndividualBabylonFileParsers;
  34096. /**
  34097. * Adds a parser in the list of available ones
  34098. * @param name Defines the name of the parser
  34099. * @param parser Defines the parser to add
  34100. */
  34101. static AddParser(name: string, parser: BabylonFileParser): void;
  34102. /**
  34103. * Gets a general parser from the list of avaialble ones
  34104. * @param name Defines the name of the parser
  34105. * @returns the requested parser or null
  34106. */
  34107. static GetParser(name: string): Nullable<BabylonFileParser>;
  34108. /**
  34109. * Adds n individual parser in the list of available ones
  34110. * @param name Defines the name of the parser
  34111. * @param parser Defines the parser to add
  34112. */
  34113. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34114. /**
  34115. * Gets an individual parser from the list of avaialble ones
  34116. * @param name Defines the name of the parser
  34117. * @returns the requested parser or null
  34118. */
  34119. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34120. /**
  34121. * Parser json data and populate both a scene and its associated container object
  34122. * @param jsonData Defines the data to parse
  34123. * @param scene Defines the scene to parse the data for
  34124. * @param container Defines the container attached to the parsing sequence
  34125. * @param rootUrl Defines the root url of the data
  34126. */
  34127. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34128. /**
  34129. * Gets the list of root nodes (ie. nodes with no parent)
  34130. */
  34131. rootNodes: Node[];
  34132. /** All of the cameras added to this scene
  34133. * @see http://doc.babylonjs.com/babylon101/cameras
  34134. */
  34135. cameras: Camera[];
  34136. /**
  34137. * All of the lights added to this scene
  34138. * @see http://doc.babylonjs.com/babylon101/lights
  34139. */
  34140. lights: Light[];
  34141. /**
  34142. * All of the (abstract) meshes added to this scene
  34143. */
  34144. meshes: AbstractMesh[];
  34145. /**
  34146. * The list of skeletons added to the scene
  34147. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34148. */
  34149. skeletons: Skeleton[];
  34150. /**
  34151. * All of the particle systems added to this scene
  34152. * @see http://doc.babylonjs.com/babylon101/particles
  34153. */
  34154. particleSystems: IParticleSystem[];
  34155. /**
  34156. * Gets a list of Animations associated with the scene
  34157. */
  34158. animations: Animation[];
  34159. /**
  34160. * All of the animation groups added to this scene
  34161. * @see http://doc.babylonjs.com/how_to/group
  34162. */
  34163. animationGroups: AnimationGroup[];
  34164. /**
  34165. * All of the multi-materials added to this scene
  34166. * @see http://doc.babylonjs.com/how_to/multi_materials
  34167. */
  34168. multiMaterials: MultiMaterial[];
  34169. /**
  34170. * All of the materials added to this scene
  34171. * In the context of a Scene, it is not supposed to be modified manually.
  34172. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34173. * Note also that the order of the Material wihin the array is not significant and might change.
  34174. * @see http://doc.babylonjs.com/babylon101/materials
  34175. */
  34176. materials: Material[];
  34177. /**
  34178. * The list of morph target managers added to the scene
  34179. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34180. */
  34181. morphTargetManagers: MorphTargetManager[];
  34182. /**
  34183. * The list of geometries used in the scene.
  34184. */
  34185. geometries: Geometry[];
  34186. /**
  34187. * All of the tranform nodes added to this scene
  34188. * In the context of a Scene, it is not supposed to be modified manually.
  34189. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34190. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34191. * @see http://doc.babylonjs.com/how_to/transformnode
  34192. */
  34193. transformNodes: TransformNode[];
  34194. /**
  34195. * ActionManagers available on the scene.
  34196. */
  34197. actionManagers: AbstractActionManager[];
  34198. /**
  34199. * Textures to keep.
  34200. */
  34201. textures: BaseTexture[];
  34202. }
  34203. }
  34204. declare module "babylonjs/Audio/sound" {
  34205. import { Observable } from "babylonjs/Misc/observable";
  34206. import { Vector3 } from "babylonjs/Maths/math";
  34207. import { Nullable } from "babylonjs/types";
  34208. import { Scene } from "babylonjs/scene";
  34209. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34210. /**
  34211. * Defines a sound that can be played in the application.
  34212. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34214. */
  34215. export class Sound {
  34216. /**
  34217. * The name of the sound in the scene.
  34218. */
  34219. name: string;
  34220. /**
  34221. * Does the sound autoplay once loaded.
  34222. */
  34223. autoplay: boolean;
  34224. /**
  34225. * Does the sound loop after it finishes playing once.
  34226. */
  34227. loop: boolean;
  34228. /**
  34229. * Does the sound use a custom attenuation curve to simulate the falloff
  34230. * happening when the source gets further away from the camera.
  34231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34232. */
  34233. useCustomAttenuation: boolean;
  34234. /**
  34235. * The sound track id this sound belongs to.
  34236. */
  34237. soundTrackId: number;
  34238. /**
  34239. * Is this sound currently played.
  34240. */
  34241. isPlaying: boolean;
  34242. /**
  34243. * Is this sound currently paused.
  34244. */
  34245. isPaused: boolean;
  34246. /**
  34247. * Does this sound enables spatial sound.
  34248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34249. */
  34250. spatialSound: boolean;
  34251. /**
  34252. * Define the reference distance the sound should be heard perfectly.
  34253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34254. */
  34255. refDistance: number;
  34256. /**
  34257. * Define the roll off factor of spatial sounds.
  34258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34259. */
  34260. rolloffFactor: number;
  34261. /**
  34262. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34264. */
  34265. maxDistance: number;
  34266. /**
  34267. * Define the distance attenuation model the sound will follow.
  34268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34269. */
  34270. distanceModel: string;
  34271. /**
  34272. * @hidden
  34273. * Back Compat
  34274. **/
  34275. onended: () => any;
  34276. /**
  34277. * Observable event when the current playing sound finishes.
  34278. */
  34279. onEndedObservable: Observable<Sound>;
  34280. private _panningModel;
  34281. private _playbackRate;
  34282. private _streaming;
  34283. private _startTime;
  34284. private _startOffset;
  34285. private _position;
  34286. /** @hidden */
  34287. _positionInEmitterSpace: boolean;
  34288. private _localDirection;
  34289. private _volume;
  34290. private _isReadyToPlay;
  34291. private _isDirectional;
  34292. private _readyToPlayCallback;
  34293. private _audioBuffer;
  34294. private _soundSource;
  34295. private _streamingSource;
  34296. private _soundPanner;
  34297. private _soundGain;
  34298. private _inputAudioNode;
  34299. private _outputAudioNode;
  34300. private _coneInnerAngle;
  34301. private _coneOuterAngle;
  34302. private _coneOuterGain;
  34303. private _scene;
  34304. private _connectedTransformNode;
  34305. private _customAttenuationFunction;
  34306. private _registerFunc;
  34307. private _isOutputConnected;
  34308. private _htmlAudioElement;
  34309. private _urlType;
  34310. /** @hidden */
  34311. static _SceneComponentInitialization: (scene: Scene) => void;
  34312. /**
  34313. * Create a sound and attach it to a scene
  34314. * @param name Name of your sound
  34315. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34316. * @param scene defines the scene the sound belongs to
  34317. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34318. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34319. */
  34320. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34321. /**
  34322. * Release the sound and its associated resources
  34323. */
  34324. dispose(): void;
  34325. /**
  34326. * Gets if the sounds is ready to be played or not.
  34327. * @returns true if ready, otherwise false
  34328. */
  34329. isReady(): boolean;
  34330. private _soundLoaded;
  34331. /**
  34332. * Sets the data of the sound from an audiobuffer
  34333. * @param audioBuffer The audioBuffer containing the data
  34334. */
  34335. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34336. /**
  34337. * Updates the current sounds options such as maxdistance, loop...
  34338. * @param options A JSON object containing values named as the object properties
  34339. */
  34340. updateOptions(options: any): void;
  34341. private _createSpatialParameters;
  34342. private _updateSpatialParameters;
  34343. /**
  34344. * Switch the panning model to HRTF:
  34345. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34347. */
  34348. switchPanningModelToHRTF(): void;
  34349. /**
  34350. * Switch the panning model to Equal Power:
  34351. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34353. */
  34354. switchPanningModelToEqualPower(): void;
  34355. private _switchPanningModel;
  34356. /**
  34357. * Connect this sound to a sound track audio node like gain...
  34358. * @param soundTrackAudioNode the sound track audio node to connect to
  34359. */
  34360. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34361. /**
  34362. * Transform this sound into a directional source
  34363. * @param coneInnerAngle Size of the inner cone in degree
  34364. * @param coneOuterAngle Size of the outer cone in degree
  34365. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34366. */
  34367. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34368. /**
  34369. * Gets or sets the inner angle for the directional cone.
  34370. */
  34371. /**
  34372. * Gets or sets the inner angle for the directional cone.
  34373. */
  34374. directionalConeInnerAngle: number;
  34375. /**
  34376. * Gets or sets the outer angle for the directional cone.
  34377. */
  34378. /**
  34379. * Gets or sets the outer angle for the directional cone.
  34380. */
  34381. directionalConeOuterAngle: number;
  34382. /**
  34383. * Sets the position of the emitter if spatial sound is enabled
  34384. * @param newPosition Defines the new posisiton
  34385. */
  34386. setPosition(newPosition: Vector3): void;
  34387. /**
  34388. * Sets the local direction of the emitter if spatial sound is enabled
  34389. * @param newLocalDirection Defines the new local direction
  34390. */
  34391. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34392. private _updateDirection;
  34393. /** @hidden */
  34394. updateDistanceFromListener(): void;
  34395. /**
  34396. * Sets a new custom attenuation function for the sound.
  34397. * @param callback Defines the function used for the attenuation
  34398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34399. */
  34400. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34401. /**
  34402. * Play the sound
  34403. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34404. * @param offset (optional) Start the sound setting it at a specific time
  34405. */
  34406. play(time?: number, offset?: number): void;
  34407. private _onended;
  34408. /**
  34409. * Stop the sound
  34410. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34411. */
  34412. stop(time?: number): void;
  34413. /**
  34414. * Put the sound in pause
  34415. */
  34416. pause(): void;
  34417. /**
  34418. * Sets a dedicated volume for this sounds
  34419. * @param newVolume Define the new volume of the sound
  34420. * @param time Define in how long the sound should be at this value
  34421. */
  34422. setVolume(newVolume: number, time?: number): void;
  34423. /**
  34424. * Set the sound play back rate
  34425. * @param newPlaybackRate Define the playback rate the sound should be played at
  34426. */
  34427. setPlaybackRate(newPlaybackRate: number): void;
  34428. /**
  34429. * Gets the volume of the sound.
  34430. * @returns the volume of the sound
  34431. */
  34432. getVolume(): number;
  34433. /**
  34434. * Attach the sound to a dedicated mesh
  34435. * @param transformNode The transform node to connect the sound with
  34436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34437. */
  34438. attachToMesh(transformNode: TransformNode): void;
  34439. /**
  34440. * Detach the sound from the previously attached mesh
  34441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34442. */
  34443. detachFromMesh(): void;
  34444. private _onRegisterAfterWorldMatrixUpdate;
  34445. /**
  34446. * Clone the current sound in the scene.
  34447. * @returns the new sound clone
  34448. */
  34449. clone(): Nullable<Sound>;
  34450. /**
  34451. * Gets the current underlying audio buffer containing the data
  34452. * @returns the audio buffer
  34453. */
  34454. getAudioBuffer(): Nullable<AudioBuffer>;
  34455. /**
  34456. * Serializes the Sound in a JSON representation
  34457. * @returns the JSON representation of the sound
  34458. */
  34459. serialize(): any;
  34460. /**
  34461. * Parse a JSON representation of a sound to innstantiate in a given scene
  34462. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34463. * @param scene Define the scene the new parsed sound should be created in
  34464. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34465. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34466. * @returns the newly parsed sound
  34467. */
  34468. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34469. }
  34470. }
  34471. declare module "babylonjs/Actions/directAudioActions" {
  34472. import { Action } from "babylonjs/Actions/action";
  34473. import { Condition } from "babylonjs/Actions/condition";
  34474. import { Sound } from "babylonjs/Audio/sound";
  34475. /**
  34476. * This defines an action helpful to play a defined sound on a triggered action.
  34477. */
  34478. export class PlaySoundAction extends Action {
  34479. private _sound;
  34480. /**
  34481. * Instantiate the action
  34482. * @param triggerOptions defines the trigger options
  34483. * @param sound defines the sound to play
  34484. * @param condition defines the trigger related conditions
  34485. */
  34486. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34487. /** @hidden */
  34488. _prepare(): void;
  34489. /**
  34490. * Execute the action and play the sound.
  34491. */
  34492. execute(): void;
  34493. /**
  34494. * Serializes the actions and its related information.
  34495. * @param parent defines the object to serialize in
  34496. * @returns the serialized object
  34497. */
  34498. serialize(parent: any): any;
  34499. }
  34500. /**
  34501. * This defines an action helpful to stop a defined sound on a triggered action.
  34502. */
  34503. export class StopSoundAction extends Action {
  34504. private _sound;
  34505. /**
  34506. * Instantiate the action
  34507. * @param triggerOptions defines the trigger options
  34508. * @param sound defines the sound to stop
  34509. * @param condition defines the trigger related conditions
  34510. */
  34511. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34512. /** @hidden */
  34513. _prepare(): void;
  34514. /**
  34515. * Execute the action and stop the sound.
  34516. */
  34517. execute(): void;
  34518. /**
  34519. * Serializes the actions and its related information.
  34520. * @param parent defines the object to serialize in
  34521. * @returns the serialized object
  34522. */
  34523. serialize(parent: any): any;
  34524. }
  34525. }
  34526. declare module "babylonjs/Actions/interpolateValueAction" {
  34527. import { Action } from "babylonjs/Actions/action";
  34528. import { Condition } from "babylonjs/Actions/condition";
  34529. import { Observable } from "babylonjs/Misc/observable";
  34530. /**
  34531. * This defines an action responsible to change the value of a property
  34532. * by interpolating between its current value and the newly set one once triggered.
  34533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34534. */
  34535. export class InterpolateValueAction extends Action {
  34536. /**
  34537. * Defines the path of the property where the value should be interpolated
  34538. */
  34539. propertyPath: string;
  34540. /**
  34541. * Defines the target value at the end of the interpolation.
  34542. */
  34543. value: any;
  34544. /**
  34545. * Defines the time it will take for the property to interpolate to the value.
  34546. */
  34547. duration: number;
  34548. /**
  34549. * Defines if the other scene animations should be stopped when the action has been triggered
  34550. */
  34551. stopOtherAnimations?: boolean;
  34552. /**
  34553. * Defines a callback raised once the interpolation animation has been done.
  34554. */
  34555. onInterpolationDone?: () => void;
  34556. /**
  34557. * Observable triggered once the interpolation animation has been done.
  34558. */
  34559. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34560. private _target;
  34561. private _effectiveTarget;
  34562. private _property;
  34563. /**
  34564. * Instantiate the action
  34565. * @param triggerOptions defines the trigger options
  34566. * @param target defines the object containing the value to interpolate
  34567. * @param propertyPath defines the path to the property in the target object
  34568. * @param value defines the target value at the end of the interpolation
  34569. * @param duration deines the time it will take for the property to interpolate to the value.
  34570. * @param condition defines the trigger related conditions
  34571. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34572. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34573. */
  34574. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34575. /** @hidden */
  34576. _prepare(): void;
  34577. /**
  34578. * Execute the action starts the value interpolation.
  34579. */
  34580. execute(): void;
  34581. /**
  34582. * Serializes the actions and its related information.
  34583. * @param parent defines the object to serialize in
  34584. * @returns the serialized object
  34585. */
  34586. serialize(parent: any): any;
  34587. }
  34588. }
  34589. declare module "babylonjs/Actions/index" {
  34590. export * from "babylonjs/Actions/action";
  34591. export * from "babylonjs/Actions/actionEvent";
  34592. export * from "babylonjs/Actions/actionManager";
  34593. export * from "babylonjs/Actions/condition";
  34594. export * from "babylonjs/Actions/directActions";
  34595. export * from "babylonjs/Actions/directAudioActions";
  34596. export * from "babylonjs/Actions/interpolateValueAction";
  34597. }
  34598. declare module "babylonjs/Animations/index" {
  34599. export * from "babylonjs/Animations/animatable";
  34600. export * from "babylonjs/Animations/animation";
  34601. export * from "babylonjs/Animations/animationGroup";
  34602. export * from "babylonjs/Animations/animationPropertiesOverride";
  34603. export * from "babylonjs/Animations/easing";
  34604. export * from "babylonjs/Animations/runtimeAnimation";
  34605. export * from "babylonjs/Animations/animationEvent";
  34606. export * from "babylonjs/Animations/animationGroup";
  34607. export * from "babylonjs/Animations/animationKey";
  34608. export * from "babylonjs/Animations/animationRange";
  34609. }
  34610. declare module "babylonjs/Audio/soundTrack" {
  34611. import { Sound } from "babylonjs/Audio/sound";
  34612. import { Analyser } from "babylonjs/Audio/analyser";
  34613. import { Scene } from "babylonjs/scene";
  34614. /**
  34615. * Options allowed during the creation of a sound track.
  34616. */
  34617. export interface ISoundTrackOptions {
  34618. /**
  34619. * The volume the sound track should take during creation
  34620. */
  34621. volume?: number;
  34622. /**
  34623. * Define if the sound track is the main sound track of the scene
  34624. */
  34625. mainTrack?: boolean;
  34626. }
  34627. /**
  34628. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34629. * It will be also used in a future release to apply effects on a specific track.
  34630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34631. */
  34632. export class SoundTrack {
  34633. /**
  34634. * The unique identifier of the sound track in the scene.
  34635. */
  34636. id: number;
  34637. /**
  34638. * The list of sounds included in the sound track.
  34639. */
  34640. soundCollection: Array<Sound>;
  34641. private _outputAudioNode;
  34642. private _scene;
  34643. private _isMainTrack;
  34644. private _connectedAnalyser;
  34645. private _options;
  34646. private _isInitialized;
  34647. /**
  34648. * Creates a new sound track.
  34649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34650. * @param scene Define the scene the sound track belongs to
  34651. * @param options
  34652. */
  34653. constructor(scene: Scene, options?: ISoundTrackOptions);
  34654. private _initializeSoundTrackAudioGraph;
  34655. /**
  34656. * Release the sound track and its associated resources
  34657. */
  34658. dispose(): void;
  34659. /**
  34660. * Adds a sound to this sound track
  34661. * @param sound define the cound to add
  34662. * @ignoreNaming
  34663. */
  34664. AddSound(sound: Sound): void;
  34665. /**
  34666. * Removes a sound to this sound track
  34667. * @param sound define the cound to remove
  34668. * @ignoreNaming
  34669. */
  34670. RemoveSound(sound: Sound): void;
  34671. /**
  34672. * Set a global volume for the full sound track.
  34673. * @param newVolume Define the new volume of the sound track
  34674. */
  34675. setVolume(newVolume: number): void;
  34676. /**
  34677. * Switch the panning model to HRTF:
  34678. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34680. */
  34681. switchPanningModelToHRTF(): void;
  34682. /**
  34683. * Switch the panning model to Equal Power:
  34684. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34686. */
  34687. switchPanningModelToEqualPower(): void;
  34688. /**
  34689. * Connect the sound track to an audio analyser allowing some amazing
  34690. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34692. * @param analyser The analyser to connect to the engine
  34693. */
  34694. connectToAnalyser(analyser: Analyser): void;
  34695. }
  34696. }
  34697. declare module "babylonjs/Audio/audioSceneComponent" {
  34698. import { Sound } from "babylonjs/Audio/sound";
  34699. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34700. import { Nullable } from "babylonjs/types";
  34701. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34702. import { Scene } from "babylonjs/scene";
  34703. import { AbstractScene } from "babylonjs/abstractScene";
  34704. module "babylonjs/abstractScene" {
  34705. interface AbstractScene {
  34706. /**
  34707. * The list of sounds used in the scene.
  34708. */
  34709. sounds: Nullable<Array<Sound>>;
  34710. }
  34711. }
  34712. module "babylonjs/scene" {
  34713. interface Scene {
  34714. /**
  34715. * @hidden
  34716. * Backing field
  34717. */
  34718. _mainSoundTrack: SoundTrack;
  34719. /**
  34720. * The main sound track played by the scene.
  34721. * It cotains your primary collection of sounds.
  34722. */
  34723. mainSoundTrack: SoundTrack;
  34724. /**
  34725. * The list of sound tracks added to the scene
  34726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34727. */
  34728. soundTracks: Nullable<Array<SoundTrack>>;
  34729. /**
  34730. * Gets a sound using a given name
  34731. * @param name defines the name to search for
  34732. * @return the found sound or null if not found at all.
  34733. */
  34734. getSoundByName(name: string): Nullable<Sound>;
  34735. /**
  34736. * Gets or sets if audio support is enabled
  34737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34738. */
  34739. audioEnabled: boolean;
  34740. /**
  34741. * Gets or sets if audio will be output to headphones
  34742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34743. */
  34744. headphone: boolean;
  34745. }
  34746. }
  34747. /**
  34748. * Defines the sound scene component responsible to manage any sounds
  34749. * in a given scene.
  34750. */
  34751. export class AudioSceneComponent implements ISceneSerializableComponent {
  34752. /**
  34753. * The component name helpfull to identify the component in the list of scene components.
  34754. */
  34755. readonly name: string;
  34756. /**
  34757. * The scene the component belongs to.
  34758. */
  34759. scene: Scene;
  34760. private _audioEnabled;
  34761. /**
  34762. * Gets whether audio is enabled or not.
  34763. * Please use related enable/disable method to switch state.
  34764. */
  34765. readonly audioEnabled: boolean;
  34766. private _headphone;
  34767. /**
  34768. * Gets whether audio is outputing to headphone or not.
  34769. * Please use the according Switch methods to change output.
  34770. */
  34771. readonly headphone: boolean;
  34772. /**
  34773. * Creates a new instance of the component for the given scene
  34774. * @param scene Defines the scene to register the component in
  34775. */
  34776. constructor(scene: Scene);
  34777. /**
  34778. * Registers the component in a given scene
  34779. */
  34780. register(): void;
  34781. /**
  34782. * Rebuilds the elements related to this component in case of
  34783. * context lost for instance.
  34784. */
  34785. rebuild(): void;
  34786. /**
  34787. * Serializes the component data to the specified json object
  34788. * @param serializationObject The object to serialize to
  34789. */
  34790. serialize(serializationObject: any): void;
  34791. /**
  34792. * Adds all the element from the container to the scene
  34793. * @param container the container holding the elements
  34794. */
  34795. addFromContainer(container: AbstractScene): void;
  34796. /**
  34797. * Removes all the elements in the container from the scene
  34798. * @param container contains the elements to remove
  34799. */
  34800. removeFromContainer(container: AbstractScene): void;
  34801. /**
  34802. * Disposes the component and the associated ressources.
  34803. */
  34804. dispose(): void;
  34805. /**
  34806. * Disables audio in the associated scene.
  34807. */
  34808. disableAudio(): void;
  34809. /**
  34810. * Enables audio in the associated scene.
  34811. */
  34812. enableAudio(): void;
  34813. /**
  34814. * Switch audio to headphone output.
  34815. */
  34816. switchAudioModeForHeadphones(): void;
  34817. /**
  34818. * Switch audio to normal speakers.
  34819. */
  34820. switchAudioModeForNormalSpeakers(): void;
  34821. private _afterRender;
  34822. }
  34823. }
  34824. declare module "babylonjs/Audio/weightedsound" {
  34825. import { Sound } from "babylonjs/Audio/sound";
  34826. /**
  34827. * Wraps one or more Sound objects and selects one with random weight for playback.
  34828. */
  34829. export class WeightedSound {
  34830. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34831. loop: boolean;
  34832. private _coneInnerAngle;
  34833. private _coneOuterAngle;
  34834. private _volume;
  34835. /** A Sound is currently playing. */
  34836. isPlaying: boolean;
  34837. /** A Sound is currently paused. */
  34838. isPaused: boolean;
  34839. private _sounds;
  34840. private _weights;
  34841. private _currentIndex?;
  34842. /**
  34843. * Creates a new WeightedSound from the list of sounds given.
  34844. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34845. * @param sounds Array of Sounds that will be selected from.
  34846. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34847. */
  34848. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34849. /**
  34850. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34851. */
  34852. /**
  34853. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34854. */
  34855. directionalConeInnerAngle: number;
  34856. /**
  34857. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34858. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34859. */
  34860. /**
  34861. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34862. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34863. */
  34864. directionalConeOuterAngle: number;
  34865. /**
  34866. * Playback volume.
  34867. */
  34868. /**
  34869. * Playback volume.
  34870. */
  34871. volume: number;
  34872. private _onended;
  34873. /**
  34874. * Suspend playback
  34875. */
  34876. pause(): void;
  34877. /**
  34878. * Stop playback
  34879. */
  34880. stop(): void;
  34881. /**
  34882. * Start playback.
  34883. * @param startOffset Position the clip head at a specific time in seconds.
  34884. */
  34885. play(startOffset?: number): void;
  34886. }
  34887. }
  34888. declare module "babylonjs/Audio/index" {
  34889. export * from "babylonjs/Audio/analyser";
  34890. export * from "babylonjs/Audio/audioEngine";
  34891. export * from "babylonjs/Audio/audioSceneComponent";
  34892. export * from "babylonjs/Audio/sound";
  34893. export * from "babylonjs/Audio/soundTrack";
  34894. export * from "babylonjs/Audio/weightedsound";
  34895. }
  34896. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34897. import { Behavior } from "babylonjs/Behaviors/behavior";
  34898. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34899. import { BackEase } from "babylonjs/Animations/easing";
  34900. /**
  34901. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34902. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34903. */
  34904. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34905. /**
  34906. * Gets the name of the behavior.
  34907. */
  34908. readonly name: string;
  34909. /**
  34910. * The easing function used by animations
  34911. */
  34912. static EasingFunction: BackEase;
  34913. /**
  34914. * The easing mode used by animations
  34915. */
  34916. static EasingMode: number;
  34917. /**
  34918. * The duration of the animation, in milliseconds
  34919. */
  34920. transitionDuration: number;
  34921. /**
  34922. * Length of the distance animated by the transition when lower radius is reached
  34923. */
  34924. lowerRadiusTransitionRange: number;
  34925. /**
  34926. * Length of the distance animated by the transition when upper radius is reached
  34927. */
  34928. upperRadiusTransitionRange: number;
  34929. private _autoTransitionRange;
  34930. /**
  34931. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34932. */
  34933. /**
  34934. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34935. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34936. */
  34937. autoTransitionRange: boolean;
  34938. private _attachedCamera;
  34939. private _onAfterCheckInputsObserver;
  34940. private _onMeshTargetChangedObserver;
  34941. /**
  34942. * Initializes the behavior.
  34943. */
  34944. init(): void;
  34945. /**
  34946. * Attaches the behavior to its arc rotate camera.
  34947. * @param camera Defines the camera to attach the behavior to
  34948. */
  34949. attach(camera: ArcRotateCamera): void;
  34950. /**
  34951. * Detaches the behavior from its current arc rotate camera.
  34952. */
  34953. detach(): void;
  34954. private _radiusIsAnimating;
  34955. private _radiusBounceTransition;
  34956. private _animatables;
  34957. private _cachedWheelPrecision;
  34958. /**
  34959. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34960. * @param radiusLimit The limit to check against.
  34961. * @return Bool to indicate if at limit.
  34962. */
  34963. private _isRadiusAtLimit;
  34964. /**
  34965. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34966. * @param radiusDelta The delta by which to animate to. Can be negative.
  34967. */
  34968. private _applyBoundRadiusAnimation;
  34969. /**
  34970. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34971. */
  34972. protected _clearAnimationLocks(): void;
  34973. /**
  34974. * Stops and removes all animations that have been applied to the camera
  34975. */
  34976. stopAllAnimations(): void;
  34977. }
  34978. }
  34979. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34980. import { Behavior } from "babylonjs/Behaviors/behavior";
  34981. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34982. import { ExponentialEase } from "babylonjs/Animations/easing";
  34983. import { Nullable } from "babylonjs/types";
  34984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34985. import { Vector3 } from "babylonjs/Maths/math";
  34986. /**
  34987. * 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.
  34988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34989. */
  34990. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34991. /**
  34992. * Gets the name of the behavior.
  34993. */
  34994. readonly name: string;
  34995. private _mode;
  34996. private _radiusScale;
  34997. private _positionScale;
  34998. private _defaultElevation;
  34999. private _elevationReturnTime;
  35000. private _elevationReturnWaitTime;
  35001. private _zoomStopsAnimation;
  35002. private _framingTime;
  35003. /**
  35004. * The easing function used by animations
  35005. */
  35006. static EasingFunction: ExponentialEase;
  35007. /**
  35008. * The easing mode used by animations
  35009. */
  35010. static EasingMode: number;
  35011. /**
  35012. * Sets the current mode used by the behavior
  35013. */
  35014. /**
  35015. * Gets current mode used by the behavior.
  35016. */
  35017. mode: number;
  35018. /**
  35019. * Sets the scale applied to the radius (1 by default)
  35020. */
  35021. /**
  35022. * Gets the scale applied to the radius
  35023. */
  35024. radiusScale: number;
  35025. /**
  35026. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35027. */
  35028. /**
  35029. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35030. */
  35031. positionScale: number;
  35032. /**
  35033. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35034. * behaviour is triggered, in radians.
  35035. */
  35036. /**
  35037. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35038. * behaviour is triggered, in radians.
  35039. */
  35040. defaultElevation: number;
  35041. /**
  35042. * Sets the time (in milliseconds) taken to return to the default beta position.
  35043. * Negative value indicates camera should not return to default.
  35044. */
  35045. /**
  35046. * Gets the time (in milliseconds) taken to return to the default beta position.
  35047. * Negative value indicates camera should not return to default.
  35048. */
  35049. elevationReturnTime: number;
  35050. /**
  35051. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35052. */
  35053. /**
  35054. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35055. */
  35056. elevationReturnWaitTime: number;
  35057. /**
  35058. * Sets the flag that indicates if user zooming should stop animation.
  35059. */
  35060. /**
  35061. * Gets the flag that indicates if user zooming should stop animation.
  35062. */
  35063. zoomStopsAnimation: boolean;
  35064. /**
  35065. * Sets the transition time when framing the mesh, in milliseconds
  35066. */
  35067. /**
  35068. * Gets the transition time when framing the mesh, in milliseconds
  35069. */
  35070. framingTime: number;
  35071. /**
  35072. * Define if the behavior should automatically change the configured
  35073. * camera limits and sensibilities.
  35074. */
  35075. autoCorrectCameraLimitsAndSensibility: boolean;
  35076. private _onPrePointerObservableObserver;
  35077. private _onAfterCheckInputsObserver;
  35078. private _onMeshTargetChangedObserver;
  35079. private _attachedCamera;
  35080. private _isPointerDown;
  35081. private _lastInteractionTime;
  35082. /**
  35083. * Initializes the behavior.
  35084. */
  35085. init(): void;
  35086. /**
  35087. * Attaches the behavior to its arc rotate camera.
  35088. * @param camera Defines the camera to attach the behavior to
  35089. */
  35090. attach(camera: ArcRotateCamera): void;
  35091. /**
  35092. * Detaches the behavior from its current arc rotate camera.
  35093. */
  35094. detach(): void;
  35095. private _animatables;
  35096. private _betaIsAnimating;
  35097. private _betaTransition;
  35098. private _radiusTransition;
  35099. private _vectorTransition;
  35100. /**
  35101. * Targets the given mesh and updates zoom level accordingly.
  35102. * @param mesh The mesh to target.
  35103. * @param radius Optional. If a cached radius position already exists, overrides default.
  35104. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35105. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35106. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35107. */
  35108. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35109. /**
  35110. * Targets the given mesh with its children and updates zoom level accordingly.
  35111. * @param mesh The mesh to target.
  35112. * @param radius Optional. If a cached radius position already exists, overrides default.
  35113. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35114. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35115. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35116. */
  35117. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35118. /**
  35119. * Targets the given meshes with their children and updates zoom level accordingly.
  35120. * @param meshes The mesh to target.
  35121. * @param radius Optional. If a cached radius position already exists, overrides default.
  35122. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35123. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35124. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35125. */
  35126. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35127. /**
  35128. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35129. * @param minimumWorld Determines the smaller position of the bounding box extend
  35130. * @param maximumWorld Determines the bigger position of the bounding box extend
  35131. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35132. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35133. */
  35134. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35135. /**
  35136. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35137. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35138. * frustum width.
  35139. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35140. * to fully enclose the mesh in the viewing frustum.
  35141. */
  35142. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35143. /**
  35144. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35145. * is automatically returned to its default position (expected to be above ground plane).
  35146. */
  35147. private _maintainCameraAboveGround;
  35148. /**
  35149. * Returns the frustum slope based on the canvas ratio and camera FOV
  35150. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35151. */
  35152. private _getFrustumSlope;
  35153. /**
  35154. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35155. */
  35156. private _clearAnimationLocks;
  35157. /**
  35158. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35159. */
  35160. private _applyUserInteraction;
  35161. /**
  35162. * Stops and removes all animations that have been applied to the camera
  35163. */
  35164. stopAllAnimations(): void;
  35165. /**
  35166. * Gets a value indicating if the user is moving the camera
  35167. */
  35168. readonly isUserIsMoving: boolean;
  35169. /**
  35170. * The camera can move all the way towards the mesh.
  35171. */
  35172. static IgnoreBoundsSizeMode: number;
  35173. /**
  35174. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35175. */
  35176. static FitFrustumSidesMode: number;
  35177. }
  35178. }
  35179. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35180. import { Nullable } from "babylonjs/types";
  35181. import { Camera } from "babylonjs/Cameras/camera";
  35182. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35183. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35184. /**
  35185. * Base class for Camera Pointer Inputs.
  35186. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35187. * for example usage.
  35188. */
  35189. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35190. /**
  35191. * Defines the camera the input is attached to.
  35192. */
  35193. abstract camera: Camera;
  35194. /**
  35195. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35196. */
  35197. protected _altKey: boolean;
  35198. protected _ctrlKey: boolean;
  35199. protected _metaKey: boolean;
  35200. protected _shiftKey: boolean;
  35201. /**
  35202. * Which mouse buttons were pressed at time of last mouse event.
  35203. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35204. */
  35205. protected _buttonsPressed: number;
  35206. /**
  35207. * Defines the buttons associated with the input to handle camera move.
  35208. */
  35209. buttons: number[];
  35210. /**
  35211. * Attach the input controls to a specific dom element to get the input from.
  35212. * @param element Defines the element the controls should be listened from
  35213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35214. */
  35215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35216. /**
  35217. * Detach the current controls from the specified dom element.
  35218. * @param element Defines the element to stop listening the inputs from
  35219. */
  35220. detachControl(element: Nullable<HTMLElement>): void;
  35221. /**
  35222. * Gets the class name of the current input.
  35223. * @returns the class name
  35224. */
  35225. getClassName(): string;
  35226. /**
  35227. * Get the friendly name associated with the input class.
  35228. * @returns the input friendly name
  35229. */
  35230. getSimpleName(): string;
  35231. /**
  35232. * Called on pointer POINTERDOUBLETAP event.
  35233. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35234. */
  35235. protected onDoubleTap(type: string): void;
  35236. /**
  35237. * Called on pointer POINTERMOVE event if only a single touch is active.
  35238. * Override this method to provide functionality.
  35239. */
  35240. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35241. /**
  35242. * Called on pointer POINTERMOVE event if multiple touches are active.
  35243. * Override this method to provide functionality.
  35244. */
  35245. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35246. /**
  35247. * Called on JS contextmenu event.
  35248. * Override this method to provide functionality.
  35249. */
  35250. protected onContextMenu(evt: PointerEvent): void;
  35251. /**
  35252. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35253. * press.
  35254. * Override this method to provide functionality.
  35255. */
  35256. protected onButtonDown(evt: PointerEvent): void;
  35257. /**
  35258. * Called each time a new POINTERUP event occurs. Ie, for each button
  35259. * release.
  35260. * Override this method to provide functionality.
  35261. */
  35262. protected onButtonUp(evt: PointerEvent): void;
  35263. /**
  35264. * Called when window becomes inactive.
  35265. * Override this method to provide functionality.
  35266. */
  35267. protected onLostFocus(): void;
  35268. private _pointerInput;
  35269. private _observer;
  35270. private _onLostFocus;
  35271. private pointA;
  35272. private pointB;
  35273. }
  35274. }
  35275. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35276. import { Nullable } from "babylonjs/types";
  35277. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35278. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35279. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35280. /**
  35281. * Manage the pointers inputs to control an arc rotate camera.
  35282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35283. */
  35284. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35285. /**
  35286. * Defines the camera the input is attached to.
  35287. */
  35288. camera: ArcRotateCamera;
  35289. /**
  35290. * Gets the class name of the current input.
  35291. * @returns the class name
  35292. */
  35293. getClassName(): string;
  35294. /**
  35295. * Defines the buttons associated with the input to handle camera move.
  35296. */
  35297. buttons: number[];
  35298. /**
  35299. * Defines the pointer angular sensibility along the X axis or how fast is
  35300. * the camera rotating.
  35301. */
  35302. angularSensibilityX: number;
  35303. /**
  35304. * Defines the pointer angular sensibility along the Y axis or how fast is
  35305. * the camera rotating.
  35306. */
  35307. angularSensibilityY: number;
  35308. /**
  35309. * Defines the pointer pinch precision or how fast is the camera zooming.
  35310. */
  35311. pinchPrecision: number;
  35312. /**
  35313. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35314. * from 0.
  35315. * It defines the percentage of current camera.radius to use as delta when
  35316. * pinch zoom is used.
  35317. */
  35318. pinchDeltaPercentage: number;
  35319. /**
  35320. * Defines the pointer panning sensibility or how fast is the camera moving.
  35321. */
  35322. panningSensibility: number;
  35323. /**
  35324. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35325. */
  35326. multiTouchPanning: boolean;
  35327. /**
  35328. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35329. * zoom (pinch) through multitouch.
  35330. */
  35331. multiTouchPanAndZoom: boolean;
  35332. /**
  35333. * Revers pinch action direction.
  35334. */
  35335. pinchInwards: boolean;
  35336. private _isPanClick;
  35337. private _twoFingerActivityCount;
  35338. private _isPinching;
  35339. /**
  35340. * Called on pointer POINTERMOVE event if only a single touch is active.
  35341. */
  35342. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35343. /**
  35344. * Called on pointer POINTERDOUBLETAP event.
  35345. */
  35346. protected onDoubleTap(type: string): void;
  35347. /**
  35348. * Called on pointer POINTERMOVE event if multiple touches are active.
  35349. */
  35350. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35351. /**
  35352. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35353. * press.
  35354. */
  35355. protected onButtonDown(evt: PointerEvent): void;
  35356. /**
  35357. * Called each time a new POINTERUP event occurs. Ie, for each button
  35358. * release.
  35359. */
  35360. protected onButtonUp(evt: PointerEvent): void;
  35361. /**
  35362. * Called when window becomes inactive.
  35363. */
  35364. protected onLostFocus(): void;
  35365. }
  35366. }
  35367. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35368. import { Nullable } from "babylonjs/types";
  35369. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35370. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35371. /**
  35372. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35374. */
  35375. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35376. /**
  35377. * Defines the camera the input is attached to.
  35378. */
  35379. camera: ArcRotateCamera;
  35380. /**
  35381. * Defines the list of key codes associated with the up action (increase alpha)
  35382. */
  35383. keysUp: number[];
  35384. /**
  35385. * Defines the list of key codes associated with the down action (decrease alpha)
  35386. */
  35387. keysDown: number[];
  35388. /**
  35389. * Defines the list of key codes associated with the left action (increase beta)
  35390. */
  35391. keysLeft: number[];
  35392. /**
  35393. * Defines the list of key codes associated with the right action (decrease beta)
  35394. */
  35395. keysRight: number[];
  35396. /**
  35397. * Defines the list of key codes associated with the reset action.
  35398. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35399. */
  35400. keysReset: number[];
  35401. /**
  35402. * Defines the panning sensibility of the inputs.
  35403. * (How fast is the camera paning)
  35404. */
  35405. panningSensibility: number;
  35406. /**
  35407. * Defines the zooming sensibility of the inputs.
  35408. * (How fast is the camera zooming)
  35409. */
  35410. zoomingSensibility: number;
  35411. /**
  35412. * Defines wether maintaining the alt key down switch the movement mode from
  35413. * orientation to zoom.
  35414. */
  35415. useAltToZoom: boolean;
  35416. /**
  35417. * Rotation speed of the camera
  35418. */
  35419. angularSpeed: number;
  35420. private _keys;
  35421. private _ctrlPressed;
  35422. private _altPressed;
  35423. private _onCanvasBlurObserver;
  35424. private _onKeyboardObserver;
  35425. private _engine;
  35426. private _scene;
  35427. /**
  35428. * Attach the input controls to a specific dom element to get the input from.
  35429. * @param element Defines the element the controls should be listened from
  35430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35431. */
  35432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35433. /**
  35434. * Detach the current controls from the specified dom element.
  35435. * @param element Defines the element to stop listening the inputs from
  35436. */
  35437. detachControl(element: Nullable<HTMLElement>): void;
  35438. /**
  35439. * Update the current camera state depending on the inputs that have been used this frame.
  35440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35441. */
  35442. checkInputs(): void;
  35443. /**
  35444. * Gets the class name of the current intput.
  35445. * @returns the class name
  35446. */
  35447. getClassName(): string;
  35448. /**
  35449. * Get the friendly name associated with the input class.
  35450. * @returns the input friendly name
  35451. */
  35452. getSimpleName(): string;
  35453. }
  35454. }
  35455. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35456. import { Nullable } from "babylonjs/types";
  35457. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35458. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35459. /**
  35460. * Manage the mouse wheel inputs to control an arc rotate camera.
  35461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35462. */
  35463. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35464. /**
  35465. * Defines the camera the input is attached to.
  35466. */
  35467. camera: ArcRotateCamera;
  35468. /**
  35469. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35470. */
  35471. wheelPrecision: number;
  35472. /**
  35473. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35474. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35475. */
  35476. wheelDeltaPercentage: number;
  35477. private _wheel;
  35478. private _observer;
  35479. /**
  35480. * Attach the input controls to a specific dom element to get the input from.
  35481. * @param element Defines the element the controls should be listened from
  35482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35483. */
  35484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35485. /**
  35486. * Detach the current controls from the specified dom element.
  35487. * @param element Defines the element to stop listening the inputs from
  35488. */
  35489. detachControl(element: Nullable<HTMLElement>): void;
  35490. /**
  35491. * Gets the class name of the current intput.
  35492. * @returns the class name
  35493. */
  35494. getClassName(): string;
  35495. /**
  35496. * Get the friendly name associated with the input class.
  35497. * @returns the input friendly name
  35498. */
  35499. getSimpleName(): string;
  35500. }
  35501. }
  35502. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35503. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35504. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35505. /**
  35506. * Default Inputs manager for the ArcRotateCamera.
  35507. * It groups all the default supported inputs for ease of use.
  35508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35509. */
  35510. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35511. /**
  35512. * Instantiates a new ArcRotateCameraInputsManager.
  35513. * @param camera Defines the camera the inputs belong to
  35514. */
  35515. constructor(camera: ArcRotateCamera);
  35516. /**
  35517. * Add mouse wheel input support to the input manager.
  35518. * @returns the current input manager
  35519. */
  35520. addMouseWheel(): ArcRotateCameraInputsManager;
  35521. /**
  35522. * Add pointers input support to the input manager.
  35523. * @returns the current input manager
  35524. */
  35525. addPointers(): ArcRotateCameraInputsManager;
  35526. /**
  35527. * Add keyboard input support to the input manager.
  35528. * @returns the current input manager
  35529. */
  35530. addKeyboard(): ArcRotateCameraInputsManager;
  35531. }
  35532. }
  35533. declare module "babylonjs/Cameras/arcRotateCamera" {
  35534. import { Observable } from "babylonjs/Misc/observable";
  35535. import { Nullable } from "babylonjs/types";
  35536. import { Scene } from "babylonjs/scene";
  35537. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35539. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35540. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35541. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35542. import { Camera } from "babylonjs/Cameras/camera";
  35543. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35544. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35545. import { Collider } from "babylonjs/Collisions/collider";
  35546. /**
  35547. * This represents an orbital type of camera.
  35548. *
  35549. * 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.
  35550. * 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.
  35551. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35552. */
  35553. export class ArcRotateCamera extends TargetCamera {
  35554. /**
  35555. * Defines the rotation angle of the camera along the longitudinal axis.
  35556. */
  35557. alpha: number;
  35558. /**
  35559. * Defines the rotation angle of the camera along the latitudinal axis.
  35560. */
  35561. beta: number;
  35562. /**
  35563. * Defines the radius of the camera from it s target point.
  35564. */
  35565. radius: number;
  35566. protected _target: Vector3;
  35567. protected _targetHost: Nullable<AbstractMesh>;
  35568. /**
  35569. * Defines the target point of the camera.
  35570. * The camera looks towards it form the radius distance.
  35571. */
  35572. target: Vector3;
  35573. /**
  35574. * Define the current local position of the camera in the scene
  35575. */
  35576. position: Vector3;
  35577. /**
  35578. * Current inertia value on the longitudinal axis.
  35579. * The bigger this number the longer it will take for the camera to stop.
  35580. */
  35581. inertialAlphaOffset: number;
  35582. /**
  35583. * Current inertia value on the latitudinal axis.
  35584. * The bigger this number the longer it will take for the camera to stop.
  35585. */
  35586. inertialBetaOffset: number;
  35587. /**
  35588. * Current inertia value on the radius axis.
  35589. * The bigger this number the longer it will take for the camera to stop.
  35590. */
  35591. inertialRadiusOffset: number;
  35592. /**
  35593. * Minimum allowed angle on the longitudinal axis.
  35594. * This can help limiting how the Camera is able to move in the scene.
  35595. */
  35596. lowerAlphaLimit: Nullable<number>;
  35597. /**
  35598. * Maximum allowed angle on the longitudinal axis.
  35599. * This can help limiting how the Camera is able to move in the scene.
  35600. */
  35601. upperAlphaLimit: Nullable<number>;
  35602. /**
  35603. * Minimum allowed angle on the latitudinal axis.
  35604. * This can help limiting how the Camera is able to move in the scene.
  35605. */
  35606. lowerBetaLimit: number;
  35607. /**
  35608. * Maximum allowed angle on the latitudinal axis.
  35609. * This can help limiting how the Camera is able to move in the scene.
  35610. */
  35611. upperBetaLimit: number;
  35612. /**
  35613. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35614. * This can help limiting how the Camera is able to move in the scene.
  35615. */
  35616. lowerRadiusLimit: Nullable<number>;
  35617. /**
  35618. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35619. * This can help limiting how the Camera is able to move in the scene.
  35620. */
  35621. upperRadiusLimit: Nullable<number>;
  35622. /**
  35623. * Defines the current inertia value used during panning of the camera along the X axis.
  35624. */
  35625. inertialPanningX: number;
  35626. /**
  35627. * Defines the current inertia value used during panning of the camera along the Y axis.
  35628. */
  35629. inertialPanningY: number;
  35630. /**
  35631. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35632. * Basically if your fingers moves away from more than this distance you will be considered
  35633. * in pinch mode.
  35634. */
  35635. pinchToPanMaxDistance: number;
  35636. /**
  35637. * Defines the maximum distance the camera can pan.
  35638. * This could help keeping the cammera always in your scene.
  35639. */
  35640. panningDistanceLimit: Nullable<number>;
  35641. /**
  35642. * Defines the target of the camera before paning.
  35643. */
  35644. panningOriginTarget: Vector3;
  35645. /**
  35646. * Defines the value of the inertia used during panning.
  35647. * 0 would mean stop inertia and one would mean no decelleration at all.
  35648. */
  35649. panningInertia: number;
  35650. /**
  35651. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35652. */
  35653. angularSensibilityX: number;
  35654. /**
  35655. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35656. */
  35657. angularSensibilityY: number;
  35658. /**
  35659. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35660. */
  35661. pinchPrecision: number;
  35662. /**
  35663. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35664. * It will be used instead of pinchDeltaPrecision if different from 0.
  35665. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35666. */
  35667. pinchDeltaPercentage: number;
  35668. /**
  35669. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35670. */
  35671. panningSensibility: number;
  35672. /**
  35673. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35674. */
  35675. keysUp: number[];
  35676. /**
  35677. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35678. */
  35679. keysDown: number[];
  35680. /**
  35681. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35682. */
  35683. keysLeft: number[];
  35684. /**
  35685. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35686. */
  35687. keysRight: number[];
  35688. /**
  35689. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35690. */
  35691. wheelPrecision: number;
  35692. /**
  35693. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35694. * It will be used instead of pinchDeltaPrecision if different from 0.
  35695. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35696. */
  35697. wheelDeltaPercentage: number;
  35698. /**
  35699. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35700. */
  35701. zoomOnFactor: number;
  35702. /**
  35703. * Defines a screen offset for the camera position.
  35704. */
  35705. targetScreenOffset: Vector2;
  35706. /**
  35707. * Allows the camera to be completely reversed.
  35708. * If false the camera can not arrive upside down.
  35709. */
  35710. allowUpsideDown: boolean;
  35711. /**
  35712. * Define if double tap/click is used to restore the previously saved state of the camera.
  35713. */
  35714. useInputToRestoreState: boolean;
  35715. /** @hidden */
  35716. _viewMatrix: Matrix;
  35717. /** @hidden */
  35718. _useCtrlForPanning: boolean;
  35719. /** @hidden */
  35720. _panningMouseButton: number;
  35721. /**
  35722. * Defines the input associated to the camera.
  35723. */
  35724. inputs: ArcRotateCameraInputsManager;
  35725. /** @hidden */
  35726. _reset: () => void;
  35727. /**
  35728. * Defines the allowed panning axis.
  35729. */
  35730. panningAxis: Vector3;
  35731. protected _localDirection: Vector3;
  35732. protected _transformedDirection: Vector3;
  35733. private _bouncingBehavior;
  35734. /**
  35735. * Gets the bouncing behavior of the camera if it has been enabled.
  35736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35737. */
  35738. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35739. /**
  35740. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35741. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35742. */
  35743. useBouncingBehavior: boolean;
  35744. private _framingBehavior;
  35745. /**
  35746. * Gets the framing behavior of the camera if it has been enabled.
  35747. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35748. */
  35749. readonly framingBehavior: Nullable<FramingBehavior>;
  35750. /**
  35751. * Defines if the framing behavior of the camera is enabled on the camera.
  35752. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35753. */
  35754. useFramingBehavior: boolean;
  35755. private _autoRotationBehavior;
  35756. /**
  35757. * Gets the auto rotation behavior of the camera if it has been enabled.
  35758. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35759. */
  35760. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35761. /**
  35762. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35763. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35764. */
  35765. useAutoRotationBehavior: boolean;
  35766. /**
  35767. * Observable triggered when the mesh target has been changed on the camera.
  35768. */
  35769. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35770. /**
  35771. * Event raised when the camera is colliding with a mesh.
  35772. */
  35773. onCollide: (collidedMesh: AbstractMesh) => void;
  35774. /**
  35775. * Defines whether the camera should check collision with the objects oh the scene.
  35776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35777. */
  35778. checkCollisions: boolean;
  35779. /**
  35780. * Defines the collision radius of the camera.
  35781. * This simulates a sphere around the camera.
  35782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35783. */
  35784. collisionRadius: Vector3;
  35785. protected _collider: Collider;
  35786. protected _previousPosition: Vector3;
  35787. protected _collisionVelocity: Vector3;
  35788. protected _newPosition: Vector3;
  35789. protected _previousAlpha: number;
  35790. protected _previousBeta: number;
  35791. protected _previousRadius: number;
  35792. protected _collisionTriggered: boolean;
  35793. protected _targetBoundingCenter: Nullable<Vector3>;
  35794. private _computationVector;
  35795. private _tempAxisVector;
  35796. private _tempAxisRotationMatrix;
  35797. /**
  35798. * Instantiates a new ArcRotateCamera in a given scene
  35799. * @param name Defines the name of the camera
  35800. * @param alpha Defines the camera rotation along the logitudinal axis
  35801. * @param beta Defines the camera rotation along the latitudinal axis
  35802. * @param radius Defines the camera distance from its target
  35803. * @param target Defines the camera target
  35804. * @param scene Defines the scene the camera belongs to
  35805. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35806. */
  35807. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35808. /** @hidden */
  35809. _initCache(): void;
  35810. /** @hidden */
  35811. _updateCache(ignoreParentClass?: boolean): void;
  35812. protected _getTargetPosition(): Vector3;
  35813. private _storedAlpha;
  35814. private _storedBeta;
  35815. private _storedRadius;
  35816. private _storedTarget;
  35817. /**
  35818. * Stores the current state of the camera (alpha, beta, radius and target)
  35819. * @returns the camera itself
  35820. */
  35821. storeState(): Camera;
  35822. /**
  35823. * @hidden
  35824. * Restored camera state. You must call storeState() first
  35825. */
  35826. _restoreStateValues(): boolean;
  35827. /** @hidden */
  35828. _isSynchronizedViewMatrix(): boolean;
  35829. /**
  35830. * Attached controls to the current camera.
  35831. * @param element Defines the element the controls should be listened from
  35832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35833. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35834. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35835. */
  35836. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35837. /**
  35838. * Detach the current controls from the camera.
  35839. * The camera will stop reacting to inputs.
  35840. * @param element Defines the element to stop listening the inputs from
  35841. */
  35842. detachControl(element: HTMLElement): void;
  35843. /** @hidden */
  35844. _checkInputs(): void;
  35845. protected _checkLimits(): void;
  35846. /**
  35847. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35848. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35849. */
  35850. rebuildAnglesAndRadius(updateView?: boolean): void;
  35851. /**
  35852. * Use a position to define the current camera related information like aplha, beta and radius
  35853. * @param position Defines the position to set the camera at
  35854. */
  35855. setPosition(position: Vector3): void;
  35856. /**
  35857. * Defines the target the camera should look at.
  35858. * This will automatically adapt alpha beta and radius to fit within the new target.
  35859. * @param target Defines the new target as a Vector or a mesh
  35860. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35861. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35862. */
  35863. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35864. /** @hidden */
  35865. _getViewMatrix(): Matrix;
  35866. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35867. /**
  35868. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35869. * @param meshes Defines the mesh to zoom on
  35870. * @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)
  35871. */
  35872. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35873. /**
  35874. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35875. * The target will be changed but the radius
  35876. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35877. * @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)
  35878. */
  35879. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35880. min: Vector3;
  35881. max: Vector3;
  35882. distance: number;
  35883. }, doNotUpdateMaxZ?: boolean): void;
  35884. /**
  35885. * @override
  35886. * Override Camera.createRigCamera
  35887. */
  35888. createRigCamera(name: string, cameraIndex: number): Camera;
  35889. /**
  35890. * @hidden
  35891. * @override
  35892. * Override Camera._updateRigCameras
  35893. */
  35894. _updateRigCameras(): void;
  35895. /**
  35896. * Destroy the camera and release the current resources hold by it.
  35897. */
  35898. dispose(): void;
  35899. /**
  35900. * Gets the current object class name.
  35901. * @return the class name
  35902. */
  35903. getClassName(): string;
  35904. }
  35905. }
  35906. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35907. import { Behavior } from "babylonjs/Behaviors/behavior";
  35908. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35909. /**
  35910. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35911. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35912. */
  35913. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35914. /**
  35915. * Gets the name of the behavior.
  35916. */
  35917. readonly name: string;
  35918. private _zoomStopsAnimation;
  35919. private _idleRotationSpeed;
  35920. private _idleRotationWaitTime;
  35921. private _idleRotationSpinupTime;
  35922. /**
  35923. * Sets the flag that indicates if user zooming should stop animation.
  35924. */
  35925. /**
  35926. * Gets the flag that indicates if user zooming should stop animation.
  35927. */
  35928. zoomStopsAnimation: boolean;
  35929. /**
  35930. * Sets the default speed at which the camera rotates around the model.
  35931. */
  35932. /**
  35933. * Gets the default speed at which the camera rotates around the model.
  35934. */
  35935. idleRotationSpeed: number;
  35936. /**
  35937. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35938. */
  35939. /**
  35940. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35941. */
  35942. idleRotationWaitTime: number;
  35943. /**
  35944. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35945. */
  35946. /**
  35947. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35948. */
  35949. idleRotationSpinupTime: number;
  35950. /**
  35951. * Gets a value indicating if the camera is currently rotating because of this behavior
  35952. */
  35953. readonly rotationInProgress: boolean;
  35954. private _onPrePointerObservableObserver;
  35955. private _onAfterCheckInputsObserver;
  35956. private _attachedCamera;
  35957. private _isPointerDown;
  35958. private _lastFrameTime;
  35959. private _lastInteractionTime;
  35960. private _cameraRotationSpeed;
  35961. /**
  35962. * Initializes the behavior.
  35963. */
  35964. init(): void;
  35965. /**
  35966. * Attaches the behavior to its arc rotate camera.
  35967. * @param camera Defines the camera to attach the behavior to
  35968. */
  35969. attach(camera: ArcRotateCamera): void;
  35970. /**
  35971. * Detaches the behavior from its current arc rotate camera.
  35972. */
  35973. detach(): void;
  35974. /**
  35975. * Returns true if user is scrolling.
  35976. * @return true if user is scrolling.
  35977. */
  35978. private _userIsZooming;
  35979. private _lastFrameRadius;
  35980. private _shouldAnimationStopForInteraction;
  35981. /**
  35982. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35983. */
  35984. private _applyUserInteraction;
  35985. private _userIsMoving;
  35986. }
  35987. }
  35988. declare module "babylonjs/Behaviors/Cameras/index" {
  35989. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35990. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35991. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35992. }
  35993. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35994. import { Mesh } from "babylonjs/Meshes/mesh";
  35995. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35996. import { Behavior } from "babylonjs/Behaviors/behavior";
  35997. /**
  35998. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35999. */
  36000. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36001. private ui;
  36002. /**
  36003. * The name of the behavior
  36004. */
  36005. name: string;
  36006. /**
  36007. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36008. */
  36009. distanceAwayFromFace: number;
  36010. /**
  36011. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36012. */
  36013. distanceAwayFromBottomOfFace: number;
  36014. private _faceVectors;
  36015. private _target;
  36016. private _scene;
  36017. private _onRenderObserver;
  36018. private _tmpMatrix;
  36019. private _tmpVector;
  36020. /**
  36021. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36022. * @param ui The transform node that should be attched to the mesh
  36023. */
  36024. constructor(ui: TransformNode);
  36025. /**
  36026. * Initializes the behavior
  36027. */
  36028. init(): void;
  36029. private _closestFace;
  36030. private _zeroVector;
  36031. private _lookAtTmpMatrix;
  36032. private _lookAtToRef;
  36033. /**
  36034. * Attaches the AttachToBoxBehavior to the passed in mesh
  36035. * @param target The mesh that the specified node will be attached to
  36036. */
  36037. attach(target: Mesh): void;
  36038. /**
  36039. * Detaches the behavior from the mesh
  36040. */
  36041. detach(): void;
  36042. }
  36043. }
  36044. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36045. import { Behavior } from "babylonjs/Behaviors/behavior";
  36046. import { Mesh } from "babylonjs/Meshes/mesh";
  36047. /**
  36048. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36049. */
  36050. export class FadeInOutBehavior implements Behavior<Mesh> {
  36051. /**
  36052. * Time in milliseconds to delay before fading in (Default: 0)
  36053. */
  36054. delay: number;
  36055. /**
  36056. * Time in milliseconds for the mesh to fade in (Default: 300)
  36057. */
  36058. fadeInTime: number;
  36059. private _millisecondsPerFrame;
  36060. private _hovered;
  36061. private _hoverValue;
  36062. private _ownerNode;
  36063. /**
  36064. * Instatiates the FadeInOutBehavior
  36065. */
  36066. constructor();
  36067. /**
  36068. * The name of the behavior
  36069. */
  36070. readonly name: string;
  36071. /**
  36072. * Initializes the behavior
  36073. */
  36074. init(): void;
  36075. /**
  36076. * Attaches the fade behavior on the passed in mesh
  36077. * @param ownerNode The mesh that will be faded in/out once attached
  36078. */
  36079. attach(ownerNode: Mesh): void;
  36080. /**
  36081. * Detaches the behavior from the mesh
  36082. */
  36083. detach(): void;
  36084. /**
  36085. * Triggers the mesh to begin fading in or out
  36086. * @param value if the object should fade in or out (true to fade in)
  36087. */
  36088. fadeIn(value: boolean): void;
  36089. private _update;
  36090. private _setAllVisibility;
  36091. }
  36092. }
  36093. declare module "babylonjs/Misc/pivotTools" {
  36094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36095. /**
  36096. * Class containing a set of static utilities functions for managing Pivots
  36097. * @hidden
  36098. */
  36099. export class PivotTools {
  36100. private static _PivotCached;
  36101. private static _OldPivotPoint;
  36102. private static _PivotTranslation;
  36103. private static _PivotTmpVector;
  36104. /** @hidden */
  36105. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36106. /** @hidden */
  36107. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36108. }
  36109. }
  36110. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36111. import { Scene } from "babylonjs/scene";
  36112. import { Vector4, Plane } from "babylonjs/Maths/math";
  36113. import { Mesh } from "babylonjs/Meshes/mesh";
  36114. /**
  36115. * Class containing static functions to help procedurally build meshes
  36116. */
  36117. export class PlaneBuilder {
  36118. /**
  36119. * Creates a plane mesh
  36120. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36121. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36122. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36126. * @param name defines the name of the mesh
  36127. * @param options defines the options used to create the mesh
  36128. * @param scene defines the hosting scene
  36129. * @returns the plane mesh
  36130. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36131. */
  36132. static CreatePlane(name: string, options: {
  36133. size?: number;
  36134. width?: number;
  36135. height?: number;
  36136. sideOrientation?: number;
  36137. frontUVs?: Vector4;
  36138. backUVs?: Vector4;
  36139. updatable?: boolean;
  36140. sourcePlane?: Plane;
  36141. }, scene: Scene): Mesh;
  36142. }
  36143. }
  36144. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36145. import { Behavior } from "babylonjs/Behaviors/behavior";
  36146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36147. import { Observable } from "babylonjs/Misc/observable";
  36148. import { Vector3 } from "babylonjs/Maths/math";
  36149. import { Ray } from "babylonjs/Culling/ray";
  36150. import "babylonjs/Meshes/Builders/planeBuilder";
  36151. /**
  36152. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36153. */
  36154. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36155. private static _AnyMouseID;
  36156. private _attachedNode;
  36157. private _dragPlane;
  36158. private _scene;
  36159. private _pointerObserver;
  36160. private _beforeRenderObserver;
  36161. private static _planeScene;
  36162. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36163. /**
  36164. * 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)
  36165. */
  36166. maxDragAngle: number;
  36167. /**
  36168. * @hidden
  36169. */
  36170. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36171. /**
  36172. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36173. */
  36174. currentDraggingPointerID: number;
  36175. /**
  36176. * The last position where the pointer hit the drag plane in world space
  36177. */
  36178. lastDragPosition: Vector3;
  36179. /**
  36180. * If the behavior is currently in a dragging state
  36181. */
  36182. dragging: boolean;
  36183. /**
  36184. * 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)
  36185. */
  36186. dragDeltaRatio: number;
  36187. /**
  36188. * If the drag plane orientation should be updated during the dragging (Default: true)
  36189. */
  36190. updateDragPlane: boolean;
  36191. private _debugMode;
  36192. private _moving;
  36193. /**
  36194. * Fires each time the attached mesh is dragged with the pointer
  36195. * * delta between last drag position and current drag position in world space
  36196. * * dragDistance along the drag axis
  36197. * * dragPlaneNormal normal of the current drag plane used during the drag
  36198. * * dragPlanePoint in world space where the drag intersects the drag plane
  36199. */
  36200. onDragObservable: Observable<{
  36201. delta: Vector3;
  36202. dragPlanePoint: Vector3;
  36203. dragPlaneNormal: Vector3;
  36204. dragDistance: number;
  36205. pointerId: number;
  36206. }>;
  36207. /**
  36208. * Fires each time a drag begins (eg. mouse down on mesh)
  36209. */
  36210. onDragStartObservable: Observable<{
  36211. dragPlanePoint: Vector3;
  36212. pointerId: number;
  36213. }>;
  36214. /**
  36215. * Fires each time a drag ends (eg. mouse release after drag)
  36216. */
  36217. onDragEndObservable: Observable<{
  36218. dragPlanePoint: Vector3;
  36219. pointerId: number;
  36220. }>;
  36221. /**
  36222. * If the attached mesh should be moved when dragged
  36223. */
  36224. moveAttached: boolean;
  36225. /**
  36226. * If the drag behavior will react to drag events (Default: true)
  36227. */
  36228. enabled: boolean;
  36229. /**
  36230. * If camera controls should be detached during the drag
  36231. */
  36232. detachCameraControls: boolean;
  36233. /**
  36234. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36235. */
  36236. useObjectOrienationForDragging: boolean;
  36237. private _options;
  36238. /**
  36239. * Creates a pointer drag behavior that can be attached to a mesh
  36240. * @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)
  36241. */
  36242. constructor(options?: {
  36243. dragAxis?: Vector3;
  36244. dragPlaneNormal?: Vector3;
  36245. });
  36246. /**
  36247. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36248. */
  36249. validateDrag: (targetPosition: Vector3) => boolean;
  36250. /**
  36251. * The name of the behavior
  36252. */
  36253. readonly name: string;
  36254. /**
  36255. * Initializes the behavior
  36256. */
  36257. init(): void;
  36258. private _tmpVector;
  36259. private _alternatePickedPoint;
  36260. private _worldDragAxis;
  36261. private _targetPosition;
  36262. private _attachedElement;
  36263. /**
  36264. * Attaches the drag behavior the passed in mesh
  36265. * @param ownerNode The mesh that will be dragged around once attached
  36266. */
  36267. attach(ownerNode: AbstractMesh): void;
  36268. /**
  36269. * Force relase the drag action by code.
  36270. */
  36271. releaseDrag(): void;
  36272. private _startDragRay;
  36273. private _lastPointerRay;
  36274. /**
  36275. * Simulates the start of a pointer drag event on the behavior
  36276. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36277. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36278. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36279. */
  36280. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36281. private _startDrag;
  36282. private _dragDelta;
  36283. private _moveDrag;
  36284. private _pickWithRayOnDragPlane;
  36285. private _pointA;
  36286. private _pointB;
  36287. private _pointC;
  36288. private _lineA;
  36289. private _lineB;
  36290. private _localAxis;
  36291. private _lookAt;
  36292. private _updateDragPlanePosition;
  36293. /**
  36294. * Detaches the behavior from the mesh
  36295. */
  36296. detach(): void;
  36297. }
  36298. }
  36299. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36300. import { Mesh } from "babylonjs/Meshes/mesh";
  36301. import { Behavior } from "babylonjs/Behaviors/behavior";
  36302. /**
  36303. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36304. */
  36305. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36306. private _dragBehaviorA;
  36307. private _dragBehaviorB;
  36308. private _startDistance;
  36309. private _initialScale;
  36310. private _targetScale;
  36311. private _ownerNode;
  36312. private _sceneRenderObserver;
  36313. /**
  36314. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36315. */
  36316. constructor();
  36317. /**
  36318. * The name of the behavior
  36319. */
  36320. readonly name: string;
  36321. /**
  36322. * Initializes the behavior
  36323. */
  36324. init(): void;
  36325. private _getCurrentDistance;
  36326. /**
  36327. * Attaches the scale behavior the passed in mesh
  36328. * @param ownerNode The mesh that will be scaled around once attached
  36329. */
  36330. attach(ownerNode: Mesh): void;
  36331. /**
  36332. * Detaches the behavior from the mesh
  36333. */
  36334. detach(): void;
  36335. }
  36336. }
  36337. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36338. import { Behavior } from "babylonjs/Behaviors/behavior";
  36339. import { Mesh } from "babylonjs/Meshes/mesh";
  36340. import { Observable } from "babylonjs/Misc/observable";
  36341. /**
  36342. * 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
  36343. */
  36344. export class SixDofDragBehavior implements Behavior<Mesh> {
  36345. private static _virtualScene;
  36346. private _ownerNode;
  36347. private _sceneRenderObserver;
  36348. private _scene;
  36349. private _targetPosition;
  36350. private _virtualOriginMesh;
  36351. private _virtualDragMesh;
  36352. private _pointerObserver;
  36353. private _moving;
  36354. private _startingOrientation;
  36355. /**
  36356. * 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)
  36357. */
  36358. private zDragFactor;
  36359. /**
  36360. * If the object should rotate to face the drag origin
  36361. */
  36362. rotateDraggedObject: boolean;
  36363. /**
  36364. * If the behavior is currently in a dragging state
  36365. */
  36366. dragging: boolean;
  36367. /**
  36368. * 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)
  36369. */
  36370. dragDeltaRatio: number;
  36371. /**
  36372. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36373. */
  36374. currentDraggingPointerID: number;
  36375. /**
  36376. * If camera controls should be detached during the drag
  36377. */
  36378. detachCameraControls: boolean;
  36379. /**
  36380. * Fires each time a drag starts
  36381. */
  36382. onDragStartObservable: Observable<{}>;
  36383. /**
  36384. * Fires each time a drag ends (eg. mouse release after drag)
  36385. */
  36386. onDragEndObservable: Observable<{}>;
  36387. /**
  36388. * 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
  36389. */
  36390. constructor();
  36391. /**
  36392. * The name of the behavior
  36393. */
  36394. readonly name: string;
  36395. /**
  36396. * Initializes the behavior
  36397. */
  36398. init(): void;
  36399. /**
  36400. * Attaches the scale behavior the passed in mesh
  36401. * @param ownerNode The mesh that will be scaled around once attached
  36402. */
  36403. attach(ownerNode: Mesh): void;
  36404. /**
  36405. * Detaches the behavior from the mesh
  36406. */
  36407. detach(): void;
  36408. }
  36409. }
  36410. declare module "babylonjs/Behaviors/Meshes/index" {
  36411. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36412. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36413. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36414. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36415. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36416. }
  36417. declare module "babylonjs/Behaviors/index" {
  36418. export * from "babylonjs/Behaviors/behavior";
  36419. export * from "babylonjs/Behaviors/Cameras/index";
  36420. export * from "babylonjs/Behaviors/Meshes/index";
  36421. }
  36422. declare module "babylonjs/Bones/boneIKController" {
  36423. import { Bone } from "babylonjs/Bones/bone";
  36424. import { Vector3 } from "babylonjs/Maths/math";
  36425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36426. import { Nullable } from "babylonjs/types";
  36427. /**
  36428. * Class used to apply inverse kinematics to bones
  36429. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36430. */
  36431. export class BoneIKController {
  36432. private static _tmpVecs;
  36433. private static _tmpQuat;
  36434. private static _tmpMats;
  36435. /**
  36436. * Gets or sets the target mesh
  36437. */
  36438. targetMesh: AbstractMesh;
  36439. /** Gets or sets the mesh used as pole */
  36440. poleTargetMesh: AbstractMesh;
  36441. /**
  36442. * Gets or sets the bone used as pole
  36443. */
  36444. poleTargetBone: Nullable<Bone>;
  36445. /**
  36446. * Gets or sets the target position
  36447. */
  36448. targetPosition: Vector3;
  36449. /**
  36450. * Gets or sets the pole target position
  36451. */
  36452. poleTargetPosition: Vector3;
  36453. /**
  36454. * Gets or sets the pole target local offset
  36455. */
  36456. poleTargetLocalOffset: Vector3;
  36457. /**
  36458. * Gets or sets the pole angle
  36459. */
  36460. poleAngle: number;
  36461. /**
  36462. * Gets or sets the mesh associated with the controller
  36463. */
  36464. mesh: AbstractMesh;
  36465. /**
  36466. * 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)
  36467. */
  36468. slerpAmount: number;
  36469. private _bone1Quat;
  36470. private _bone1Mat;
  36471. private _bone2Ang;
  36472. private _bone1;
  36473. private _bone2;
  36474. private _bone1Length;
  36475. private _bone2Length;
  36476. private _maxAngle;
  36477. private _maxReach;
  36478. private _rightHandedSystem;
  36479. private _bendAxis;
  36480. private _slerping;
  36481. private _adjustRoll;
  36482. /**
  36483. * Gets or sets maximum allowed angle
  36484. */
  36485. maxAngle: number;
  36486. /**
  36487. * Creates a new BoneIKController
  36488. * @param mesh defines the mesh to control
  36489. * @param bone defines the bone to control
  36490. * @param options defines options to set up the controller
  36491. */
  36492. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36493. targetMesh?: AbstractMesh;
  36494. poleTargetMesh?: AbstractMesh;
  36495. poleTargetBone?: Bone;
  36496. poleTargetLocalOffset?: Vector3;
  36497. poleAngle?: number;
  36498. bendAxis?: Vector3;
  36499. maxAngle?: number;
  36500. slerpAmount?: number;
  36501. });
  36502. private _setMaxAngle;
  36503. /**
  36504. * Force the controller to update the bones
  36505. */
  36506. update(): void;
  36507. }
  36508. }
  36509. declare module "babylonjs/Bones/boneLookController" {
  36510. import { Vector3, Space } from "babylonjs/Maths/math";
  36511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36512. import { Bone } from "babylonjs/Bones/bone";
  36513. /**
  36514. * Class used to make a bone look toward a point in space
  36515. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36516. */
  36517. export class BoneLookController {
  36518. private static _tmpVecs;
  36519. private static _tmpQuat;
  36520. private static _tmpMats;
  36521. /**
  36522. * The target Vector3 that the bone will look at
  36523. */
  36524. target: Vector3;
  36525. /**
  36526. * The mesh that the bone is attached to
  36527. */
  36528. mesh: AbstractMesh;
  36529. /**
  36530. * The bone that will be looking to the target
  36531. */
  36532. bone: Bone;
  36533. /**
  36534. * The up axis of the coordinate system that is used when the bone is rotated
  36535. */
  36536. upAxis: Vector3;
  36537. /**
  36538. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36539. */
  36540. upAxisSpace: Space;
  36541. /**
  36542. * Used to make an adjustment to the yaw of the bone
  36543. */
  36544. adjustYaw: number;
  36545. /**
  36546. * Used to make an adjustment to the pitch of the bone
  36547. */
  36548. adjustPitch: number;
  36549. /**
  36550. * Used to make an adjustment to the roll of the bone
  36551. */
  36552. adjustRoll: number;
  36553. /**
  36554. * 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)
  36555. */
  36556. slerpAmount: number;
  36557. private _minYaw;
  36558. private _maxYaw;
  36559. private _minPitch;
  36560. private _maxPitch;
  36561. private _minYawSin;
  36562. private _minYawCos;
  36563. private _maxYawSin;
  36564. private _maxYawCos;
  36565. private _midYawConstraint;
  36566. private _minPitchTan;
  36567. private _maxPitchTan;
  36568. private _boneQuat;
  36569. private _slerping;
  36570. private _transformYawPitch;
  36571. private _transformYawPitchInv;
  36572. private _firstFrameSkipped;
  36573. private _yawRange;
  36574. private _fowardAxis;
  36575. /**
  36576. * Gets or sets the minimum yaw angle that the bone can look to
  36577. */
  36578. minYaw: number;
  36579. /**
  36580. * Gets or sets the maximum yaw angle that the bone can look to
  36581. */
  36582. maxYaw: number;
  36583. /**
  36584. * Gets or sets the minimum pitch angle that the bone can look to
  36585. */
  36586. minPitch: number;
  36587. /**
  36588. * Gets or sets the maximum pitch angle that the bone can look to
  36589. */
  36590. maxPitch: number;
  36591. /**
  36592. * Create a BoneLookController
  36593. * @param mesh the mesh that the bone belongs to
  36594. * @param bone the bone that will be looking to the target
  36595. * @param target the target Vector3 to look at
  36596. * @param options optional settings:
  36597. * * maxYaw: the maximum angle the bone will yaw to
  36598. * * minYaw: the minimum angle the bone will yaw to
  36599. * * maxPitch: the maximum angle the bone will pitch to
  36600. * * minPitch: the minimum angle the bone will yaw to
  36601. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36602. * * upAxis: the up axis of the coordinate system
  36603. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36604. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36605. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36606. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36607. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36608. * * adjustRoll: used to make an adjustment to the roll of the bone
  36609. **/
  36610. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36611. maxYaw?: number;
  36612. minYaw?: number;
  36613. maxPitch?: number;
  36614. minPitch?: number;
  36615. slerpAmount?: number;
  36616. upAxis?: Vector3;
  36617. upAxisSpace?: Space;
  36618. yawAxis?: Vector3;
  36619. pitchAxis?: Vector3;
  36620. adjustYaw?: number;
  36621. adjustPitch?: number;
  36622. adjustRoll?: number;
  36623. });
  36624. /**
  36625. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36626. */
  36627. update(): void;
  36628. private _getAngleDiff;
  36629. private _getAngleBetween;
  36630. private _isAngleBetween;
  36631. }
  36632. }
  36633. declare module "babylonjs/Bones/index" {
  36634. export * from "babylonjs/Bones/bone";
  36635. export * from "babylonjs/Bones/boneIKController";
  36636. export * from "babylonjs/Bones/boneLookController";
  36637. export * from "babylonjs/Bones/skeleton";
  36638. }
  36639. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36640. import { Nullable } from "babylonjs/types";
  36641. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36642. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36643. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36644. /**
  36645. * Manage the gamepad inputs to control an arc rotate camera.
  36646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36647. */
  36648. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36649. /**
  36650. * Defines the camera the input is attached to.
  36651. */
  36652. camera: ArcRotateCamera;
  36653. /**
  36654. * Defines the gamepad the input is gathering event from.
  36655. */
  36656. gamepad: Nullable<Gamepad>;
  36657. /**
  36658. * Defines the gamepad rotation sensiblity.
  36659. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36660. */
  36661. gamepadRotationSensibility: number;
  36662. /**
  36663. * Defines the gamepad move sensiblity.
  36664. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36665. */
  36666. gamepadMoveSensibility: number;
  36667. private _onGamepadConnectedObserver;
  36668. private _onGamepadDisconnectedObserver;
  36669. /**
  36670. * Attach the input controls to a specific dom element to get the input from.
  36671. * @param element Defines the element the controls should be listened from
  36672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36673. */
  36674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36675. /**
  36676. * Detach the current controls from the specified dom element.
  36677. * @param element Defines the element to stop listening the inputs from
  36678. */
  36679. detachControl(element: Nullable<HTMLElement>): void;
  36680. /**
  36681. * Update the current camera state depending on the inputs that have been used this frame.
  36682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36683. */
  36684. checkInputs(): void;
  36685. /**
  36686. * Gets the class name of the current intput.
  36687. * @returns the class name
  36688. */
  36689. getClassName(): string;
  36690. /**
  36691. * Get the friendly name associated with the input class.
  36692. * @returns the input friendly name
  36693. */
  36694. getSimpleName(): string;
  36695. }
  36696. }
  36697. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36698. import { Nullable } from "babylonjs/types";
  36699. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36700. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36701. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36702. interface ArcRotateCameraInputsManager {
  36703. /**
  36704. * Add orientation input support to the input manager.
  36705. * @returns the current input manager
  36706. */
  36707. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36708. }
  36709. }
  36710. /**
  36711. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36713. */
  36714. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36715. /**
  36716. * Defines the camera the input is attached to.
  36717. */
  36718. camera: ArcRotateCamera;
  36719. /**
  36720. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36721. */
  36722. alphaCorrection: number;
  36723. /**
  36724. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36725. */
  36726. gammaCorrection: number;
  36727. private _alpha;
  36728. private _gamma;
  36729. private _dirty;
  36730. private _deviceOrientationHandler;
  36731. /**
  36732. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36733. */
  36734. constructor();
  36735. /**
  36736. * Attach the input controls to a specific dom element to get the input from.
  36737. * @param element Defines the element the controls should be listened from
  36738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36739. */
  36740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36741. /** @hidden */
  36742. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36743. /**
  36744. * Update the current camera state depending on the inputs that have been used this frame.
  36745. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36746. */
  36747. checkInputs(): void;
  36748. /**
  36749. * Detach the current controls from the specified dom element.
  36750. * @param element Defines the element to stop listening the inputs from
  36751. */
  36752. detachControl(element: Nullable<HTMLElement>): void;
  36753. /**
  36754. * Gets the class name of the current intput.
  36755. * @returns the class name
  36756. */
  36757. getClassName(): string;
  36758. /**
  36759. * Get the friendly name associated with the input class.
  36760. * @returns the input friendly name
  36761. */
  36762. getSimpleName(): string;
  36763. }
  36764. }
  36765. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36766. import { Nullable } from "babylonjs/types";
  36767. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36768. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36769. /**
  36770. * Listen to mouse events to control the camera.
  36771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36772. */
  36773. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36774. /**
  36775. * Defines the camera the input is attached to.
  36776. */
  36777. camera: FlyCamera;
  36778. /**
  36779. * Defines if touch is enabled. (Default is true.)
  36780. */
  36781. touchEnabled: boolean;
  36782. /**
  36783. * Defines the buttons associated with the input to handle camera rotation.
  36784. */
  36785. buttons: number[];
  36786. /**
  36787. * Assign buttons for Yaw control.
  36788. */
  36789. buttonsYaw: number[];
  36790. /**
  36791. * Assign buttons for Pitch control.
  36792. */
  36793. buttonsPitch: number[];
  36794. /**
  36795. * Assign buttons for Roll control.
  36796. */
  36797. buttonsRoll: number[];
  36798. /**
  36799. * Detect if any button is being pressed while mouse is moved.
  36800. * -1 = Mouse locked.
  36801. * 0 = Left button.
  36802. * 1 = Middle Button.
  36803. * 2 = Right Button.
  36804. */
  36805. activeButton: number;
  36806. /**
  36807. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36808. * Higher values reduce its sensitivity.
  36809. */
  36810. angularSensibility: number;
  36811. private _mousemoveCallback;
  36812. private _observer;
  36813. private _rollObserver;
  36814. private previousPosition;
  36815. private noPreventDefault;
  36816. private element;
  36817. /**
  36818. * Listen to mouse events to control the camera.
  36819. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36821. */
  36822. constructor(touchEnabled?: boolean);
  36823. /**
  36824. * Attach the mouse control to the HTML DOM element.
  36825. * @param element Defines the element that listens to the input events.
  36826. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36827. */
  36828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36829. /**
  36830. * Detach the current controls from the specified dom element.
  36831. * @param element Defines the element to stop listening the inputs from
  36832. */
  36833. detachControl(element: Nullable<HTMLElement>): void;
  36834. /**
  36835. * Gets the class name of the current input.
  36836. * @returns the class name.
  36837. */
  36838. getClassName(): string;
  36839. /**
  36840. * Get the friendly name associated with the input class.
  36841. * @returns the input's friendly name.
  36842. */
  36843. getSimpleName(): string;
  36844. private _pointerInput;
  36845. private _onMouseMove;
  36846. /**
  36847. * Rotate camera by mouse offset.
  36848. */
  36849. private rotateCamera;
  36850. }
  36851. }
  36852. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36853. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36854. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36855. /**
  36856. * Default Inputs manager for the FlyCamera.
  36857. * It groups all the default supported inputs for ease of use.
  36858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36859. */
  36860. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36861. /**
  36862. * Instantiates a new FlyCameraInputsManager.
  36863. * @param camera Defines the camera the inputs belong to.
  36864. */
  36865. constructor(camera: FlyCamera);
  36866. /**
  36867. * Add keyboard input support to the input manager.
  36868. * @returns the new FlyCameraKeyboardMoveInput().
  36869. */
  36870. addKeyboard(): FlyCameraInputsManager;
  36871. /**
  36872. * Add mouse input support to the input manager.
  36873. * @param touchEnabled Enable touch screen support.
  36874. * @returns the new FlyCameraMouseInput().
  36875. */
  36876. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36877. }
  36878. }
  36879. declare module "babylonjs/Cameras/flyCamera" {
  36880. import { Scene } from "babylonjs/scene";
  36881. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36883. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36884. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36885. /**
  36886. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36887. * such as in a 3D Space Shooter or a Flight Simulator.
  36888. */
  36889. export class FlyCamera extends TargetCamera {
  36890. /**
  36891. * Define the collision ellipsoid of the camera.
  36892. * This is helpful for simulating a camera body, like a player's body.
  36893. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36894. */
  36895. ellipsoid: Vector3;
  36896. /**
  36897. * Define an offset for the position of the ellipsoid around the camera.
  36898. * This can be helpful if the camera is attached away from the player's body center,
  36899. * such as at its head.
  36900. */
  36901. ellipsoidOffset: Vector3;
  36902. /**
  36903. * Enable or disable collisions of the camera with the rest of the scene objects.
  36904. */
  36905. checkCollisions: boolean;
  36906. /**
  36907. * Enable or disable gravity on the camera.
  36908. */
  36909. applyGravity: boolean;
  36910. /**
  36911. * Define the current direction the camera is moving to.
  36912. */
  36913. cameraDirection: Vector3;
  36914. /**
  36915. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36916. * This overrides and empties cameraRotation.
  36917. */
  36918. rotationQuaternion: Quaternion;
  36919. /**
  36920. * Track Roll to maintain the wanted Rolling when looking around.
  36921. */
  36922. _trackRoll: number;
  36923. /**
  36924. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36925. */
  36926. rollCorrect: number;
  36927. /**
  36928. * Mimic a banked turn, Rolling the camera when Yawing.
  36929. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36930. */
  36931. bankedTurn: boolean;
  36932. /**
  36933. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36934. */
  36935. bankedTurnLimit: number;
  36936. /**
  36937. * Value of 0 disables the banked Roll.
  36938. * Value of 1 is equal to the Yaw angle in radians.
  36939. */
  36940. bankedTurnMultiplier: number;
  36941. /**
  36942. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36943. */
  36944. inputs: FlyCameraInputsManager;
  36945. /**
  36946. * Gets the input sensibility for mouse input.
  36947. * Higher values reduce sensitivity.
  36948. */
  36949. /**
  36950. * Sets the input sensibility for a mouse input.
  36951. * Higher values reduce sensitivity.
  36952. */
  36953. angularSensibility: number;
  36954. /**
  36955. * Get the keys for camera movement forward.
  36956. */
  36957. /**
  36958. * Set the keys for camera movement forward.
  36959. */
  36960. keysForward: number[];
  36961. /**
  36962. * Get the keys for camera movement backward.
  36963. */
  36964. keysBackward: number[];
  36965. /**
  36966. * Get the keys for camera movement up.
  36967. */
  36968. /**
  36969. * Set the keys for camera movement up.
  36970. */
  36971. keysUp: number[];
  36972. /**
  36973. * Get the keys for camera movement down.
  36974. */
  36975. /**
  36976. * Set the keys for camera movement down.
  36977. */
  36978. keysDown: number[];
  36979. /**
  36980. * Get the keys for camera movement left.
  36981. */
  36982. /**
  36983. * Set the keys for camera movement left.
  36984. */
  36985. keysLeft: number[];
  36986. /**
  36987. * Set the keys for camera movement right.
  36988. */
  36989. /**
  36990. * Set the keys for camera movement right.
  36991. */
  36992. keysRight: number[];
  36993. /**
  36994. * Event raised when the camera collides with a mesh in the scene.
  36995. */
  36996. onCollide: (collidedMesh: AbstractMesh) => void;
  36997. private _collider;
  36998. private _needMoveForGravity;
  36999. private _oldPosition;
  37000. private _diffPosition;
  37001. private _newPosition;
  37002. /** @hidden */
  37003. _localDirection: Vector3;
  37004. /** @hidden */
  37005. _transformedDirection: Vector3;
  37006. /**
  37007. * Instantiates a FlyCamera.
  37008. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37009. * such as in a 3D Space Shooter or a Flight Simulator.
  37010. * @param name Define the name of the camera in the scene.
  37011. * @param position Define the starting position of the camera in the scene.
  37012. * @param scene Define the scene the camera belongs to.
  37013. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37014. */
  37015. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37016. /**
  37017. * Attach a control to the HTML DOM element.
  37018. * @param element Defines the element that listens to the input events.
  37019. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37020. */
  37021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37022. /**
  37023. * Detach a control from the HTML DOM element.
  37024. * The camera will stop reacting to that input.
  37025. * @param element Defines the element that listens to the input events.
  37026. */
  37027. detachControl(element: HTMLElement): void;
  37028. private _collisionMask;
  37029. /**
  37030. * Get the mask that the camera ignores in collision events.
  37031. */
  37032. /**
  37033. * Set the mask that the camera ignores in collision events.
  37034. */
  37035. collisionMask: number;
  37036. /** @hidden */
  37037. _collideWithWorld(displacement: Vector3): void;
  37038. /** @hidden */
  37039. private _onCollisionPositionChange;
  37040. /** @hidden */
  37041. _checkInputs(): void;
  37042. /** @hidden */
  37043. _decideIfNeedsToMove(): boolean;
  37044. /** @hidden */
  37045. _updatePosition(): void;
  37046. /**
  37047. * Restore the Roll to its target value at the rate specified.
  37048. * @param rate - Higher means slower restoring.
  37049. * @hidden
  37050. */
  37051. restoreRoll(rate: number): void;
  37052. /**
  37053. * Destroy the camera and release the current resources held by it.
  37054. */
  37055. dispose(): void;
  37056. /**
  37057. * Get the current object class name.
  37058. * @returns the class name.
  37059. */
  37060. getClassName(): string;
  37061. }
  37062. }
  37063. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37064. import { Nullable } from "babylonjs/types";
  37065. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37066. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37067. /**
  37068. * Listen to keyboard events to control the camera.
  37069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37070. */
  37071. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37072. /**
  37073. * Defines the camera the input is attached to.
  37074. */
  37075. camera: FlyCamera;
  37076. /**
  37077. * The list of keyboard keys used to control the forward move of the camera.
  37078. */
  37079. keysForward: number[];
  37080. /**
  37081. * The list of keyboard keys used to control the backward move of the camera.
  37082. */
  37083. keysBackward: number[];
  37084. /**
  37085. * The list of keyboard keys used to control the forward move of the camera.
  37086. */
  37087. keysUp: number[];
  37088. /**
  37089. * The list of keyboard keys used to control the backward move of the camera.
  37090. */
  37091. keysDown: number[];
  37092. /**
  37093. * The list of keyboard keys used to control the right strafe move of the camera.
  37094. */
  37095. keysRight: number[];
  37096. /**
  37097. * The list of keyboard keys used to control the left strafe move of the camera.
  37098. */
  37099. keysLeft: number[];
  37100. private _keys;
  37101. private _onCanvasBlurObserver;
  37102. private _onKeyboardObserver;
  37103. private _engine;
  37104. private _scene;
  37105. /**
  37106. * Attach the input controls to a specific dom element to get the input from.
  37107. * @param element Defines the element the controls should be listened from
  37108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37109. */
  37110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37111. /**
  37112. * Detach the current controls from the specified dom element.
  37113. * @param element Defines the element to stop listening the inputs from
  37114. */
  37115. detachControl(element: Nullable<HTMLElement>): void;
  37116. /**
  37117. * Gets the class name of the current intput.
  37118. * @returns the class name
  37119. */
  37120. getClassName(): string;
  37121. /** @hidden */
  37122. _onLostFocus(e: FocusEvent): void;
  37123. /**
  37124. * Get the friendly name associated with the input class.
  37125. * @returns the input friendly name
  37126. */
  37127. getSimpleName(): string;
  37128. /**
  37129. * Update the current camera state depending on the inputs that have been used this frame.
  37130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37131. */
  37132. checkInputs(): void;
  37133. }
  37134. }
  37135. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37136. import { Nullable } from "babylonjs/types";
  37137. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37138. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37139. /**
  37140. * Manage the mouse wheel inputs to control a follow camera.
  37141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37142. */
  37143. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37144. /**
  37145. * Defines the camera the input is attached to.
  37146. */
  37147. camera: FollowCamera;
  37148. /**
  37149. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37150. */
  37151. axisControlRadius: boolean;
  37152. /**
  37153. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37154. */
  37155. axisControlHeight: boolean;
  37156. /**
  37157. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37158. */
  37159. axisControlRotation: boolean;
  37160. /**
  37161. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37162. * relation to mouseWheel events.
  37163. */
  37164. wheelPrecision: number;
  37165. /**
  37166. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37167. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37168. */
  37169. wheelDeltaPercentage: number;
  37170. private _wheel;
  37171. private _observer;
  37172. /**
  37173. * Attach the input controls to a specific dom element to get the input from.
  37174. * @param element Defines the element the controls should be listened from
  37175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37176. */
  37177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37178. /**
  37179. * Detach the current controls from the specified dom element.
  37180. * @param element Defines the element to stop listening the inputs from
  37181. */
  37182. detachControl(element: Nullable<HTMLElement>): void;
  37183. /**
  37184. * Gets the class name of the current intput.
  37185. * @returns the class name
  37186. */
  37187. getClassName(): string;
  37188. /**
  37189. * Get the friendly name associated with the input class.
  37190. * @returns the input friendly name
  37191. */
  37192. getSimpleName(): string;
  37193. }
  37194. }
  37195. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37196. import { Nullable } from "babylonjs/types";
  37197. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37198. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37199. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37200. /**
  37201. * Manage the pointers inputs to control an follow camera.
  37202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37203. */
  37204. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37205. /**
  37206. * Defines the camera the input is attached to.
  37207. */
  37208. camera: FollowCamera;
  37209. /**
  37210. * Gets the class name of the current input.
  37211. * @returns the class name
  37212. */
  37213. getClassName(): string;
  37214. /**
  37215. * Defines the pointer angular sensibility along the X axis or how fast is
  37216. * the camera rotating.
  37217. * A negative number will reverse the axis direction.
  37218. */
  37219. angularSensibilityX: number;
  37220. /**
  37221. * Defines the pointer angular sensibility along the Y axis or how fast is
  37222. * the camera rotating.
  37223. * A negative number will reverse the axis direction.
  37224. */
  37225. angularSensibilityY: number;
  37226. /**
  37227. * Defines the pointer pinch precision or how fast is the camera zooming.
  37228. * A negative number will reverse the axis direction.
  37229. */
  37230. pinchPrecision: number;
  37231. /**
  37232. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37233. * from 0.
  37234. * It defines the percentage of current camera.radius to use as delta when
  37235. * pinch zoom is used.
  37236. */
  37237. pinchDeltaPercentage: number;
  37238. /**
  37239. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37240. */
  37241. axisXControlRadius: boolean;
  37242. /**
  37243. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37244. */
  37245. axisXControlHeight: boolean;
  37246. /**
  37247. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37248. */
  37249. axisXControlRotation: boolean;
  37250. /**
  37251. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37252. */
  37253. axisYControlRadius: boolean;
  37254. /**
  37255. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37256. */
  37257. axisYControlHeight: boolean;
  37258. /**
  37259. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37260. */
  37261. axisYControlRotation: boolean;
  37262. /**
  37263. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37264. */
  37265. axisPinchControlRadius: boolean;
  37266. /**
  37267. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37268. */
  37269. axisPinchControlHeight: boolean;
  37270. /**
  37271. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37272. */
  37273. axisPinchControlRotation: boolean;
  37274. /**
  37275. * Log error messages if basic misconfiguration has occurred.
  37276. */
  37277. warningEnable: boolean;
  37278. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37279. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37280. private _warningCounter;
  37281. private _warning;
  37282. }
  37283. }
  37284. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37285. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37286. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37287. /**
  37288. * Default Inputs manager for the FollowCamera.
  37289. * It groups all the default supported inputs for ease of use.
  37290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37291. */
  37292. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37293. /**
  37294. * Instantiates a new FollowCameraInputsManager.
  37295. * @param camera Defines the camera the inputs belong to
  37296. */
  37297. constructor(camera: FollowCamera);
  37298. /**
  37299. * Add keyboard input support to the input manager.
  37300. * @returns the current input manager
  37301. */
  37302. addKeyboard(): FollowCameraInputsManager;
  37303. /**
  37304. * Add mouse wheel input support to the input manager.
  37305. * @returns the current input manager
  37306. */
  37307. addMouseWheel(): FollowCameraInputsManager;
  37308. /**
  37309. * Add pointers input support to the input manager.
  37310. * @returns the current input manager
  37311. */
  37312. addPointers(): FollowCameraInputsManager;
  37313. /**
  37314. * Add orientation input support to the input manager.
  37315. * @returns the current input manager
  37316. */
  37317. addVRDeviceOrientation(): FollowCameraInputsManager;
  37318. }
  37319. }
  37320. declare module "babylonjs/Cameras/followCamera" {
  37321. import { Nullable } from "babylonjs/types";
  37322. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37323. import { Scene } from "babylonjs/scene";
  37324. import { Vector3 } from "babylonjs/Maths/math";
  37325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37326. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37327. /**
  37328. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37329. * an arc rotate version arcFollowCamera are available.
  37330. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37331. */
  37332. export class FollowCamera extends TargetCamera {
  37333. /**
  37334. * Distance the follow camera should follow an object at
  37335. */
  37336. radius: number;
  37337. /**
  37338. * Minimum allowed distance of the camera to the axis of rotation
  37339. * (The camera can not get closer).
  37340. * This can help limiting how the Camera is able to move in the scene.
  37341. */
  37342. lowerRadiusLimit: Nullable<number>;
  37343. /**
  37344. * Maximum allowed distance of the camera to the axis of rotation
  37345. * (The camera can not get further).
  37346. * This can help limiting how the Camera is able to move in the scene.
  37347. */
  37348. upperRadiusLimit: Nullable<number>;
  37349. /**
  37350. * Define a rotation offset between the camera and the object it follows
  37351. */
  37352. rotationOffset: number;
  37353. /**
  37354. * Minimum allowed angle to camera position relative to target object.
  37355. * This can help limiting how the Camera is able to move in the scene.
  37356. */
  37357. lowerRotationOffsetLimit: Nullable<number>;
  37358. /**
  37359. * Maximum allowed angle to camera position relative to target object.
  37360. * This can help limiting how the Camera is able to move in the scene.
  37361. */
  37362. upperRotationOffsetLimit: Nullable<number>;
  37363. /**
  37364. * Define a height offset between the camera and the object it follows.
  37365. * It can help following an object from the top (like a car chaing a plane)
  37366. */
  37367. heightOffset: number;
  37368. /**
  37369. * Minimum allowed height of camera position relative to target object.
  37370. * This can help limiting how the Camera is able to move in the scene.
  37371. */
  37372. lowerHeightOffsetLimit: Nullable<number>;
  37373. /**
  37374. * Maximum allowed height of camera position relative to target object.
  37375. * This can help limiting how the Camera is able to move in the scene.
  37376. */
  37377. upperHeightOffsetLimit: Nullable<number>;
  37378. /**
  37379. * Define how fast the camera can accelerate to follow it s target.
  37380. */
  37381. cameraAcceleration: number;
  37382. /**
  37383. * Define the speed limit of the camera following an object.
  37384. */
  37385. maxCameraSpeed: number;
  37386. /**
  37387. * Define the target of the camera.
  37388. */
  37389. lockedTarget: Nullable<AbstractMesh>;
  37390. /**
  37391. * Defines the input associated with the camera.
  37392. */
  37393. inputs: FollowCameraInputsManager;
  37394. /**
  37395. * Instantiates the follow camera.
  37396. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37397. * @param name Define the name of the camera in the scene
  37398. * @param position Define the position of the camera
  37399. * @param scene Define the scene the camera belong to
  37400. * @param lockedTarget Define the target of the camera
  37401. */
  37402. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37403. private _follow;
  37404. /**
  37405. * Attached controls to the current camera.
  37406. * @param element Defines the element the controls should be listened from
  37407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37408. */
  37409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37410. /**
  37411. * Detach the current controls from the camera.
  37412. * The camera will stop reacting to inputs.
  37413. * @param element Defines the element to stop listening the inputs from
  37414. */
  37415. detachControl(element: HTMLElement): void;
  37416. /** @hidden */
  37417. _checkInputs(): void;
  37418. private _checkLimits;
  37419. /**
  37420. * Gets the camera class name.
  37421. * @returns the class name
  37422. */
  37423. getClassName(): string;
  37424. }
  37425. /**
  37426. * Arc Rotate version of the follow camera.
  37427. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37428. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37429. */
  37430. export class ArcFollowCamera extends TargetCamera {
  37431. /** The longitudinal angle of the camera */
  37432. alpha: number;
  37433. /** The latitudinal angle of the camera */
  37434. beta: number;
  37435. /** The radius of the camera from its target */
  37436. radius: number;
  37437. /** Define the camera target (the messh it should follow) */
  37438. target: Nullable<AbstractMesh>;
  37439. private _cartesianCoordinates;
  37440. /**
  37441. * Instantiates a new ArcFollowCamera
  37442. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37443. * @param name Define the name of the camera
  37444. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37445. * @param beta Define the rotation angle of the camera around the elevation axis
  37446. * @param radius Define the radius of the camera from its target point
  37447. * @param target Define the target of the camera
  37448. * @param scene Define the scene the camera belongs to
  37449. */
  37450. constructor(name: string,
  37451. /** The longitudinal angle of the camera */
  37452. alpha: number,
  37453. /** The latitudinal angle of the camera */
  37454. beta: number,
  37455. /** The radius of the camera from its target */
  37456. radius: number,
  37457. /** Define the camera target (the messh it should follow) */
  37458. target: Nullable<AbstractMesh>, scene: Scene);
  37459. private _follow;
  37460. /** @hidden */
  37461. _checkInputs(): void;
  37462. /**
  37463. * Returns the class name of the object.
  37464. * It is mostly used internally for serialization purposes.
  37465. */
  37466. getClassName(): string;
  37467. }
  37468. }
  37469. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37470. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37471. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37472. import { Nullable } from "babylonjs/types";
  37473. /**
  37474. * Manage the keyboard inputs to control the movement of a follow camera.
  37475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37476. */
  37477. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37478. /**
  37479. * Defines the camera the input is attached to.
  37480. */
  37481. camera: FollowCamera;
  37482. /**
  37483. * Defines the list of key codes associated with the up action (increase heightOffset)
  37484. */
  37485. keysHeightOffsetIncr: number[];
  37486. /**
  37487. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37488. */
  37489. keysHeightOffsetDecr: number[];
  37490. /**
  37491. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37492. */
  37493. keysHeightOffsetModifierAlt: boolean;
  37494. /**
  37495. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37496. */
  37497. keysHeightOffsetModifierCtrl: boolean;
  37498. /**
  37499. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37500. */
  37501. keysHeightOffsetModifierShift: boolean;
  37502. /**
  37503. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37504. */
  37505. keysRotationOffsetIncr: number[];
  37506. /**
  37507. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37508. */
  37509. keysRotationOffsetDecr: number[];
  37510. /**
  37511. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37512. */
  37513. keysRotationOffsetModifierAlt: boolean;
  37514. /**
  37515. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37516. */
  37517. keysRotationOffsetModifierCtrl: boolean;
  37518. /**
  37519. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37520. */
  37521. keysRotationOffsetModifierShift: boolean;
  37522. /**
  37523. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37524. */
  37525. keysRadiusIncr: number[];
  37526. /**
  37527. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37528. */
  37529. keysRadiusDecr: number[];
  37530. /**
  37531. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37532. */
  37533. keysRadiusModifierAlt: boolean;
  37534. /**
  37535. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37536. */
  37537. keysRadiusModifierCtrl: boolean;
  37538. /**
  37539. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37540. */
  37541. keysRadiusModifierShift: boolean;
  37542. /**
  37543. * Defines the rate of change of heightOffset.
  37544. */
  37545. heightSensibility: number;
  37546. /**
  37547. * Defines the rate of change of rotationOffset.
  37548. */
  37549. rotationSensibility: number;
  37550. /**
  37551. * Defines the rate of change of radius.
  37552. */
  37553. radiusSensibility: number;
  37554. private _keys;
  37555. private _ctrlPressed;
  37556. private _altPressed;
  37557. private _shiftPressed;
  37558. private _onCanvasBlurObserver;
  37559. private _onKeyboardObserver;
  37560. private _engine;
  37561. private _scene;
  37562. /**
  37563. * Attach the input controls to a specific dom element to get the input from.
  37564. * @param element Defines the element the controls should be listened from
  37565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37566. */
  37567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37568. /**
  37569. * Detach the current controls from the specified dom element.
  37570. * @param element Defines the element to stop listening the inputs from
  37571. */
  37572. detachControl(element: Nullable<HTMLElement>): void;
  37573. /**
  37574. * Update the current camera state depending on the inputs that have been used this frame.
  37575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37576. */
  37577. checkInputs(): void;
  37578. /**
  37579. * Gets the class name of the current input.
  37580. * @returns the class name
  37581. */
  37582. getClassName(): string;
  37583. /**
  37584. * Get the friendly name associated with the input class.
  37585. * @returns the input friendly name
  37586. */
  37587. getSimpleName(): string;
  37588. /**
  37589. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37590. * allow modification of the heightOffset value.
  37591. */
  37592. private _modifierHeightOffset;
  37593. /**
  37594. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37595. * allow modification of the rotationOffset value.
  37596. */
  37597. private _modifierRotationOffset;
  37598. /**
  37599. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37600. * allow modification of the radius value.
  37601. */
  37602. private _modifierRadius;
  37603. }
  37604. }
  37605. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37606. import { Nullable } from "babylonjs/types";
  37607. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37608. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37609. module "babylonjs/Cameras/freeCameraInputsManager" {
  37610. interface FreeCameraInputsManager {
  37611. /**
  37612. * Add orientation input support to the input manager.
  37613. * @returns the current input manager
  37614. */
  37615. addDeviceOrientation(): FreeCameraInputsManager;
  37616. }
  37617. }
  37618. /**
  37619. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37620. * Screen rotation is taken into account.
  37621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37622. */
  37623. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37624. private _camera;
  37625. private _screenOrientationAngle;
  37626. private _constantTranform;
  37627. private _screenQuaternion;
  37628. private _alpha;
  37629. private _beta;
  37630. private _gamma;
  37631. /**
  37632. * Instantiates a new input
  37633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37634. */
  37635. constructor();
  37636. /**
  37637. * Define the camera controlled by the input.
  37638. */
  37639. camera: FreeCamera;
  37640. /**
  37641. * Attach the input controls to a specific dom element to get the input from.
  37642. * @param element Defines the element the controls should be listened from
  37643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37644. */
  37645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37646. private _orientationChanged;
  37647. private _deviceOrientation;
  37648. /**
  37649. * Detach the current controls from the specified dom element.
  37650. * @param element Defines the element to stop listening the inputs from
  37651. */
  37652. detachControl(element: Nullable<HTMLElement>): void;
  37653. /**
  37654. * Update the current camera state depending on the inputs that have been used this frame.
  37655. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37656. */
  37657. checkInputs(): void;
  37658. /**
  37659. * Gets the class name of the current intput.
  37660. * @returns the class name
  37661. */
  37662. getClassName(): string;
  37663. /**
  37664. * Get the friendly name associated with the input class.
  37665. * @returns the input friendly name
  37666. */
  37667. getSimpleName(): string;
  37668. }
  37669. }
  37670. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37671. import { Nullable } from "babylonjs/types";
  37672. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37673. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37674. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37675. /**
  37676. * Manage the gamepad inputs to control a free camera.
  37677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37678. */
  37679. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37680. /**
  37681. * Define the camera the input is attached to.
  37682. */
  37683. camera: FreeCamera;
  37684. /**
  37685. * Define the Gamepad controlling the input
  37686. */
  37687. gamepad: Nullable<Gamepad>;
  37688. /**
  37689. * Defines the gamepad rotation sensiblity.
  37690. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37691. */
  37692. gamepadAngularSensibility: number;
  37693. /**
  37694. * Defines the gamepad move sensiblity.
  37695. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37696. */
  37697. gamepadMoveSensibility: number;
  37698. private _onGamepadConnectedObserver;
  37699. private _onGamepadDisconnectedObserver;
  37700. private _cameraTransform;
  37701. private _deltaTransform;
  37702. private _vector3;
  37703. private _vector2;
  37704. /**
  37705. * Attach the input controls to a specific dom element to get the input from.
  37706. * @param element Defines the element the controls should be listened from
  37707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37708. */
  37709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37710. /**
  37711. * Detach the current controls from the specified dom element.
  37712. * @param element Defines the element to stop listening the inputs from
  37713. */
  37714. detachControl(element: Nullable<HTMLElement>): void;
  37715. /**
  37716. * Update the current camera state depending on the inputs that have been used this frame.
  37717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37718. */
  37719. checkInputs(): void;
  37720. /**
  37721. * Gets the class name of the current intput.
  37722. * @returns the class name
  37723. */
  37724. getClassName(): string;
  37725. /**
  37726. * Get the friendly name associated with the input class.
  37727. * @returns the input friendly name
  37728. */
  37729. getSimpleName(): string;
  37730. }
  37731. }
  37732. declare module "babylonjs/Misc/virtualJoystick" {
  37733. import { Nullable } from "babylonjs/types";
  37734. import { Vector3 } from "babylonjs/Maths/math";
  37735. /**
  37736. * Defines the potential axis of a Joystick
  37737. */
  37738. export enum JoystickAxis {
  37739. /** X axis */
  37740. X = 0,
  37741. /** Y axis */
  37742. Y = 1,
  37743. /** Z axis */
  37744. Z = 2
  37745. }
  37746. /**
  37747. * Class used to define virtual joystick (used in touch mode)
  37748. */
  37749. export class VirtualJoystick {
  37750. /**
  37751. * Gets or sets a boolean indicating that left and right values must be inverted
  37752. */
  37753. reverseLeftRight: boolean;
  37754. /**
  37755. * Gets or sets a boolean indicating that up and down values must be inverted
  37756. */
  37757. reverseUpDown: boolean;
  37758. /**
  37759. * Gets the offset value for the position (ie. the change of the position value)
  37760. */
  37761. deltaPosition: Vector3;
  37762. /**
  37763. * Gets a boolean indicating if the virtual joystick was pressed
  37764. */
  37765. pressed: boolean;
  37766. /**
  37767. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37768. */
  37769. static Canvas: Nullable<HTMLCanvasElement>;
  37770. private static _globalJoystickIndex;
  37771. private static vjCanvasContext;
  37772. private static vjCanvasWidth;
  37773. private static vjCanvasHeight;
  37774. private static halfWidth;
  37775. private _action;
  37776. private _axisTargetedByLeftAndRight;
  37777. private _axisTargetedByUpAndDown;
  37778. private _joystickSensibility;
  37779. private _inversedSensibility;
  37780. private _joystickPointerID;
  37781. private _joystickColor;
  37782. private _joystickPointerPos;
  37783. private _joystickPreviousPointerPos;
  37784. private _joystickPointerStartPos;
  37785. private _deltaJoystickVector;
  37786. private _leftJoystick;
  37787. private _touches;
  37788. private _onPointerDownHandlerRef;
  37789. private _onPointerMoveHandlerRef;
  37790. private _onPointerUpHandlerRef;
  37791. private _onResize;
  37792. /**
  37793. * Creates a new virtual joystick
  37794. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37795. */
  37796. constructor(leftJoystick?: boolean);
  37797. /**
  37798. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37799. * @param newJoystickSensibility defines the new sensibility
  37800. */
  37801. setJoystickSensibility(newJoystickSensibility: number): void;
  37802. private _onPointerDown;
  37803. private _onPointerMove;
  37804. private _onPointerUp;
  37805. /**
  37806. * Change the color of the virtual joystick
  37807. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37808. */
  37809. setJoystickColor(newColor: string): void;
  37810. /**
  37811. * Defines a callback to call when the joystick is touched
  37812. * @param action defines the callback
  37813. */
  37814. setActionOnTouch(action: () => any): void;
  37815. /**
  37816. * Defines which axis you'd like to control for left & right
  37817. * @param axis defines the axis to use
  37818. */
  37819. setAxisForLeftRight(axis: JoystickAxis): void;
  37820. /**
  37821. * Defines which axis you'd like to control for up & down
  37822. * @param axis defines the axis to use
  37823. */
  37824. setAxisForUpDown(axis: JoystickAxis): void;
  37825. private _drawVirtualJoystick;
  37826. /**
  37827. * Release internal HTML canvas
  37828. */
  37829. releaseCanvas(): void;
  37830. }
  37831. }
  37832. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37833. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37834. import { Nullable } from "babylonjs/types";
  37835. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37836. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37837. module "babylonjs/Cameras/freeCameraInputsManager" {
  37838. interface FreeCameraInputsManager {
  37839. /**
  37840. * Add virtual joystick input support to the input manager.
  37841. * @returns the current input manager
  37842. */
  37843. addVirtualJoystick(): FreeCameraInputsManager;
  37844. }
  37845. }
  37846. /**
  37847. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37849. */
  37850. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37851. /**
  37852. * Defines the camera the input is attached to.
  37853. */
  37854. camera: FreeCamera;
  37855. private _leftjoystick;
  37856. private _rightjoystick;
  37857. /**
  37858. * Gets the left stick of the virtual joystick.
  37859. * @returns The virtual Joystick
  37860. */
  37861. getLeftJoystick(): VirtualJoystick;
  37862. /**
  37863. * Gets the right stick of the virtual joystick.
  37864. * @returns The virtual Joystick
  37865. */
  37866. getRightJoystick(): VirtualJoystick;
  37867. /**
  37868. * Update the current camera state depending on the inputs that have been used this frame.
  37869. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37870. */
  37871. checkInputs(): void;
  37872. /**
  37873. * Attach the input controls to a specific dom element to get the input from.
  37874. * @param element Defines the element the controls should be listened from
  37875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37876. */
  37877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37878. /**
  37879. * Detach the current controls from the specified dom element.
  37880. * @param element Defines the element to stop listening the inputs from
  37881. */
  37882. detachControl(element: Nullable<HTMLElement>): void;
  37883. /**
  37884. * Gets the class name of the current intput.
  37885. * @returns the class name
  37886. */
  37887. getClassName(): string;
  37888. /**
  37889. * Get the friendly name associated with the input class.
  37890. * @returns the input friendly name
  37891. */
  37892. getSimpleName(): string;
  37893. }
  37894. }
  37895. declare module "babylonjs/Cameras/Inputs/index" {
  37896. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37897. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37898. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37899. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37900. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37901. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37902. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37903. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37904. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37905. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37906. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37907. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37908. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37909. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37910. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37911. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37912. }
  37913. declare module "babylonjs/Cameras/touchCamera" {
  37914. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37915. import { Scene } from "babylonjs/scene";
  37916. import { Vector3 } from "babylonjs/Maths/math";
  37917. /**
  37918. * This represents a FPS type of camera controlled by touch.
  37919. * This is like a universal camera minus the Gamepad controls.
  37920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37921. */
  37922. export class TouchCamera extends FreeCamera {
  37923. /**
  37924. * Defines the touch sensibility for rotation.
  37925. * The higher the faster.
  37926. */
  37927. touchAngularSensibility: number;
  37928. /**
  37929. * Defines the touch sensibility for move.
  37930. * The higher the faster.
  37931. */
  37932. touchMoveSensibility: number;
  37933. /**
  37934. * Instantiates a new touch camera.
  37935. * This represents a FPS type of camera controlled by touch.
  37936. * This is like a universal camera minus the Gamepad controls.
  37937. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37938. * @param name Define the name of the camera in the scene
  37939. * @param position Define the start position of the camera in the scene
  37940. * @param scene Define the scene the camera belongs to
  37941. */
  37942. constructor(name: string, position: Vector3, scene: Scene);
  37943. /**
  37944. * Gets the current object class name.
  37945. * @return the class name
  37946. */
  37947. getClassName(): string;
  37948. /** @hidden */
  37949. _setupInputs(): void;
  37950. }
  37951. }
  37952. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37953. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37954. import { Scene } from "babylonjs/scene";
  37955. import { Vector3, Axis } from "babylonjs/Maths/math";
  37956. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37957. /**
  37958. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37959. * being tilted forward or back and left or right.
  37960. */
  37961. export class DeviceOrientationCamera extends FreeCamera {
  37962. private _initialQuaternion;
  37963. private _quaternionCache;
  37964. /**
  37965. * Creates a new device orientation camera
  37966. * @param name The name of the camera
  37967. * @param position The start position camera
  37968. * @param scene The scene the camera belongs to
  37969. */
  37970. constructor(name: string, position: Vector3, scene: Scene);
  37971. /**
  37972. * Gets the current instance class name ("DeviceOrientationCamera").
  37973. * This helps avoiding instanceof at run time.
  37974. * @returns the class name
  37975. */
  37976. getClassName(): string;
  37977. /**
  37978. * @hidden
  37979. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37980. */
  37981. _checkInputs(): void;
  37982. /**
  37983. * Reset the camera to its default orientation on the specified axis only.
  37984. * @param axis The axis to reset
  37985. */
  37986. resetToCurrentRotation(axis?: Axis): void;
  37987. }
  37988. }
  37989. declare module "babylonjs/Cameras/universalCamera" {
  37990. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37991. import { Scene } from "babylonjs/scene";
  37992. import { Vector3 } from "babylonjs/Maths/math";
  37993. /**
  37994. * 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,
  37995. * which still works and will still be found in many Playgrounds.
  37996. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37997. */
  37998. export class UniversalCamera extends TouchCamera {
  37999. /**
  38000. * Defines the gamepad rotation sensiblity.
  38001. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38002. */
  38003. gamepadAngularSensibility: number;
  38004. /**
  38005. * Defines the gamepad move sensiblity.
  38006. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38007. */
  38008. gamepadMoveSensibility: number;
  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. * @param name Define the name of the camera in the scene
  38014. * @param position Define the start position of the camera in the scene
  38015. * @param scene Define the scene the camera belongs to
  38016. */
  38017. constructor(name: string, position: Vector3, scene: Scene);
  38018. /**
  38019. * Gets the current object class name.
  38020. * @return the class name
  38021. */
  38022. getClassName(): string;
  38023. }
  38024. }
  38025. declare module "babylonjs/Cameras/gamepadCamera" {
  38026. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38027. import { Scene } from "babylonjs/scene";
  38028. import { Vector3 } from "babylonjs/Maths/math";
  38029. /**
  38030. * This represents a FPS type of camera. This is only here for back compat purpose.
  38031. * Please use the UniversalCamera instead as both are identical.
  38032. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38033. */
  38034. export class GamepadCamera extends UniversalCamera {
  38035. /**
  38036. * Instantiates a new Gamepad Camera
  38037. * This represents a FPS type of camera. This is only here for back compat purpose.
  38038. * Please use the UniversalCamera instead as both are identical.
  38039. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38040. * @param name Define the name of the camera in the scene
  38041. * @param position Define the start position of the camera in the scene
  38042. * @param scene Define the scene the camera belongs to
  38043. */
  38044. constructor(name: string, position: Vector3, scene: Scene);
  38045. /**
  38046. * Gets the current object class name.
  38047. * @return the class name
  38048. */
  38049. getClassName(): string;
  38050. }
  38051. }
  38052. declare module "babylonjs/Shaders/pass.fragment" {
  38053. /** @hidden */
  38054. export var passPixelShader: {
  38055. name: string;
  38056. shader: string;
  38057. };
  38058. }
  38059. declare module "babylonjs/Shaders/passCube.fragment" {
  38060. /** @hidden */
  38061. export var passCubePixelShader: {
  38062. name: string;
  38063. shader: string;
  38064. };
  38065. }
  38066. declare module "babylonjs/PostProcesses/passPostProcess" {
  38067. import { Nullable } from "babylonjs/types";
  38068. import { Camera } from "babylonjs/Cameras/camera";
  38069. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38070. import { Engine } from "babylonjs/Engines/engine";
  38071. import "babylonjs/Shaders/pass.fragment";
  38072. import "babylonjs/Shaders/passCube.fragment";
  38073. /**
  38074. * PassPostProcess which produces an output the same as it's input
  38075. */
  38076. export class PassPostProcess extends PostProcess {
  38077. /**
  38078. * Creates the PassPostProcess
  38079. * @param name The name of the effect.
  38080. * @param options The required width/height ratio to downsize to before computing the render pass.
  38081. * @param camera The camera to apply the render pass to.
  38082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38083. * @param engine The engine which the post process will be applied. (default: current engine)
  38084. * @param reusable If the post process can be reused on the same frame. (default: false)
  38085. * @param textureType The type of texture to be used when performing the post processing.
  38086. * @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)
  38087. */
  38088. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38089. }
  38090. /**
  38091. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38092. */
  38093. export class PassCubePostProcess extends PostProcess {
  38094. private _face;
  38095. /**
  38096. * Gets or sets the cube face to display.
  38097. * * 0 is +X
  38098. * * 1 is -X
  38099. * * 2 is +Y
  38100. * * 3 is -Y
  38101. * * 4 is +Z
  38102. * * 5 is -Z
  38103. */
  38104. face: number;
  38105. /**
  38106. * Creates the PassCubePostProcess
  38107. * @param name The name of the effect.
  38108. * @param options The required width/height ratio to downsize to before computing the render pass.
  38109. * @param camera The camera to apply the render pass to.
  38110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38111. * @param engine The engine which the post process will be applied. (default: current engine)
  38112. * @param reusable If the post process can be reused on the same frame. (default: false)
  38113. * @param textureType The type of texture to be used when performing the post processing.
  38114. * @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)
  38115. */
  38116. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38117. }
  38118. }
  38119. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38120. /** @hidden */
  38121. export var anaglyphPixelShader: {
  38122. name: string;
  38123. shader: string;
  38124. };
  38125. }
  38126. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38127. import { Engine } from "babylonjs/Engines/engine";
  38128. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38129. import { Camera } from "babylonjs/Cameras/camera";
  38130. import "babylonjs/Shaders/anaglyph.fragment";
  38131. /**
  38132. * Postprocess used to generate anaglyphic rendering
  38133. */
  38134. export class AnaglyphPostProcess extends PostProcess {
  38135. private _passedProcess;
  38136. /**
  38137. * Creates a new AnaglyphPostProcess
  38138. * @param name defines postprocess name
  38139. * @param options defines creation options or target ratio scale
  38140. * @param rigCameras defines cameras using this postprocess
  38141. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38142. * @param engine defines hosting engine
  38143. * @param reusable defines if the postprocess will be reused multiple times per frame
  38144. */
  38145. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38146. }
  38147. }
  38148. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38149. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38150. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38151. import { Scene } from "babylonjs/scene";
  38152. import { Vector3 } from "babylonjs/Maths/math";
  38153. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38154. /**
  38155. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38156. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38157. */
  38158. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38159. /**
  38160. * Creates a new AnaglyphArcRotateCamera
  38161. * @param name defines camera name
  38162. * @param alpha defines alpha angle (in radians)
  38163. * @param beta defines beta angle (in radians)
  38164. * @param radius defines radius
  38165. * @param target defines camera target
  38166. * @param interaxialDistance defines distance between each color axis
  38167. * @param scene defines the hosting scene
  38168. */
  38169. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38170. /**
  38171. * Gets camera class name
  38172. * @returns AnaglyphArcRotateCamera
  38173. */
  38174. getClassName(): string;
  38175. }
  38176. }
  38177. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38178. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38179. import { Scene } from "babylonjs/scene";
  38180. import { Vector3 } from "babylonjs/Maths/math";
  38181. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38182. /**
  38183. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38184. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38185. */
  38186. export class AnaglyphFreeCamera extends FreeCamera {
  38187. /**
  38188. * Creates a new AnaglyphFreeCamera
  38189. * @param name defines camera name
  38190. * @param position defines initial position
  38191. * @param interaxialDistance defines distance between each color axis
  38192. * @param scene defines the hosting scene
  38193. */
  38194. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38195. /**
  38196. * Gets camera class name
  38197. * @returns AnaglyphFreeCamera
  38198. */
  38199. getClassName(): string;
  38200. }
  38201. }
  38202. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38203. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38204. import { Scene } from "babylonjs/scene";
  38205. import { Vector3 } from "babylonjs/Maths/math";
  38206. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38207. /**
  38208. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38209. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38210. */
  38211. export class AnaglyphGamepadCamera extends GamepadCamera {
  38212. /**
  38213. * Creates a new AnaglyphGamepadCamera
  38214. * @param name defines camera name
  38215. * @param position defines initial position
  38216. * @param interaxialDistance defines distance between each color axis
  38217. * @param scene defines the hosting scene
  38218. */
  38219. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38220. /**
  38221. * Gets camera class name
  38222. * @returns AnaglyphGamepadCamera
  38223. */
  38224. getClassName(): string;
  38225. }
  38226. }
  38227. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38228. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38229. import { Scene } from "babylonjs/scene";
  38230. import { Vector3 } from "babylonjs/Maths/math";
  38231. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38232. /**
  38233. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38234. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38235. */
  38236. export class AnaglyphUniversalCamera extends UniversalCamera {
  38237. /**
  38238. * Creates a new AnaglyphUniversalCamera
  38239. * @param name defines camera name
  38240. * @param position defines initial position
  38241. * @param interaxialDistance defines distance between each color axis
  38242. * @param scene defines the hosting scene
  38243. */
  38244. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38245. /**
  38246. * Gets camera class name
  38247. * @returns AnaglyphUniversalCamera
  38248. */
  38249. getClassName(): string;
  38250. }
  38251. }
  38252. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38253. /** @hidden */
  38254. export var stereoscopicInterlacePixelShader: {
  38255. name: string;
  38256. shader: string;
  38257. };
  38258. }
  38259. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38260. import { Camera } from "babylonjs/Cameras/camera";
  38261. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38262. import { Engine } from "babylonjs/Engines/engine";
  38263. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38264. /**
  38265. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38266. */
  38267. export class StereoscopicInterlacePostProcess extends PostProcess {
  38268. private _stepSize;
  38269. private _passedProcess;
  38270. /**
  38271. * Initializes a StereoscopicInterlacePostProcess
  38272. * @param name The name of the effect.
  38273. * @param rigCameras The rig cameras to be appled to the post process
  38274. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38276. * @param engine The engine which the post process will be applied. (default: current engine)
  38277. * @param reusable If the post process can be reused on the same frame. (default: false)
  38278. */
  38279. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38280. }
  38281. }
  38282. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38283. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38284. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38285. import { Scene } from "babylonjs/scene";
  38286. import { Vector3 } from "babylonjs/Maths/math";
  38287. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38288. /**
  38289. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38290. * @see http://doc.babylonjs.com/features/cameras
  38291. */
  38292. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38293. /**
  38294. * Creates a new StereoscopicArcRotateCamera
  38295. * @param name defines camera name
  38296. * @param alpha defines alpha angle (in radians)
  38297. * @param beta defines beta angle (in radians)
  38298. * @param radius defines radius
  38299. * @param target defines camera target
  38300. * @param interaxialDistance defines distance between each color axis
  38301. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38302. * @param scene defines the hosting scene
  38303. */
  38304. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38305. /**
  38306. * Gets camera class name
  38307. * @returns StereoscopicArcRotateCamera
  38308. */
  38309. getClassName(): string;
  38310. }
  38311. }
  38312. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38313. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38314. import { Scene } from "babylonjs/scene";
  38315. import { Vector3 } from "babylonjs/Maths/math";
  38316. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38317. /**
  38318. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38319. * @see http://doc.babylonjs.com/features/cameras
  38320. */
  38321. export class StereoscopicFreeCamera extends FreeCamera {
  38322. /**
  38323. * Creates a new StereoscopicFreeCamera
  38324. * @param name defines camera name
  38325. * @param position defines initial position
  38326. * @param interaxialDistance defines distance between each color axis
  38327. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38328. * @param scene defines the hosting scene
  38329. */
  38330. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38331. /**
  38332. * Gets camera class name
  38333. * @returns StereoscopicFreeCamera
  38334. */
  38335. getClassName(): string;
  38336. }
  38337. }
  38338. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38339. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38340. import { Scene } from "babylonjs/scene";
  38341. import { Vector3 } from "babylonjs/Maths/math";
  38342. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38343. /**
  38344. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38345. * @see http://doc.babylonjs.com/features/cameras
  38346. */
  38347. export class StereoscopicGamepadCamera extends GamepadCamera {
  38348. /**
  38349. * Creates a new StereoscopicGamepadCamera
  38350. * @param name defines camera name
  38351. * @param position defines initial position
  38352. * @param interaxialDistance defines distance between each color axis
  38353. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38354. * @param scene defines the hosting scene
  38355. */
  38356. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38357. /**
  38358. * Gets camera class name
  38359. * @returns StereoscopicGamepadCamera
  38360. */
  38361. getClassName(): string;
  38362. }
  38363. }
  38364. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38365. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38366. import { Scene } from "babylonjs/scene";
  38367. import { Vector3 } from "babylonjs/Maths/math";
  38368. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38369. /**
  38370. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38371. * @see http://doc.babylonjs.com/features/cameras
  38372. */
  38373. export class StereoscopicUniversalCamera extends UniversalCamera {
  38374. /**
  38375. * Creates a new StereoscopicUniversalCamera
  38376. * @param name defines camera name
  38377. * @param position defines initial position
  38378. * @param interaxialDistance defines distance between each color axis
  38379. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38380. * @param scene defines the hosting scene
  38381. */
  38382. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38383. /**
  38384. * Gets camera class name
  38385. * @returns StereoscopicUniversalCamera
  38386. */
  38387. getClassName(): string;
  38388. }
  38389. }
  38390. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38391. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38392. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38393. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38394. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38395. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38396. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38397. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38398. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38399. }
  38400. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38401. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38402. import { Scene } from "babylonjs/scene";
  38403. import { Vector3 } from "babylonjs/Maths/math";
  38404. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38405. /**
  38406. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38407. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38408. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38409. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38410. */
  38411. export class VirtualJoysticksCamera extends FreeCamera {
  38412. /**
  38413. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38414. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38415. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38416. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38417. * @param name Define the name of the camera in the scene
  38418. * @param position Define the start position of the camera in the scene
  38419. * @param scene Define the scene the camera belongs to
  38420. */
  38421. constructor(name: string, position: Vector3, scene: Scene);
  38422. /**
  38423. * Gets the current object class name.
  38424. * @return the class name
  38425. */
  38426. getClassName(): string;
  38427. }
  38428. }
  38429. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38430. import { Matrix } from "babylonjs/Maths/math";
  38431. /**
  38432. * This represents all the required metrics to create a VR camera.
  38433. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38434. */
  38435. export class VRCameraMetrics {
  38436. /**
  38437. * Define the horizontal resolution off the screen.
  38438. */
  38439. hResolution: number;
  38440. /**
  38441. * Define the vertical resolution off the screen.
  38442. */
  38443. vResolution: number;
  38444. /**
  38445. * Define the horizontal screen size.
  38446. */
  38447. hScreenSize: number;
  38448. /**
  38449. * Define the vertical screen size.
  38450. */
  38451. vScreenSize: number;
  38452. /**
  38453. * Define the vertical screen center position.
  38454. */
  38455. vScreenCenter: number;
  38456. /**
  38457. * Define the distance of the eyes to the screen.
  38458. */
  38459. eyeToScreenDistance: number;
  38460. /**
  38461. * Define the distance between both lenses
  38462. */
  38463. lensSeparationDistance: number;
  38464. /**
  38465. * Define the distance between both viewer's eyes.
  38466. */
  38467. interpupillaryDistance: number;
  38468. /**
  38469. * Define the distortion factor of the VR postprocess.
  38470. * Please, touch with care.
  38471. */
  38472. distortionK: number[];
  38473. /**
  38474. * Define the chromatic aberration correction factors for the VR post process.
  38475. */
  38476. chromaAbCorrection: number[];
  38477. /**
  38478. * Define the scale factor of the post process.
  38479. * The smaller the better but the slower.
  38480. */
  38481. postProcessScaleFactor: number;
  38482. /**
  38483. * Define an offset for the lens center.
  38484. */
  38485. lensCenterOffset: number;
  38486. /**
  38487. * Define if the current vr camera should compensate the distortion of the lense or not.
  38488. */
  38489. compensateDistortion: boolean;
  38490. /**
  38491. * Gets the rendering aspect ratio based on the provided resolutions.
  38492. */
  38493. readonly aspectRatio: number;
  38494. /**
  38495. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38496. */
  38497. readonly aspectRatioFov: number;
  38498. /**
  38499. * @hidden
  38500. */
  38501. readonly leftHMatrix: Matrix;
  38502. /**
  38503. * @hidden
  38504. */
  38505. readonly rightHMatrix: Matrix;
  38506. /**
  38507. * @hidden
  38508. */
  38509. readonly leftPreViewMatrix: Matrix;
  38510. /**
  38511. * @hidden
  38512. */
  38513. readonly rightPreViewMatrix: Matrix;
  38514. /**
  38515. * Get the default VRMetrics based on the most generic setup.
  38516. * @returns the default vr metrics
  38517. */
  38518. static GetDefault(): VRCameraMetrics;
  38519. }
  38520. }
  38521. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38522. /** @hidden */
  38523. export var vrDistortionCorrectionPixelShader: {
  38524. name: string;
  38525. shader: string;
  38526. };
  38527. }
  38528. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38529. import { Camera } from "babylonjs/Cameras/camera";
  38530. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38531. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38532. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38533. /**
  38534. * VRDistortionCorrectionPostProcess used for mobile VR
  38535. */
  38536. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38537. private _isRightEye;
  38538. private _distortionFactors;
  38539. private _postProcessScaleFactor;
  38540. private _lensCenterOffset;
  38541. private _scaleIn;
  38542. private _scaleFactor;
  38543. private _lensCenter;
  38544. /**
  38545. * Initializes the VRDistortionCorrectionPostProcess
  38546. * @param name The name of the effect.
  38547. * @param camera The camera to apply the render pass to.
  38548. * @param isRightEye If this is for the right eye distortion
  38549. * @param vrMetrics All the required metrics for the VR camera
  38550. */
  38551. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38552. }
  38553. }
  38554. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38555. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38556. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38557. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38558. import { Scene } from "babylonjs/scene";
  38559. import { Vector3 } from "babylonjs/Maths/math";
  38560. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38561. import "babylonjs/Cameras/RigModes/vrRigMode";
  38562. /**
  38563. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38564. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38565. */
  38566. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38567. /**
  38568. * Creates a new VRDeviceOrientationArcRotateCamera
  38569. * @param name defines camera name
  38570. * @param alpha defines the camera rotation along the logitudinal axis
  38571. * @param beta defines the camera rotation along the latitudinal axis
  38572. * @param radius defines the camera distance from its target
  38573. * @param target defines the camera target
  38574. * @param scene defines the scene the camera belongs to
  38575. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38576. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38577. */
  38578. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38579. /**
  38580. * Gets camera class name
  38581. * @returns VRDeviceOrientationArcRotateCamera
  38582. */
  38583. getClassName(): string;
  38584. }
  38585. }
  38586. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38587. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38588. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38589. import { Scene } from "babylonjs/scene";
  38590. import { Vector3 } from "babylonjs/Maths/math";
  38591. import "babylonjs/Cameras/RigModes/vrRigMode";
  38592. /**
  38593. * Camera used to simulate VR rendering (based on FreeCamera)
  38594. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38595. */
  38596. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38597. /**
  38598. * Creates a new VRDeviceOrientationFreeCamera
  38599. * @param name defines camera name
  38600. * @param position defines the start position of the camera
  38601. * @param scene defines the scene the camera belongs to
  38602. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38603. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38604. */
  38605. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38606. /**
  38607. * Gets camera class name
  38608. * @returns VRDeviceOrientationFreeCamera
  38609. */
  38610. getClassName(): string;
  38611. }
  38612. }
  38613. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38614. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38615. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38616. import { Scene } from "babylonjs/scene";
  38617. import { Vector3 } from "babylonjs/Maths/math";
  38618. /**
  38619. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38620. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38621. */
  38622. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38623. /**
  38624. * Creates a new VRDeviceOrientationGamepadCamera
  38625. * @param name defines camera name
  38626. * @param position defines the start position of the camera
  38627. * @param scene defines the scene the camera belongs to
  38628. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38629. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38630. */
  38631. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38632. /**
  38633. * Gets camera class name
  38634. * @returns VRDeviceOrientationGamepadCamera
  38635. */
  38636. getClassName(): string;
  38637. }
  38638. }
  38639. declare module "babylonjs/Gamepads/xboxGamepad" {
  38640. import { Observable } from "babylonjs/Misc/observable";
  38641. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38642. /**
  38643. * Defines supported buttons for XBox360 compatible gamepads
  38644. */
  38645. export enum Xbox360Button {
  38646. /** A */
  38647. A = 0,
  38648. /** B */
  38649. B = 1,
  38650. /** X */
  38651. X = 2,
  38652. /** Y */
  38653. Y = 3,
  38654. /** Start */
  38655. Start = 4,
  38656. /** Back */
  38657. Back = 5,
  38658. /** Left button */
  38659. LB = 6,
  38660. /** Right button */
  38661. RB = 7,
  38662. /** Left stick */
  38663. LeftStick = 8,
  38664. /** Right stick */
  38665. RightStick = 9
  38666. }
  38667. /** Defines values for XBox360 DPad */
  38668. export enum Xbox360Dpad {
  38669. /** Up */
  38670. Up = 0,
  38671. /** Down */
  38672. Down = 1,
  38673. /** Left */
  38674. Left = 2,
  38675. /** Right */
  38676. Right = 3
  38677. }
  38678. /**
  38679. * Defines a XBox360 gamepad
  38680. */
  38681. export class Xbox360Pad extends Gamepad {
  38682. private _leftTrigger;
  38683. private _rightTrigger;
  38684. private _onlefttriggerchanged;
  38685. private _onrighttriggerchanged;
  38686. private _onbuttondown;
  38687. private _onbuttonup;
  38688. private _ondpaddown;
  38689. private _ondpadup;
  38690. /** Observable raised when a button is pressed */
  38691. onButtonDownObservable: Observable<Xbox360Button>;
  38692. /** Observable raised when a button is released */
  38693. onButtonUpObservable: Observable<Xbox360Button>;
  38694. /** Observable raised when a pad is pressed */
  38695. onPadDownObservable: Observable<Xbox360Dpad>;
  38696. /** Observable raised when a pad is released */
  38697. onPadUpObservable: Observable<Xbox360Dpad>;
  38698. private _buttonA;
  38699. private _buttonB;
  38700. private _buttonX;
  38701. private _buttonY;
  38702. private _buttonBack;
  38703. private _buttonStart;
  38704. private _buttonLB;
  38705. private _buttonRB;
  38706. private _buttonLeftStick;
  38707. private _buttonRightStick;
  38708. private _dPadUp;
  38709. private _dPadDown;
  38710. private _dPadLeft;
  38711. private _dPadRight;
  38712. private _isXboxOnePad;
  38713. /**
  38714. * Creates a new XBox360 gamepad object
  38715. * @param id defines the id of this gamepad
  38716. * @param index defines its index
  38717. * @param gamepad defines the internal HTML gamepad object
  38718. * @param xboxOne defines if it is a XBox One gamepad
  38719. */
  38720. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38721. /**
  38722. * Defines the callback to call when left trigger is pressed
  38723. * @param callback defines the callback to use
  38724. */
  38725. onlefttriggerchanged(callback: (value: number) => void): void;
  38726. /**
  38727. * Defines the callback to call when right trigger is pressed
  38728. * @param callback defines the callback to use
  38729. */
  38730. onrighttriggerchanged(callback: (value: number) => void): void;
  38731. /**
  38732. * Gets the left trigger value
  38733. */
  38734. /**
  38735. * Sets the left trigger value
  38736. */
  38737. leftTrigger: number;
  38738. /**
  38739. * Gets the right trigger value
  38740. */
  38741. /**
  38742. * Sets the right trigger value
  38743. */
  38744. rightTrigger: number;
  38745. /**
  38746. * Defines the callback to call when a button is pressed
  38747. * @param callback defines the callback to use
  38748. */
  38749. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38750. /**
  38751. * Defines the callback to call when a button is released
  38752. * @param callback defines the callback to use
  38753. */
  38754. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38755. /**
  38756. * Defines the callback to call when a pad is pressed
  38757. * @param callback defines the callback to use
  38758. */
  38759. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38760. /**
  38761. * Defines the callback to call when a pad is released
  38762. * @param callback defines the callback to use
  38763. */
  38764. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38765. private _setButtonValue;
  38766. private _setDPadValue;
  38767. /**
  38768. * Gets the value of the `A` button
  38769. */
  38770. /**
  38771. * Sets the value of the `A` button
  38772. */
  38773. buttonA: number;
  38774. /**
  38775. * Gets the value of the `B` button
  38776. */
  38777. /**
  38778. * Sets the value of the `B` button
  38779. */
  38780. buttonB: number;
  38781. /**
  38782. * Gets the value of the `X` button
  38783. */
  38784. /**
  38785. * Sets the value of the `X` button
  38786. */
  38787. buttonX: number;
  38788. /**
  38789. * Gets the value of the `Y` button
  38790. */
  38791. /**
  38792. * Sets the value of the `Y` button
  38793. */
  38794. buttonY: number;
  38795. /**
  38796. * Gets the value of the `Start` button
  38797. */
  38798. /**
  38799. * Sets the value of the `Start` button
  38800. */
  38801. buttonStart: number;
  38802. /**
  38803. * Gets the value of the `Back` button
  38804. */
  38805. /**
  38806. * Sets the value of the `Back` button
  38807. */
  38808. buttonBack: number;
  38809. /**
  38810. * Gets the value of the `Left` button
  38811. */
  38812. /**
  38813. * Sets the value of the `Left` button
  38814. */
  38815. buttonLB: number;
  38816. /**
  38817. * Gets the value of the `Right` button
  38818. */
  38819. /**
  38820. * Sets the value of the `Right` button
  38821. */
  38822. buttonRB: number;
  38823. /**
  38824. * Gets the value of the Left joystick
  38825. */
  38826. /**
  38827. * Sets the value of the Left joystick
  38828. */
  38829. buttonLeftStick: number;
  38830. /**
  38831. * Gets the value of the Right joystick
  38832. */
  38833. /**
  38834. * Sets the value of the Right joystick
  38835. */
  38836. buttonRightStick: number;
  38837. /**
  38838. * Gets the value of D-pad up
  38839. */
  38840. /**
  38841. * Sets the value of D-pad up
  38842. */
  38843. dPadUp: number;
  38844. /**
  38845. * Gets the value of D-pad down
  38846. */
  38847. /**
  38848. * Sets the value of D-pad down
  38849. */
  38850. dPadDown: number;
  38851. /**
  38852. * Gets the value of D-pad left
  38853. */
  38854. /**
  38855. * Sets the value of D-pad left
  38856. */
  38857. dPadLeft: number;
  38858. /**
  38859. * Gets the value of D-pad right
  38860. */
  38861. /**
  38862. * Sets the value of D-pad right
  38863. */
  38864. dPadRight: number;
  38865. /**
  38866. * Force the gamepad to synchronize with device values
  38867. */
  38868. update(): void;
  38869. /**
  38870. * Disposes the gamepad
  38871. */
  38872. dispose(): void;
  38873. }
  38874. }
  38875. declare module "babylonjs/Materials/pushMaterial" {
  38876. import { Nullable } from "babylonjs/types";
  38877. import { Scene } from "babylonjs/scene";
  38878. import { Matrix } from "babylonjs/Maths/math";
  38879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38880. import { Mesh } from "babylonjs/Meshes/mesh";
  38881. import { Material } from "babylonjs/Materials/material";
  38882. import { Effect } from "babylonjs/Materials/effect";
  38883. /**
  38884. * Base class of materials working in push mode in babylon JS
  38885. * @hidden
  38886. */
  38887. export class PushMaterial extends Material {
  38888. protected _activeEffect: Effect;
  38889. protected _normalMatrix: Matrix;
  38890. /**
  38891. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38892. * This means that the material can keep using a previous shader while a new one is being compiled.
  38893. * This is mostly used when shader parallel compilation is supported (true by default)
  38894. */
  38895. allowShaderHotSwapping: boolean;
  38896. constructor(name: string, scene: Scene);
  38897. getEffect(): Effect;
  38898. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38899. /**
  38900. * Binds the given world matrix to the active effect
  38901. *
  38902. * @param world the matrix to bind
  38903. */
  38904. bindOnlyWorldMatrix(world: Matrix): void;
  38905. /**
  38906. * Binds the given normal matrix to the active effect
  38907. *
  38908. * @param normalMatrix the matrix to bind
  38909. */
  38910. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38911. bind(world: Matrix, mesh?: Mesh): void;
  38912. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38913. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38914. }
  38915. }
  38916. declare module "babylonjs/Materials/materialFlags" {
  38917. /**
  38918. * This groups all the flags used to control the materials channel.
  38919. */
  38920. export class MaterialFlags {
  38921. private static _DiffuseTextureEnabled;
  38922. /**
  38923. * Are diffuse textures enabled in the application.
  38924. */
  38925. static DiffuseTextureEnabled: boolean;
  38926. private static _AmbientTextureEnabled;
  38927. /**
  38928. * Are ambient textures enabled in the application.
  38929. */
  38930. static AmbientTextureEnabled: boolean;
  38931. private static _OpacityTextureEnabled;
  38932. /**
  38933. * Are opacity textures enabled in the application.
  38934. */
  38935. static OpacityTextureEnabled: boolean;
  38936. private static _ReflectionTextureEnabled;
  38937. /**
  38938. * Are reflection textures enabled in the application.
  38939. */
  38940. static ReflectionTextureEnabled: boolean;
  38941. private static _EmissiveTextureEnabled;
  38942. /**
  38943. * Are emissive textures enabled in the application.
  38944. */
  38945. static EmissiveTextureEnabled: boolean;
  38946. private static _SpecularTextureEnabled;
  38947. /**
  38948. * Are specular textures enabled in the application.
  38949. */
  38950. static SpecularTextureEnabled: boolean;
  38951. private static _BumpTextureEnabled;
  38952. /**
  38953. * Are bump textures enabled in the application.
  38954. */
  38955. static BumpTextureEnabled: boolean;
  38956. private static _LightmapTextureEnabled;
  38957. /**
  38958. * Are lightmap textures enabled in the application.
  38959. */
  38960. static LightmapTextureEnabled: boolean;
  38961. private static _RefractionTextureEnabled;
  38962. /**
  38963. * Are refraction textures enabled in the application.
  38964. */
  38965. static RefractionTextureEnabled: boolean;
  38966. private static _ColorGradingTextureEnabled;
  38967. /**
  38968. * Are color grading textures enabled in the application.
  38969. */
  38970. static ColorGradingTextureEnabled: boolean;
  38971. private static _FresnelEnabled;
  38972. /**
  38973. * Are fresnels enabled in the application.
  38974. */
  38975. static FresnelEnabled: boolean;
  38976. private static _ClearCoatTextureEnabled;
  38977. /**
  38978. * Are clear coat textures enabled in the application.
  38979. */
  38980. static ClearCoatTextureEnabled: boolean;
  38981. private static _ClearCoatBumpTextureEnabled;
  38982. /**
  38983. * Are clear coat bump textures enabled in the application.
  38984. */
  38985. static ClearCoatBumpTextureEnabled: boolean;
  38986. private static _ClearCoatTintTextureEnabled;
  38987. /**
  38988. * Are clear coat tint textures enabled in the application.
  38989. */
  38990. static ClearCoatTintTextureEnabled: boolean;
  38991. private static _SheenTextureEnabled;
  38992. /**
  38993. * Are sheen textures enabled in the application.
  38994. */
  38995. static SheenTextureEnabled: boolean;
  38996. private static _AnisotropicTextureEnabled;
  38997. /**
  38998. * Are anisotropic textures enabled in the application.
  38999. */
  39000. static AnisotropicTextureEnabled: boolean;
  39001. }
  39002. }
  39003. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39004. /** @hidden */
  39005. export var defaultFragmentDeclaration: {
  39006. name: string;
  39007. shader: string;
  39008. };
  39009. }
  39010. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39011. /** @hidden */
  39012. export var defaultUboDeclaration: {
  39013. name: string;
  39014. shader: string;
  39015. };
  39016. }
  39017. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39018. /** @hidden */
  39019. export var lightFragmentDeclaration: {
  39020. name: string;
  39021. shader: string;
  39022. };
  39023. }
  39024. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39025. /** @hidden */
  39026. export var lightUboDeclaration: {
  39027. name: string;
  39028. shader: string;
  39029. };
  39030. }
  39031. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39032. /** @hidden */
  39033. export var lightsFragmentFunctions: {
  39034. name: string;
  39035. shader: string;
  39036. };
  39037. }
  39038. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39039. /** @hidden */
  39040. export var shadowsFragmentFunctions: {
  39041. name: string;
  39042. shader: string;
  39043. };
  39044. }
  39045. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39046. /** @hidden */
  39047. export var fresnelFunction: {
  39048. name: string;
  39049. shader: string;
  39050. };
  39051. }
  39052. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39053. /** @hidden */
  39054. export var reflectionFunction: {
  39055. name: string;
  39056. shader: string;
  39057. };
  39058. }
  39059. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39060. /** @hidden */
  39061. export var bumpFragmentFunctions: {
  39062. name: string;
  39063. shader: string;
  39064. };
  39065. }
  39066. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39067. /** @hidden */
  39068. export var logDepthDeclaration: {
  39069. name: string;
  39070. shader: string;
  39071. };
  39072. }
  39073. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39074. /** @hidden */
  39075. export var bumpFragment: {
  39076. name: string;
  39077. shader: string;
  39078. };
  39079. }
  39080. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39081. /** @hidden */
  39082. export var depthPrePass: {
  39083. name: string;
  39084. shader: string;
  39085. };
  39086. }
  39087. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39088. /** @hidden */
  39089. export var lightFragment: {
  39090. name: string;
  39091. shader: string;
  39092. };
  39093. }
  39094. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39095. /** @hidden */
  39096. export var logDepthFragment: {
  39097. name: string;
  39098. shader: string;
  39099. };
  39100. }
  39101. declare module "babylonjs/Shaders/default.fragment" {
  39102. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39103. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39104. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39105. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39106. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39107. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39108. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39109. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39110. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39111. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39112. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39113. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39114. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39115. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39116. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39117. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39118. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39119. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39120. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39121. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39122. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39123. /** @hidden */
  39124. export var defaultPixelShader: {
  39125. name: string;
  39126. shader: string;
  39127. };
  39128. }
  39129. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39130. /** @hidden */
  39131. export var defaultVertexDeclaration: {
  39132. name: string;
  39133. shader: string;
  39134. };
  39135. }
  39136. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39137. /** @hidden */
  39138. export var bumpVertexDeclaration: {
  39139. name: string;
  39140. shader: string;
  39141. };
  39142. }
  39143. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39144. /** @hidden */
  39145. export var bumpVertex: {
  39146. name: string;
  39147. shader: string;
  39148. };
  39149. }
  39150. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39151. /** @hidden */
  39152. export var fogVertex: {
  39153. name: string;
  39154. shader: string;
  39155. };
  39156. }
  39157. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39158. /** @hidden */
  39159. export var shadowsVertex: {
  39160. name: string;
  39161. shader: string;
  39162. };
  39163. }
  39164. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39165. /** @hidden */
  39166. export var pointCloudVertex: {
  39167. name: string;
  39168. shader: string;
  39169. };
  39170. }
  39171. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39172. /** @hidden */
  39173. export var logDepthVertex: {
  39174. name: string;
  39175. shader: string;
  39176. };
  39177. }
  39178. declare module "babylonjs/Shaders/default.vertex" {
  39179. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39180. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39181. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39182. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39183. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39184. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39185. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39186. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39187. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39188. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39189. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39190. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39191. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39192. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39193. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39194. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39195. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39196. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39197. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39198. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39199. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39200. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39201. /** @hidden */
  39202. export var defaultVertexShader: {
  39203. name: string;
  39204. shader: string;
  39205. };
  39206. }
  39207. declare module "babylonjs/Materials/standardMaterial" {
  39208. import { SmartArray } from "babylonjs/Misc/smartArray";
  39209. import { IAnimatable } from "babylonjs/Misc/tools";
  39210. import { Nullable } from "babylonjs/types";
  39211. import { Scene } from "babylonjs/scene";
  39212. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39213. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39215. import { Mesh } from "babylonjs/Meshes/mesh";
  39216. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39217. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39218. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39219. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39220. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39222. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39223. import "babylonjs/Shaders/default.fragment";
  39224. import "babylonjs/Shaders/default.vertex";
  39225. /** @hidden */
  39226. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39227. MAINUV1: boolean;
  39228. MAINUV2: boolean;
  39229. DIFFUSE: boolean;
  39230. DIFFUSEDIRECTUV: number;
  39231. AMBIENT: boolean;
  39232. AMBIENTDIRECTUV: number;
  39233. OPACITY: boolean;
  39234. OPACITYDIRECTUV: number;
  39235. OPACITYRGB: boolean;
  39236. REFLECTION: boolean;
  39237. EMISSIVE: boolean;
  39238. EMISSIVEDIRECTUV: number;
  39239. SPECULAR: boolean;
  39240. SPECULARDIRECTUV: number;
  39241. BUMP: boolean;
  39242. BUMPDIRECTUV: number;
  39243. PARALLAX: boolean;
  39244. PARALLAXOCCLUSION: boolean;
  39245. SPECULAROVERALPHA: boolean;
  39246. CLIPPLANE: boolean;
  39247. CLIPPLANE2: boolean;
  39248. CLIPPLANE3: boolean;
  39249. CLIPPLANE4: boolean;
  39250. ALPHATEST: boolean;
  39251. DEPTHPREPASS: boolean;
  39252. ALPHAFROMDIFFUSE: boolean;
  39253. POINTSIZE: boolean;
  39254. FOG: boolean;
  39255. SPECULARTERM: boolean;
  39256. DIFFUSEFRESNEL: boolean;
  39257. OPACITYFRESNEL: boolean;
  39258. REFLECTIONFRESNEL: boolean;
  39259. REFRACTIONFRESNEL: boolean;
  39260. EMISSIVEFRESNEL: boolean;
  39261. FRESNEL: boolean;
  39262. NORMAL: boolean;
  39263. UV1: boolean;
  39264. UV2: boolean;
  39265. VERTEXCOLOR: boolean;
  39266. VERTEXALPHA: boolean;
  39267. NUM_BONE_INFLUENCERS: number;
  39268. BonesPerMesh: number;
  39269. BONETEXTURE: boolean;
  39270. INSTANCES: boolean;
  39271. GLOSSINESS: boolean;
  39272. ROUGHNESS: boolean;
  39273. EMISSIVEASILLUMINATION: boolean;
  39274. LINKEMISSIVEWITHDIFFUSE: boolean;
  39275. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39276. LIGHTMAP: boolean;
  39277. LIGHTMAPDIRECTUV: number;
  39278. OBJECTSPACE_NORMALMAP: boolean;
  39279. USELIGHTMAPASSHADOWMAP: boolean;
  39280. REFLECTIONMAP_3D: boolean;
  39281. REFLECTIONMAP_SPHERICAL: boolean;
  39282. REFLECTIONMAP_PLANAR: boolean;
  39283. REFLECTIONMAP_CUBIC: boolean;
  39284. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39285. REFLECTIONMAP_PROJECTION: boolean;
  39286. REFLECTIONMAP_SKYBOX: boolean;
  39287. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39288. REFLECTIONMAP_EXPLICIT: boolean;
  39289. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39290. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39291. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39292. INVERTCUBICMAP: boolean;
  39293. LOGARITHMICDEPTH: boolean;
  39294. REFRACTION: boolean;
  39295. REFRACTIONMAP_3D: boolean;
  39296. REFLECTIONOVERALPHA: boolean;
  39297. TWOSIDEDLIGHTING: boolean;
  39298. SHADOWFLOAT: boolean;
  39299. MORPHTARGETS: boolean;
  39300. MORPHTARGETS_NORMAL: boolean;
  39301. MORPHTARGETS_TANGENT: boolean;
  39302. NUM_MORPH_INFLUENCERS: number;
  39303. NONUNIFORMSCALING: boolean;
  39304. PREMULTIPLYALPHA: boolean;
  39305. IMAGEPROCESSING: boolean;
  39306. VIGNETTE: boolean;
  39307. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39308. VIGNETTEBLENDMODEOPAQUE: boolean;
  39309. TONEMAPPING: boolean;
  39310. TONEMAPPING_ACES: boolean;
  39311. CONTRAST: boolean;
  39312. COLORCURVES: boolean;
  39313. COLORGRADING: boolean;
  39314. COLORGRADING3D: boolean;
  39315. SAMPLER3DGREENDEPTH: boolean;
  39316. SAMPLER3DBGRMAP: boolean;
  39317. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39318. /**
  39319. * If the reflection texture on this material is in linear color space
  39320. * @hidden
  39321. */
  39322. IS_REFLECTION_LINEAR: boolean;
  39323. /**
  39324. * If the refraction texture on this material is in linear color space
  39325. * @hidden
  39326. */
  39327. IS_REFRACTION_LINEAR: boolean;
  39328. EXPOSURE: boolean;
  39329. constructor();
  39330. setReflectionMode(modeToEnable: string): void;
  39331. }
  39332. /**
  39333. * This is the default material used in Babylon. It is the best trade off between quality
  39334. * and performances.
  39335. * @see http://doc.babylonjs.com/babylon101/materials
  39336. */
  39337. export class StandardMaterial extends PushMaterial {
  39338. private _diffuseTexture;
  39339. /**
  39340. * The basic texture of the material as viewed under a light.
  39341. */
  39342. diffuseTexture: Nullable<BaseTexture>;
  39343. private _ambientTexture;
  39344. /**
  39345. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39346. */
  39347. ambientTexture: Nullable<BaseTexture>;
  39348. private _opacityTexture;
  39349. /**
  39350. * Define the transparency of the material from a texture.
  39351. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39352. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39353. */
  39354. opacityTexture: Nullable<BaseTexture>;
  39355. private _reflectionTexture;
  39356. /**
  39357. * Define the texture used to display the reflection.
  39358. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39359. */
  39360. reflectionTexture: Nullable<BaseTexture>;
  39361. private _emissiveTexture;
  39362. /**
  39363. * Define texture of the material as if self lit.
  39364. * This will be mixed in the final result even in the absence of light.
  39365. */
  39366. emissiveTexture: Nullable<BaseTexture>;
  39367. private _specularTexture;
  39368. /**
  39369. * Define how the color and intensity of the highlight given by the light in the material.
  39370. */
  39371. specularTexture: Nullable<BaseTexture>;
  39372. private _bumpTexture;
  39373. /**
  39374. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39375. * 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.
  39376. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39377. */
  39378. bumpTexture: Nullable<BaseTexture>;
  39379. private _lightmapTexture;
  39380. /**
  39381. * Complex lighting can be computationally expensive to compute at runtime.
  39382. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39383. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39384. */
  39385. lightmapTexture: Nullable<BaseTexture>;
  39386. private _refractionTexture;
  39387. /**
  39388. * Define the texture used to display the refraction.
  39389. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39390. */
  39391. refractionTexture: Nullable<BaseTexture>;
  39392. /**
  39393. * The color of the material lit by the environmental background lighting.
  39394. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39395. */
  39396. ambientColor: Color3;
  39397. /**
  39398. * The basic color of the material as viewed under a light.
  39399. */
  39400. diffuseColor: Color3;
  39401. /**
  39402. * Define how the color and intensity of the highlight given by the light in the material.
  39403. */
  39404. specularColor: Color3;
  39405. /**
  39406. * Define the color of the material as if self lit.
  39407. * This will be mixed in the final result even in the absence of light.
  39408. */
  39409. emissiveColor: Color3;
  39410. /**
  39411. * Defines how sharp are the highlights in the material.
  39412. * The bigger the value the sharper giving a more glossy feeling to the result.
  39413. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39414. */
  39415. specularPower: number;
  39416. private _useAlphaFromDiffuseTexture;
  39417. /**
  39418. * Does the transparency come from the diffuse texture alpha channel.
  39419. */
  39420. useAlphaFromDiffuseTexture: boolean;
  39421. private _useEmissiveAsIllumination;
  39422. /**
  39423. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39424. */
  39425. useEmissiveAsIllumination: boolean;
  39426. private _linkEmissiveWithDiffuse;
  39427. /**
  39428. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39429. * the emissive level when the final color is close to one.
  39430. */
  39431. linkEmissiveWithDiffuse: boolean;
  39432. private _useSpecularOverAlpha;
  39433. /**
  39434. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39435. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39436. */
  39437. useSpecularOverAlpha: boolean;
  39438. private _useReflectionOverAlpha;
  39439. /**
  39440. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39441. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39442. */
  39443. useReflectionOverAlpha: boolean;
  39444. private _disableLighting;
  39445. /**
  39446. * Does lights from the scene impacts this material.
  39447. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39448. */
  39449. disableLighting: boolean;
  39450. private _useObjectSpaceNormalMap;
  39451. /**
  39452. * Allows using an object space normal map (instead of tangent space).
  39453. */
  39454. useObjectSpaceNormalMap: boolean;
  39455. private _useParallax;
  39456. /**
  39457. * Is parallax enabled or not.
  39458. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39459. */
  39460. useParallax: boolean;
  39461. private _useParallaxOcclusion;
  39462. /**
  39463. * Is parallax occlusion enabled or not.
  39464. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39465. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39466. */
  39467. useParallaxOcclusion: boolean;
  39468. /**
  39469. * 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.
  39470. */
  39471. parallaxScaleBias: number;
  39472. private _roughness;
  39473. /**
  39474. * Helps to define how blurry the reflections should appears in the material.
  39475. */
  39476. roughness: number;
  39477. /**
  39478. * In case of refraction, define the value of the indice of refraction.
  39479. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39480. */
  39481. indexOfRefraction: number;
  39482. /**
  39483. * Invert the refraction texture alongside the y axis.
  39484. * It can be useful with procedural textures or probe for instance.
  39485. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39486. */
  39487. invertRefractionY: boolean;
  39488. /**
  39489. * Defines the alpha limits in alpha test mode.
  39490. */
  39491. alphaCutOff: number;
  39492. private _useLightmapAsShadowmap;
  39493. /**
  39494. * In case of light mapping, define whether the map contains light or shadow informations.
  39495. */
  39496. useLightmapAsShadowmap: boolean;
  39497. private _diffuseFresnelParameters;
  39498. /**
  39499. * Define the diffuse fresnel parameters of the material.
  39500. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39501. */
  39502. diffuseFresnelParameters: FresnelParameters;
  39503. private _opacityFresnelParameters;
  39504. /**
  39505. * Define the opacity fresnel parameters of the material.
  39506. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39507. */
  39508. opacityFresnelParameters: FresnelParameters;
  39509. private _reflectionFresnelParameters;
  39510. /**
  39511. * Define the reflection fresnel parameters of the material.
  39512. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39513. */
  39514. reflectionFresnelParameters: FresnelParameters;
  39515. private _refractionFresnelParameters;
  39516. /**
  39517. * Define the refraction fresnel parameters of the material.
  39518. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39519. */
  39520. refractionFresnelParameters: FresnelParameters;
  39521. private _emissiveFresnelParameters;
  39522. /**
  39523. * Define the emissive fresnel parameters of the material.
  39524. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39525. */
  39526. emissiveFresnelParameters: FresnelParameters;
  39527. private _useReflectionFresnelFromSpecular;
  39528. /**
  39529. * If true automatically deducts the fresnels values from the material specularity.
  39530. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39531. */
  39532. useReflectionFresnelFromSpecular: boolean;
  39533. private _useGlossinessFromSpecularMapAlpha;
  39534. /**
  39535. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39536. */
  39537. useGlossinessFromSpecularMapAlpha: boolean;
  39538. private _maxSimultaneousLights;
  39539. /**
  39540. * Defines the maximum number of lights that can be used in the material
  39541. */
  39542. maxSimultaneousLights: number;
  39543. private _invertNormalMapX;
  39544. /**
  39545. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39546. */
  39547. invertNormalMapX: boolean;
  39548. private _invertNormalMapY;
  39549. /**
  39550. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39551. */
  39552. invertNormalMapY: boolean;
  39553. private _twoSidedLighting;
  39554. /**
  39555. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39556. */
  39557. twoSidedLighting: boolean;
  39558. /**
  39559. * Default configuration related to image processing available in the standard Material.
  39560. */
  39561. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39562. /**
  39563. * Gets the image processing configuration used either in this material.
  39564. */
  39565. /**
  39566. * Sets the Default image processing configuration used either in the this material.
  39567. *
  39568. * If sets to null, the scene one is in use.
  39569. */
  39570. imageProcessingConfiguration: ImageProcessingConfiguration;
  39571. /**
  39572. * Keep track of the image processing observer to allow dispose and replace.
  39573. */
  39574. private _imageProcessingObserver;
  39575. /**
  39576. * Attaches a new image processing configuration to the Standard Material.
  39577. * @param configuration
  39578. */
  39579. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39580. /**
  39581. * Gets wether the color curves effect is enabled.
  39582. */
  39583. /**
  39584. * Sets wether the color curves effect is enabled.
  39585. */
  39586. cameraColorCurvesEnabled: boolean;
  39587. /**
  39588. * Gets wether the color grading effect is enabled.
  39589. */
  39590. /**
  39591. * Gets wether the color grading effect is enabled.
  39592. */
  39593. cameraColorGradingEnabled: boolean;
  39594. /**
  39595. * Gets wether tonemapping is enabled or not.
  39596. */
  39597. /**
  39598. * Sets wether tonemapping is enabled or not
  39599. */
  39600. cameraToneMappingEnabled: boolean;
  39601. /**
  39602. * The camera exposure used on this material.
  39603. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39604. * This corresponds to a photographic exposure.
  39605. */
  39606. /**
  39607. * The camera exposure used on this material.
  39608. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39609. * This corresponds to a photographic exposure.
  39610. */
  39611. cameraExposure: number;
  39612. /**
  39613. * Gets The camera contrast used on this material.
  39614. */
  39615. /**
  39616. * Sets The camera contrast used on this material.
  39617. */
  39618. cameraContrast: number;
  39619. /**
  39620. * Gets the Color Grading 2D Lookup Texture.
  39621. */
  39622. /**
  39623. * Sets the Color Grading 2D Lookup Texture.
  39624. */
  39625. cameraColorGradingTexture: Nullable<BaseTexture>;
  39626. /**
  39627. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39629. * 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;
  39630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39631. */
  39632. /**
  39633. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39634. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39635. * 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;
  39636. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39637. */
  39638. cameraColorCurves: Nullable<ColorCurves>;
  39639. /**
  39640. * Custom callback helping to override the default shader used in the material.
  39641. */
  39642. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39643. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39644. protected _worldViewProjectionMatrix: Matrix;
  39645. protected _globalAmbientColor: Color3;
  39646. protected _useLogarithmicDepth: boolean;
  39647. /**
  39648. * Instantiates a new standard material.
  39649. * This is the default material used in Babylon. It is the best trade off between quality
  39650. * and performances.
  39651. * @see http://doc.babylonjs.com/babylon101/materials
  39652. * @param name Define the name of the material in the scene
  39653. * @param scene Define the scene the material belong to
  39654. */
  39655. constructor(name: string, scene: Scene);
  39656. /**
  39657. * Gets a boolean indicating that current material needs to register RTT
  39658. */
  39659. readonly hasRenderTargetTextures: boolean;
  39660. /**
  39661. * Gets the current class name of the material e.g. "StandardMaterial"
  39662. * Mainly use in serialization.
  39663. * @returns the class name
  39664. */
  39665. getClassName(): string;
  39666. /**
  39667. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39668. * You can try switching to logarithmic depth.
  39669. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39670. */
  39671. useLogarithmicDepth: boolean;
  39672. /**
  39673. * Specifies if the material will require alpha blending
  39674. * @returns a boolean specifying if alpha blending is needed
  39675. */
  39676. needAlphaBlending(): boolean;
  39677. /**
  39678. * Specifies if this material should be rendered in alpha test mode
  39679. * @returns a boolean specifying if an alpha test is needed.
  39680. */
  39681. needAlphaTesting(): boolean;
  39682. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39683. /**
  39684. * Get the texture used for alpha test purpose.
  39685. * @returns the diffuse texture in case of the standard material.
  39686. */
  39687. getAlphaTestTexture(): Nullable<BaseTexture>;
  39688. /**
  39689. * Get if the submesh is ready to be used and all its information available.
  39690. * Child classes can use it to update shaders
  39691. * @param mesh defines the mesh to check
  39692. * @param subMesh defines which submesh to check
  39693. * @param useInstances specifies that instances should be used
  39694. * @returns a boolean indicating that the submesh is ready or not
  39695. */
  39696. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39697. /**
  39698. * Builds the material UBO layouts.
  39699. * Used internally during the effect preparation.
  39700. */
  39701. buildUniformLayout(): void;
  39702. /**
  39703. * Unbinds the material from the mesh
  39704. */
  39705. unbind(): void;
  39706. /**
  39707. * Binds the submesh to this material by preparing the effect and shader to draw
  39708. * @param world defines the world transformation matrix
  39709. * @param mesh defines the mesh containing the submesh
  39710. * @param subMesh defines the submesh to bind the material to
  39711. */
  39712. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39713. /**
  39714. * Get the list of animatables in the material.
  39715. * @returns the list of animatables object used in the material
  39716. */
  39717. getAnimatables(): IAnimatable[];
  39718. /**
  39719. * Gets the active textures from the material
  39720. * @returns an array of textures
  39721. */
  39722. getActiveTextures(): BaseTexture[];
  39723. /**
  39724. * Specifies if the material uses a texture
  39725. * @param texture defines the texture to check against the material
  39726. * @returns a boolean specifying if the material uses the texture
  39727. */
  39728. hasTexture(texture: BaseTexture): boolean;
  39729. /**
  39730. * Disposes the material
  39731. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39732. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39733. */
  39734. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39735. /**
  39736. * Makes a duplicate of the material, and gives it a new name
  39737. * @param name defines the new name for the duplicated material
  39738. * @returns the cloned material
  39739. */
  39740. clone(name: string): StandardMaterial;
  39741. /**
  39742. * Serializes this material in a JSON representation
  39743. * @returns the serialized material object
  39744. */
  39745. serialize(): any;
  39746. /**
  39747. * Creates a standard material from parsed material data
  39748. * @param source defines the JSON representation of the material
  39749. * @param scene defines the hosting scene
  39750. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39751. * @returns a new standard material
  39752. */
  39753. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39754. /**
  39755. * Are diffuse textures enabled in the application.
  39756. */
  39757. static DiffuseTextureEnabled: boolean;
  39758. /**
  39759. * Are ambient textures enabled in the application.
  39760. */
  39761. static AmbientTextureEnabled: boolean;
  39762. /**
  39763. * Are opacity textures enabled in the application.
  39764. */
  39765. static OpacityTextureEnabled: boolean;
  39766. /**
  39767. * Are reflection textures enabled in the application.
  39768. */
  39769. static ReflectionTextureEnabled: boolean;
  39770. /**
  39771. * Are emissive textures enabled in the application.
  39772. */
  39773. static EmissiveTextureEnabled: boolean;
  39774. /**
  39775. * Are specular textures enabled in the application.
  39776. */
  39777. static SpecularTextureEnabled: boolean;
  39778. /**
  39779. * Are bump textures enabled in the application.
  39780. */
  39781. static BumpTextureEnabled: boolean;
  39782. /**
  39783. * Are lightmap textures enabled in the application.
  39784. */
  39785. static LightmapTextureEnabled: boolean;
  39786. /**
  39787. * Are refraction textures enabled in the application.
  39788. */
  39789. static RefractionTextureEnabled: boolean;
  39790. /**
  39791. * Are color grading textures enabled in the application.
  39792. */
  39793. static ColorGradingTextureEnabled: boolean;
  39794. /**
  39795. * Are fresnels enabled in the application.
  39796. */
  39797. static FresnelEnabled: boolean;
  39798. }
  39799. }
  39800. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39801. import { Scene } from "babylonjs/scene";
  39802. import { Texture } from "babylonjs/Materials/Textures/texture";
  39803. /**
  39804. * A class extending Texture allowing drawing on a texture
  39805. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39806. */
  39807. export class DynamicTexture extends Texture {
  39808. private _generateMipMaps;
  39809. private _canvas;
  39810. private _context;
  39811. private _engine;
  39812. /**
  39813. * Creates a DynamicTexture
  39814. * @param name defines the name of the texture
  39815. * @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
  39816. * @param scene defines the scene where you want the texture
  39817. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39818. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39819. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39820. */
  39821. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39822. /**
  39823. * Get the current class name of the texture useful for serialization or dynamic coding.
  39824. * @returns "DynamicTexture"
  39825. */
  39826. getClassName(): string;
  39827. /**
  39828. * Gets the current state of canRescale
  39829. */
  39830. readonly canRescale: boolean;
  39831. private _recreate;
  39832. /**
  39833. * Scales the texture
  39834. * @param ratio the scale factor to apply to both width and height
  39835. */
  39836. scale(ratio: number): void;
  39837. /**
  39838. * Resizes the texture
  39839. * @param width the new width
  39840. * @param height the new height
  39841. */
  39842. scaleTo(width: number, height: number): void;
  39843. /**
  39844. * Gets the context of the canvas used by the texture
  39845. * @returns the canvas context of the dynamic texture
  39846. */
  39847. getContext(): CanvasRenderingContext2D;
  39848. /**
  39849. * Clears the texture
  39850. */
  39851. clear(): void;
  39852. /**
  39853. * Updates the texture
  39854. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39855. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39856. */
  39857. update(invertY?: boolean, premulAlpha?: boolean): void;
  39858. /**
  39859. * Draws text onto the texture
  39860. * @param text defines the text to be drawn
  39861. * @param x defines the placement of the text from the left
  39862. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39863. * @param font defines the font to be used with font-style, font-size, font-name
  39864. * @param color defines the color used for the text
  39865. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39866. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39867. * @param update defines whether texture is immediately update (default is true)
  39868. */
  39869. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39870. /**
  39871. * Clones the texture
  39872. * @returns the clone of the texture.
  39873. */
  39874. clone(): DynamicTexture;
  39875. /**
  39876. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39877. * @returns a serialized dynamic texture object
  39878. */
  39879. serialize(): any;
  39880. /** @hidden */
  39881. _rebuild(): void;
  39882. }
  39883. }
  39884. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39885. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39886. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39887. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39888. /** @hidden */
  39889. export var imageProcessingPixelShader: {
  39890. name: string;
  39891. shader: string;
  39892. };
  39893. }
  39894. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39895. import { Nullable } from "babylonjs/types";
  39896. import { Color4 } from "babylonjs/Maths/math";
  39897. import { Camera } from "babylonjs/Cameras/camera";
  39898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39899. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39900. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39901. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39902. import { Engine } from "babylonjs/Engines/engine";
  39903. import "babylonjs/Shaders/imageProcessing.fragment";
  39904. import "babylonjs/Shaders/postprocess.vertex";
  39905. /**
  39906. * ImageProcessingPostProcess
  39907. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39908. */
  39909. export class ImageProcessingPostProcess extends PostProcess {
  39910. /**
  39911. * Default configuration related to image processing available in the PBR Material.
  39912. */
  39913. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39914. /**
  39915. * Gets the image processing configuration used either in this material.
  39916. */
  39917. /**
  39918. * Sets the Default image processing configuration used either in the this material.
  39919. *
  39920. * If sets to null, the scene one is in use.
  39921. */
  39922. imageProcessingConfiguration: ImageProcessingConfiguration;
  39923. /**
  39924. * Keep track of the image processing observer to allow dispose and replace.
  39925. */
  39926. private _imageProcessingObserver;
  39927. /**
  39928. * Attaches a new image processing configuration to the PBR Material.
  39929. * @param configuration
  39930. */
  39931. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39932. /**
  39933. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39934. */
  39935. /**
  39936. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39937. */
  39938. colorCurves: Nullable<ColorCurves>;
  39939. /**
  39940. * Gets wether the color curves effect is enabled.
  39941. */
  39942. /**
  39943. * Sets wether the color curves effect is enabled.
  39944. */
  39945. colorCurvesEnabled: boolean;
  39946. /**
  39947. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39948. */
  39949. /**
  39950. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39951. */
  39952. colorGradingTexture: Nullable<BaseTexture>;
  39953. /**
  39954. * Gets wether the color grading effect is enabled.
  39955. */
  39956. /**
  39957. * Gets wether the color grading effect is enabled.
  39958. */
  39959. colorGradingEnabled: boolean;
  39960. /**
  39961. * Gets exposure used in the effect.
  39962. */
  39963. /**
  39964. * Sets exposure used in the effect.
  39965. */
  39966. exposure: number;
  39967. /**
  39968. * Gets wether tonemapping is enabled or not.
  39969. */
  39970. /**
  39971. * Sets wether tonemapping is enabled or not
  39972. */
  39973. toneMappingEnabled: boolean;
  39974. /**
  39975. * Gets the type of tone mapping effect.
  39976. */
  39977. /**
  39978. * Sets the type of tone mapping effect.
  39979. */
  39980. toneMappingType: number;
  39981. /**
  39982. * Gets contrast used in the effect.
  39983. */
  39984. /**
  39985. * Sets contrast used in the effect.
  39986. */
  39987. contrast: number;
  39988. /**
  39989. * Gets Vignette stretch size.
  39990. */
  39991. /**
  39992. * Sets Vignette stretch size.
  39993. */
  39994. vignetteStretch: number;
  39995. /**
  39996. * Gets Vignette centre X Offset.
  39997. */
  39998. /**
  39999. * Sets Vignette centre X Offset.
  40000. */
  40001. vignetteCentreX: number;
  40002. /**
  40003. * Gets Vignette centre Y Offset.
  40004. */
  40005. /**
  40006. * Sets Vignette centre Y Offset.
  40007. */
  40008. vignetteCentreY: number;
  40009. /**
  40010. * Gets Vignette weight or intensity of the vignette effect.
  40011. */
  40012. /**
  40013. * Sets Vignette weight or intensity of the vignette effect.
  40014. */
  40015. vignetteWeight: number;
  40016. /**
  40017. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40018. * if vignetteEnabled is set to true.
  40019. */
  40020. /**
  40021. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40022. * if vignetteEnabled is set to true.
  40023. */
  40024. vignetteColor: Color4;
  40025. /**
  40026. * Gets Camera field of view used by the Vignette effect.
  40027. */
  40028. /**
  40029. * Sets Camera field of view used by the Vignette effect.
  40030. */
  40031. vignetteCameraFov: number;
  40032. /**
  40033. * Gets the vignette blend mode allowing different kind of effect.
  40034. */
  40035. /**
  40036. * Sets the vignette blend mode allowing different kind of effect.
  40037. */
  40038. vignetteBlendMode: number;
  40039. /**
  40040. * Gets wether the vignette effect is enabled.
  40041. */
  40042. /**
  40043. * Sets wether the vignette effect is enabled.
  40044. */
  40045. vignetteEnabled: boolean;
  40046. private _fromLinearSpace;
  40047. /**
  40048. * Gets wether the input of the processing is in Gamma or Linear Space.
  40049. */
  40050. /**
  40051. * Sets wether the input of the processing is in Gamma or Linear Space.
  40052. */
  40053. fromLinearSpace: boolean;
  40054. /**
  40055. * Defines cache preventing GC.
  40056. */
  40057. private _defines;
  40058. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40059. /**
  40060. * "ImageProcessingPostProcess"
  40061. * @returns "ImageProcessingPostProcess"
  40062. */
  40063. getClassName(): string;
  40064. protected _updateParameters(): void;
  40065. dispose(camera?: Camera): void;
  40066. }
  40067. }
  40068. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40069. import { Scene } from "babylonjs/scene";
  40070. import { Color3 } from "babylonjs/Maths/math";
  40071. import { Mesh } from "babylonjs/Meshes/mesh";
  40072. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40073. /**
  40074. * Class containing static functions to help procedurally build meshes
  40075. */
  40076. export class GroundBuilder {
  40077. /**
  40078. * Creates a ground mesh
  40079. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40080. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40082. * @param name defines the name of the mesh
  40083. * @param options defines the options used to create the mesh
  40084. * @param scene defines the hosting scene
  40085. * @returns the ground mesh
  40086. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40087. */
  40088. static CreateGround(name: string, options: {
  40089. width?: number;
  40090. height?: number;
  40091. subdivisions?: number;
  40092. subdivisionsX?: number;
  40093. subdivisionsY?: number;
  40094. updatable?: boolean;
  40095. }, scene: any): Mesh;
  40096. /**
  40097. * Creates a tiled ground mesh
  40098. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40099. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40100. * * 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
  40101. * * 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
  40102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40103. * @param name defines the name of the mesh
  40104. * @param options defines the options used to create the mesh
  40105. * @param scene defines the hosting scene
  40106. * @returns the tiled ground mesh
  40107. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40108. */
  40109. static CreateTiledGround(name: string, options: {
  40110. xmin: number;
  40111. zmin: number;
  40112. xmax: number;
  40113. zmax: number;
  40114. subdivisions?: {
  40115. w: number;
  40116. h: number;
  40117. };
  40118. precision?: {
  40119. w: number;
  40120. h: number;
  40121. };
  40122. updatable?: boolean;
  40123. }, scene: Scene): Mesh;
  40124. /**
  40125. * Creates a ground mesh from a height map
  40126. * * The parameter `url` sets the URL of the height map image resource.
  40127. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40128. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40129. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40130. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40131. * * 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.
  40132. * * 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).
  40133. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40135. * @param name defines the name of the mesh
  40136. * @param url defines the url to the height map
  40137. * @param options defines the options used to create the mesh
  40138. * @param scene defines the hosting scene
  40139. * @returns the ground mesh
  40140. * @see https://doc.babylonjs.com/babylon101/height_map
  40141. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40142. */
  40143. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40144. width?: number;
  40145. height?: number;
  40146. subdivisions?: number;
  40147. minHeight?: number;
  40148. maxHeight?: number;
  40149. colorFilter?: Color3;
  40150. alphaFilter?: number;
  40151. updatable?: boolean;
  40152. onReady?: (mesh: GroundMesh) => void;
  40153. }, scene: Scene): GroundMesh;
  40154. }
  40155. }
  40156. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40157. import { Vector4 } from "babylonjs/Maths/math";
  40158. import { Mesh } from "babylonjs/Meshes/mesh";
  40159. /**
  40160. * Class containing static functions to help procedurally build meshes
  40161. */
  40162. export class TorusBuilder {
  40163. /**
  40164. * Creates a torus mesh
  40165. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40166. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40167. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40171. * @param name defines the name of the mesh
  40172. * @param options defines the options used to create the mesh
  40173. * @param scene defines the hosting scene
  40174. * @returns the torus mesh
  40175. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40176. */
  40177. static CreateTorus(name: string, options: {
  40178. diameter?: number;
  40179. thickness?: number;
  40180. tessellation?: number;
  40181. updatable?: boolean;
  40182. sideOrientation?: number;
  40183. frontUVs?: Vector4;
  40184. backUVs?: Vector4;
  40185. }, scene: any): Mesh;
  40186. }
  40187. }
  40188. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40189. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40190. import { Mesh } from "babylonjs/Meshes/mesh";
  40191. /**
  40192. * Class containing static functions to help procedurally build meshes
  40193. */
  40194. export class CylinderBuilder {
  40195. /**
  40196. * Creates a cylinder or a cone mesh
  40197. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40198. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40199. * * 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.
  40200. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40201. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40202. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40203. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40204. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40205. * * 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).
  40206. * * 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
  40207. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40208. * * 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
  40209. * * 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.
  40210. * * If `enclose` is false, a ring surface is one element.
  40211. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40212. * * 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
  40213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40216. * @param name defines the name of the mesh
  40217. * @param options defines the options used to create the mesh
  40218. * @param scene defines the hosting scene
  40219. * @returns the cylinder mesh
  40220. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40221. */
  40222. static CreateCylinder(name: string, options: {
  40223. height?: number;
  40224. diameterTop?: number;
  40225. diameterBottom?: number;
  40226. diameter?: number;
  40227. tessellation?: number;
  40228. subdivisions?: number;
  40229. arc?: number;
  40230. faceColors?: Color4[];
  40231. faceUV?: Vector4[];
  40232. updatable?: boolean;
  40233. hasRings?: boolean;
  40234. enclose?: boolean;
  40235. sideOrientation?: number;
  40236. frontUVs?: Vector4;
  40237. backUVs?: Vector4;
  40238. }, scene: any): Mesh;
  40239. }
  40240. }
  40241. declare module "babylonjs/Gamepads/gamepadManager" {
  40242. import { Observable } from "babylonjs/Misc/observable";
  40243. import { Nullable } from "babylonjs/types";
  40244. import { Scene } from "babylonjs/scene";
  40245. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40246. /**
  40247. * Manager for handling gamepads
  40248. */
  40249. export class GamepadManager {
  40250. private _scene?;
  40251. private _babylonGamepads;
  40252. private _oneGamepadConnected;
  40253. /** @hidden */
  40254. _isMonitoring: boolean;
  40255. private _gamepadEventSupported;
  40256. private _gamepadSupport;
  40257. /**
  40258. * observable to be triggered when the gamepad controller has been connected
  40259. */
  40260. onGamepadConnectedObservable: Observable<Gamepad>;
  40261. /**
  40262. * observable to be triggered when the gamepad controller has been disconnected
  40263. */
  40264. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40265. private _onGamepadConnectedEvent;
  40266. private _onGamepadDisconnectedEvent;
  40267. /**
  40268. * Initializes the gamepad manager
  40269. * @param _scene BabylonJS scene
  40270. */
  40271. constructor(_scene?: Scene | undefined);
  40272. /**
  40273. * The gamepads in the game pad manager
  40274. */
  40275. readonly gamepads: Gamepad[];
  40276. /**
  40277. * Get the gamepad controllers based on type
  40278. * @param type The type of gamepad controller
  40279. * @returns Nullable gamepad
  40280. */
  40281. getGamepadByType(type?: number): Nullable<Gamepad>;
  40282. /**
  40283. * Disposes the gamepad manager
  40284. */
  40285. dispose(): void;
  40286. private _addNewGamepad;
  40287. private _startMonitoringGamepads;
  40288. private _stopMonitoringGamepads;
  40289. /** @hidden */
  40290. _checkGamepadsStatus(): void;
  40291. private _updateGamepadObjects;
  40292. }
  40293. }
  40294. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40295. import { Nullable } from "babylonjs/types";
  40296. import { Scene } from "babylonjs/scene";
  40297. import { ISceneComponent } from "babylonjs/sceneComponent";
  40298. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40299. module "babylonjs/scene" {
  40300. interface Scene {
  40301. /** @hidden */
  40302. _gamepadManager: Nullable<GamepadManager>;
  40303. /**
  40304. * Gets the gamepad manager associated with the scene
  40305. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40306. */
  40307. gamepadManager: GamepadManager;
  40308. }
  40309. }
  40310. module "babylonjs/Cameras/freeCameraInputsManager" {
  40311. /**
  40312. * Interface representing a free camera inputs manager
  40313. */
  40314. interface FreeCameraInputsManager {
  40315. /**
  40316. * Adds gamepad input support to the FreeCameraInputsManager.
  40317. * @returns the FreeCameraInputsManager
  40318. */
  40319. addGamepad(): FreeCameraInputsManager;
  40320. }
  40321. }
  40322. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40323. /**
  40324. * Interface representing an arc rotate camera inputs manager
  40325. */
  40326. interface ArcRotateCameraInputsManager {
  40327. /**
  40328. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40329. * @returns the camera inputs manager
  40330. */
  40331. addGamepad(): ArcRotateCameraInputsManager;
  40332. }
  40333. }
  40334. /**
  40335. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40336. */
  40337. export class GamepadSystemSceneComponent implements ISceneComponent {
  40338. /**
  40339. * The component name helpfull to identify the component in the list of scene components.
  40340. */
  40341. readonly name: string;
  40342. /**
  40343. * The scene the component belongs to.
  40344. */
  40345. scene: Scene;
  40346. /**
  40347. * Creates a new instance of the component for the given scene
  40348. * @param scene Defines the scene to register the component in
  40349. */
  40350. constructor(scene: Scene);
  40351. /**
  40352. * Registers the component in a given scene
  40353. */
  40354. register(): void;
  40355. /**
  40356. * Rebuilds the elements related to this component in case of
  40357. * context lost for instance.
  40358. */
  40359. rebuild(): void;
  40360. /**
  40361. * Disposes the component and the associated ressources
  40362. */
  40363. dispose(): void;
  40364. private _beforeCameraUpdate;
  40365. }
  40366. }
  40367. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40368. import { Observable } from "babylonjs/Misc/observable";
  40369. import { Nullable } from "babylonjs/types";
  40370. import { Camera } from "babylonjs/Cameras/camera";
  40371. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40372. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40373. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40374. import { Scene } from "babylonjs/scene";
  40375. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40376. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40378. import { Mesh } from "babylonjs/Meshes/mesh";
  40379. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40380. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40381. import "babylonjs/Meshes/Builders/groundBuilder";
  40382. import "babylonjs/Meshes/Builders/torusBuilder";
  40383. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40384. import "babylonjs/Gamepads/gamepadSceneComponent";
  40385. import "babylonjs/Animations/animatable";
  40386. /**
  40387. * Options to modify the vr teleportation behavior.
  40388. */
  40389. export interface VRTeleportationOptions {
  40390. /**
  40391. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40392. */
  40393. floorMeshName?: string;
  40394. /**
  40395. * A list of meshes to be used as the teleportation floor. (default: empty)
  40396. */
  40397. floorMeshes?: Mesh[];
  40398. }
  40399. /**
  40400. * Options to modify the vr experience helper's behavior.
  40401. */
  40402. export interface VRExperienceHelperOptions extends WebVROptions {
  40403. /**
  40404. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40405. */
  40406. createDeviceOrientationCamera?: boolean;
  40407. /**
  40408. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40409. */
  40410. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40411. /**
  40412. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40413. */
  40414. laserToggle?: boolean;
  40415. /**
  40416. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40417. */
  40418. floorMeshes?: Mesh[];
  40419. /**
  40420. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40421. */
  40422. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40423. }
  40424. /**
  40425. * Event containing information after VR has been entered
  40426. */
  40427. export class OnAfterEnteringVRObservableEvent {
  40428. /**
  40429. * If entering vr was successful
  40430. */
  40431. success: boolean;
  40432. }
  40433. /**
  40434. * Helps to quickly add VR support to an existing scene.
  40435. * See http://doc.babylonjs.com/how_to/webvr_helper
  40436. */
  40437. export class VRExperienceHelper {
  40438. /** Options to modify the vr experience helper's behavior. */
  40439. webVROptions: VRExperienceHelperOptions;
  40440. private _scene;
  40441. private _position;
  40442. private _btnVR;
  40443. private _btnVRDisplayed;
  40444. private _webVRsupported;
  40445. private _webVRready;
  40446. private _webVRrequesting;
  40447. private _webVRpresenting;
  40448. private _hasEnteredVR;
  40449. private _fullscreenVRpresenting;
  40450. private _canvas;
  40451. private _webVRCamera;
  40452. private _vrDeviceOrientationCamera;
  40453. private _deviceOrientationCamera;
  40454. private _existingCamera;
  40455. private _onKeyDown;
  40456. private _onVrDisplayPresentChange;
  40457. private _onVRDisplayChanged;
  40458. private _onVRRequestPresentStart;
  40459. private _onVRRequestPresentComplete;
  40460. /**
  40461. * Observable raised right before entering VR.
  40462. */
  40463. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40464. /**
  40465. * Observable raised when entering VR has completed.
  40466. */
  40467. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40468. /**
  40469. * Observable raised when exiting VR.
  40470. */
  40471. onExitingVRObservable: Observable<VRExperienceHelper>;
  40472. /**
  40473. * Observable raised when controller mesh is loaded.
  40474. */
  40475. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40476. /** Return this.onEnteringVRObservable
  40477. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40478. */
  40479. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40480. /** Return this.onExitingVRObservable
  40481. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40482. */
  40483. readonly onExitingVR: Observable<VRExperienceHelper>;
  40484. /** Return this.onControllerMeshLoadedObservable
  40485. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40486. */
  40487. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40488. private _rayLength;
  40489. private _useCustomVRButton;
  40490. private _teleportationRequested;
  40491. private _teleportActive;
  40492. private _floorMeshName;
  40493. private _floorMeshesCollection;
  40494. private _rotationAllowed;
  40495. private _teleportBackwardsVector;
  40496. private _teleportationTarget;
  40497. private _isDefaultTeleportationTarget;
  40498. private _postProcessMove;
  40499. private _teleportationFillColor;
  40500. private _teleportationBorderColor;
  40501. private _rotationAngle;
  40502. private _haloCenter;
  40503. private _cameraGazer;
  40504. private _padSensibilityUp;
  40505. private _padSensibilityDown;
  40506. private _leftController;
  40507. private _rightController;
  40508. /**
  40509. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40510. */
  40511. onNewMeshSelected: Observable<AbstractMesh>;
  40512. /**
  40513. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40514. */
  40515. onNewMeshPicked: Observable<PickingInfo>;
  40516. private _circleEase;
  40517. /**
  40518. * Observable raised before camera teleportation
  40519. */
  40520. onBeforeCameraTeleport: Observable<Vector3>;
  40521. /**
  40522. * Observable raised after camera teleportation
  40523. */
  40524. onAfterCameraTeleport: Observable<Vector3>;
  40525. /**
  40526. * Observable raised when current selected mesh gets unselected
  40527. */
  40528. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40529. private _raySelectionPredicate;
  40530. /**
  40531. * To be optionaly changed by user to define custom ray selection
  40532. */
  40533. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40534. /**
  40535. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40536. */
  40537. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40538. /**
  40539. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40540. */
  40541. teleportationEnabled: boolean;
  40542. private _defaultHeight;
  40543. private _teleportationInitialized;
  40544. private _interactionsEnabled;
  40545. private _interactionsRequested;
  40546. private _displayGaze;
  40547. private _displayLaserPointer;
  40548. /**
  40549. * The mesh used to display where the user is going to teleport.
  40550. */
  40551. /**
  40552. * Sets the mesh to be used to display where the user is going to teleport.
  40553. */
  40554. teleportationTarget: Mesh;
  40555. /**
  40556. * 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
  40557. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40558. * See http://doc.babylonjs.com/resources/baking_transformations
  40559. */
  40560. gazeTrackerMesh: Mesh;
  40561. /**
  40562. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40563. */
  40564. updateGazeTrackerScale: boolean;
  40565. /**
  40566. * If the gaze trackers color should be updated when selecting meshes
  40567. */
  40568. updateGazeTrackerColor: boolean;
  40569. /**
  40570. * The gaze tracking mesh corresponding to the left controller
  40571. */
  40572. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40573. /**
  40574. * The gaze tracking mesh corresponding to the right controller
  40575. */
  40576. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40577. /**
  40578. * If the ray of the gaze should be displayed.
  40579. */
  40580. /**
  40581. * Sets if the ray of the gaze should be displayed.
  40582. */
  40583. displayGaze: boolean;
  40584. /**
  40585. * If the ray of the LaserPointer should be displayed.
  40586. */
  40587. /**
  40588. * Sets if the ray of the LaserPointer should be displayed.
  40589. */
  40590. displayLaserPointer: boolean;
  40591. /**
  40592. * The deviceOrientationCamera used as the camera when not in VR.
  40593. */
  40594. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40595. /**
  40596. * Based on the current WebVR support, returns the current VR camera used.
  40597. */
  40598. readonly currentVRCamera: Nullable<Camera>;
  40599. /**
  40600. * The webVRCamera which is used when in VR.
  40601. */
  40602. readonly webVRCamera: WebVRFreeCamera;
  40603. /**
  40604. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40605. */
  40606. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40607. private readonly _teleportationRequestInitiated;
  40608. /**
  40609. * Defines wether or not Pointer lock should be requested when switching to
  40610. * full screen.
  40611. */
  40612. requestPointerLockOnFullScreen: boolean;
  40613. /**
  40614. * Instantiates a VRExperienceHelper.
  40615. * Helps to quickly add VR support to an existing scene.
  40616. * @param scene The scene the VRExperienceHelper belongs to.
  40617. * @param webVROptions Options to modify the vr experience helper's behavior.
  40618. */
  40619. constructor(scene: Scene,
  40620. /** Options to modify the vr experience helper's behavior. */
  40621. webVROptions?: VRExperienceHelperOptions);
  40622. private _onDefaultMeshLoaded;
  40623. private _onResize;
  40624. private _onFullscreenChange;
  40625. /**
  40626. * Gets a value indicating if we are currently in VR mode.
  40627. */
  40628. readonly isInVRMode: boolean;
  40629. private onVrDisplayPresentChange;
  40630. private onVRDisplayChanged;
  40631. private moveButtonToBottomRight;
  40632. private displayVRButton;
  40633. private updateButtonVisibility;
  40634. private _cachedAngularSensibility;
  40635. /**
  40636. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40637. * Otherwise, will use the fullscreen API.
  40638. */
  40639. enterVR(): void;
  40640. /**
  40641. * Attempt to exit VR, or fullscreen.
  40642. */
  40643. exitVR(): void;
  40644. /**
  40645. * The position of the vr experience helper.
  40646. */
  40647. /**
  40648. * Sets the position of the vr experience helper.
  40649. */
  40650. position: Vector3;
  40651. /**
  40652. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40653. */
  40654. enableInteractions(): void;
  40655. private readonly _noControllerIsActive;
  40656. private beforeRender;
  40657. private _isTeleportationFloor;
  40658. /**
  40659. * Adds a floor mesh to be used for teleportation.
  40660. * @param floorMesh the mesh to be used for teleportation.
  40661. */
  40662. addFloorMesh(floorMesh: Mesh): void;
  40663. /**
  40664. * Removes a floor mesh from being used for teleportation.
  40665. * @param floorMesh the mesh to be removed.
  40666. */
  40667. removeFloorMesh(floorMesh: Mesh): void;
  40668. /**
  40669. * Enables interactions and teleportation using the VR controllers and gaze.
  40670. * @param vrTeleportationOptions options to modify teleportation behavior.
  40671. */
  40672. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40673. private _onNewGamepadConnected;
  40674. private _tryEnableInteractionOnController;
  40675. private _onNewGamepadDisconnected;
  40676. private _enableInteractionOnController;
  40677. private _checkTeleportWithRay;
  40678. private _checkRotate;
  40679. private _checkTeleportBackwards;
  40680. private _enableTeleportationOnController;
  40681. private _createTeleportationCircles;
  40682. private _displayTeleportationTarget;
  40683. private _hideTeleportationTarget;
  40684. private _rotateCamera;
  40685. private _moveTeleportationSelectorTo;
  40686. private _workingVector;
  40687. private _workingQuaternion;
  40688. private _workingMatrix;
  40689. /**
  40690. * Teleports the users feet to the desired location
  40691. * @param location The location where the user's feet should be placed
  40692. */
  40693. teleportCamera(location: Vector3): void;
  40694. private _convertNormalToDirectionOfRay;
  40695. private _castRayAndSelectObject;
  40696. private _notifySelectedMeshUnselected;
  40697. /**
  40698. * Sets the color of the laser ray from the vr controllers.
  40699. * @param color new color for the ray.
  40700. */
  40701. changeLaserColor(color: Color3): void;
  40702. /**
  40703. * Sets the color of the ray from the vr headsets gaze.
  40704. * @param color new color for the ray.
  40705. */
  40706. changeGazeColor(color: Color3): void;
  40707. /**
  40708. * Exits VR and disposes of the vr experience helper
  40709. */
  40710. dispose(): void;
  40711. /**
  40712. * Gets the name of the VRExperienceHelper class
  40713. * @returns "VRExperienceHelper"
  40714. */
  40715. getClassName(): string;
  40716. }
  40717. }
  40718. declare module "babylonjs/Cameras/VR/index" {
  40719. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40720. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40721. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40722. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40723. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40724. export * from "babylonjs/Cameras/VR/webVRCamera";
  40725. }
  40726. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40727. import { Observable } from "babylonjs/Misc/observable";
  40728. import { Nullable } from "babylonjs/types";
  40729. import { IDisposable, Scene } from "babylonjs/scene";
  40730. import { Vector3 } from "babylonjs/Maths/math";
  40731. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40732. import { Ray } from "babylonjs/Culling/ray";
  40733. /**
  40734. * Manages an XRSession
  40735. * @see https://doc.babylonjs.com/how_to/webxr
  40736. */
  40737. export class WebXRSessionManager implements IDisposable {
  40738. private scene;
  40739. /**
  40740. * Fires every time a new xrFrame arrives which can be used to update the camera
  40741. */
  40742. onXRFrameObservable: Observable<any>;
  40743. /**
  40744. * Fires when the xr session is ended either by the device or manually done
  40745. */
  40746. onXRSessionEnded: Observable<any>;
  40747. /** @hidden */
  40748. _xrSession: XRSession;
  40749. /** @hidden */
  40750. _frameOfReference: XRFrameOfReference;
  40751. /** @hidden */
  40752. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40753. /** @hidden */
  40754. _currentXRFrame: Nullable<XRFrame>;
  40755. private _xrNavigator;
  40756. private _xrDevice;
  40757. private _tmpMatrix;
  40758. /**
  40759. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40760. * @param scene The scene which the session should be created for
  40761. */
  40762. constructor(scene: Scene);
  40763. /**
  40764. * Initializes the manager
  40765. * After initialization enterXR can be called to start an XR session
  40766. * @returns Promise which resolves after it is initialized
  40767. */
  40768. initializeAsync(): Promise<void>;
  40769. /**
  40770. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40771. * @param sessionCreationOptions xr options to create the session with
  40772. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40773. * @returns Promise which resolves after it enters XR
  40774. */
  40775. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40776. /**
  40777. * Stops the xrSession and restores the renderloop
  40778. * @returns Promise which resolves after it exits XR
  40779. */
  40780. exitXRAsync(): Promise<void>;
  40781. /**
  40782. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40783. * @param ray ray to cast into the environment
  40784. * @returns Promise which resolves with a collision point in the environment if it exists
  40785. */
  40786. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40787. /**
  40788. * Checks if a session would be supported for the creation options specified
  40789. * @param options creation options to check if they are supported
  40790. * @returns true if supported
  40791. */
  40792. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40793. /**
  40794. * @hidden
  40795. * Converts the render layer of xrSession to a render target
  40796. * @param session session to create render target for
  40797. * @param scene scene the new render target should be created for
  40798. */
  40799. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40800. /**
  40801. * Disposes of the session manager
  40802. */
  40803. dispose(): void;
  40804. }
  40805. }
  40806. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40807. import { Scene } from "babylonjs/scene";
  40808. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40809. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40810. /**
  40811. * WebXR Camera which holds the views for the xrSession
  40812. * @see https://doc.babylonjs.com/how_to/webxr
  40813. */
  40814. export class WebXRCamera extends FreeCamera {
  40815. private static _TmpMatrix;
  40816. /**
  40817. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40818. * @param name the name of the camera
  40819. * @param scene the scene to add the camera to
  40820. */
  40821. constructor(name: string, scene: Scene);
  40822. private _updateNumberOfRigCameras;
  40823. /** @hidden */
  40824. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40825. /**
  40826. * Updates the cameras position from the current pose information of the XR session
  40827. * @param xrSessionManager the session containing pose information
  40828. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40829. */
  40830. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40831. }
  40832. }
  40833. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40834. import { Nullable } from "babylonjs/types";
  40835. import { Observable } from "babylonjs/Misc/observable";
  40836. import { IDisposable, Scene } from "babylonjs/scene";
  40837. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40839. import { Ray } from "babylonjs/Culling/ray";
  40840. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40841. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40842. /**
  40843. * States of the webXR experience
  40844. */
  40845. export enum WebXRState {
  40846. /**
  40847. * Transitioning to being in XR mode
  40848. */
  40849. ENTERING_XR = 0,
  40850. /**
  40851. * Transitioning to non XR mode
  40852. */
  40853. EXITING_XR = 1,
  40854. /**
  40855. * In XR mode and presenting
  40856. */
  40857. IN_XR = 2,
  40858. /**
  40859. * Not entered XR mode
  40860. */
  40861. NOT_IN_XR = 3
  40862. }
  40863. /**
  40864. * Helper class used to enable XR
  40865. * @see https://doc.babylonjs.com/how_to/webxr
  40866. */
  40867. export class WebXRExperienceHelper implements IDisposable {
  40868. private scene;
  40869. /**
  40870. * 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
  40871. */
  40872. container: AbstractMesh;
  40873. /**
  40874. * Camera used to render xr content
  40875. */
  40876. camera: WebXRCamera;
  40877. /**
  40878. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40879. */
  40880. state: WebXRState;
  40881. private _setState;
  40882. private static _TmpVector;
  40883. /**
  40884. * Fires when the state of the experience helper has changed
  40885. */
  40886. onStateChangedObservable: Observable<WebXRState>;
  40887. /** @hidden */
  40888. _sessionManager: WebXRSessionManager;
  40889. private _nonVRCamera;
  40890. private _originalSceneAutoClear;
  40891. private _supported;
  40892. /**
  40893. * Creates the experience helper
  40894. * @param scene the scene to attach the experience helper to
  40895. * @returns a promise for the experience helper
  40896. */
  40897. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40898. /**
  40899. * Creates a WebXRExperienceHelper
  40900. * @param scene The scene the helper should be created in
  40901. */
  40902. private constructor();
  40903. /**
  40904. * Exits XR mode and returns the scene to its original state
  40905. * @returns promise that resolves after xr mode has exited
  40906. */
  40907. exitXRAsync(): Promise<void>;
  40908. /**
  40909. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40910. * @param sessionCreationOptions options for the XR session
  40911. * @param frameOfReference frame of reference of the XR session
  40912. * @returns promise that resolves after xr mode has entered
  40913. */
  40914. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40915. /**
  40916. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40917. * @param ray ray to cast into the environment
  40918. * @returns Promise which resolves with a collision point in the environment if it exists
  40919. */
  40920. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40921. /**
  40922. * Updates the global position of the camera by moving the camera's container
  40923. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40924. * @param position The desired global position of the camera
  40925. */
  40926. setPositionOfCameraUsingContainer(position: Vector3): void;
  40927. /**
  40928. * Rotates the xr camera by rotating the camera's container around the camera's position
  40929. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40930. * @param rotation the desired quaternion rotation to apply to the camera
  40931. */
  40932. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40933. /**
  40934. * Checks if the creation options are supported by the xr session
  40935. * @param options creation options
  40936. * @returns true if supported
  40937. */
  40938. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40939. /**
  40940. * Disposes of the experience helper
  40941. */
  40942. dispose(): void;
  40943. }
  40944. }
  40945. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40946. import { Nullable } from "babylonjs/types";
  40947. import { Observable } from "babylonjs/Misc/observable";
  40948. import { IDisposable, Scene } from "babylonjs/scene";
  40949. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40950. /**
  40951. * Button which can be used to enter a different mode of XR
  40952. */
  40953. export class WebXREnterExitUIButton {
  40954. /** button element */
  40955. element: HTMLElement;
  40956. /** XR initialization options for the button */
  40957. initializationOptions: XRSessionCreationOptions;
  40958. /**
  40959. * Creates a WebXREnterExitUIButton
  40960. * @param element button element
  40961. * @param initializationOptions XR initialization options for the button
  40962. */
  40963. constructor(
  40964. /** button element */
  40965. element: HTMLElement,
  40966. /** XR initialization options for the button */
  40967. initializationOptions: XRSessionCreationOptions);
  40968. /**
  40969. * Overwritable function which can be used to update the button's visuals when the state changes
  40970. * @param activeButton the current active button in the UI
  40971. */
  40972. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40973. }
  40974. /**
  40975. * Options to create the webXR UI
  40976. */
  40977. export class WebXREnterExitUIOptions {
  40978. /**
  40979. * Context to enter xr with
  40980. */
  40981. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40982. /**
  40983. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40984. */
  40985. customButtons?: Array<WebXREnterExitUIButton>;
  40986. }
  40987. /**
  40988. * UI to allow the user to enter/exit XR mode
  40989. */
  40990. export class WebXREnterExitUI implements IDisposable {
  40991. private scene;
  40992. private _overlay;
  40993. private _buttons;
  40994. private _activeButton;
  40995. /**
  40996. * Fired every time the active button is changed.
  40997. *
  40998. * When xr is entered via a button that launches xr that button will be the callback parameter
  40999. *
  41000. * When exiting xr the callback parameter will be null)
  41001. */
  41002. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41003. /**
  41004. * Creates UI to allow the user to enter/exit XR mode
  41005. * @param scene the scene to add the ui to
  41006. * @param helper the xr experience helper to enter/exit xr with
  41007. * @param options options to configure the UI
  41008. * @returns the created ui
  41009. */
  41010. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41011. private constructor();
  41012. private _updateButtons;
  41013. /**
  41014. * Disposes of the object
  41015. */
  41016. dispose(): void;
  41017. }
  41018. }
  41019. declare module "babylonjs/Cameras/XR/webXRInput" {
  41020. import { IDisposable, Scene } from "babylonjs/scene";
  41021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41022. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41023. /**
  41024. * Represents an XR input
  41025. */
  41026. export class WebXRController {
  41027. /**
  41028. * 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
  41029. */
  41030. grip?: AbstractMesh;
  41031. /**
  41032. * Pointer which can be used to select objects or attach a visible laser to
  41033. */
  41034. pointer: AbstractMesh;
  41035. /**
  41036. * Creates the controller
  41037. * @see https://doc.babylonjs.com/how_to/webxr
  41038. * @param scene the scene which the controller should be associated to
  41039. */
  41040. constructor(scene: Scene);
  41041. /**
  41042. * Disposes of the object
  41043. */
  41044. dispose(): void;
  41045. }
  41046. /**
  41047. * XR input used to track XR inputs such as controllers/rays
  41048. */
  41049. export class WebXRInput implements IDisposable {
  41050. private helper;
  41051. /**
  41052. * XR controllers being tracked
  41053. */
  41054. controllers: Array<WebXRController>;
  41055. private _tmpMatrix;
  41056. private _frameObserver;
  41057. /**
  41058. * Initializes the WebXRInput
  41059. * @param helper experience helper which the input should be created for
  41060. */
  41061. constructor(helper: WebXRExperienceHelper);
  41062. /**
  41063. * Disposes of the object
  41064. */
  41065. dispose(): void;
  41066. }
  41067. }
  41068. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41069. import { Nullable } from "babylonjs/types";
  41070. import { IDisposable } from "babylonjs/scene";
  41071. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41072. /**
  41073. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41074. */
  41075. export class WebXRManagedOutputCanvas implements IDisposable {
  41076. private _canvas;
  41077. /**
  41078. * xrpresent context of the canvas which can be used to display/mirror xr content
  41079. */
  41080. canvasContext: Nullable<WebGLRenderingContext>;
  41081. /**
  41082. * Initializes the canvas to be added/removed upon entering/exiting xr
  41083. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41084. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41085. */
  41086. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41087. /**
  41088. * Disposes of the object
  41089. */
  41090. dispose(): void;
  41091. private _setManagedOutputCanvas;
  41092. private _addCanvas;
  41093. private _removeCanvas;
  41094. }
  41095. }
  41096. declare module "babylonjs/Cameras/XR/index" {
  41097. export * from "babylonjs/Cameras/XR/webXRCamera";
  41098. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41099. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41100. export * from "babylonjs/Cameras/XR/webXRInput";
  41101. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41102. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41103. }
  41104. declare module "babylonjs/Cameras/RigModes/index" {
  41105. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41106. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41107. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41108. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41109. }
  41110. declare module "babylonjs/Cameras/index" {
  41111. export * from "babylonjs/Cameras/Inputs/index";
  41112. export * from "babylonjs/Cameras/cameraInputsManager";
  41113. export * from "babylonjs/Cameras/camera";
  41114. export * from "babylonjs/Cameras/targetCamera";
  41115. export * from "babylonjs/Cameras/freeCamera";
  41116. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41117. export * from "babylonjs/Cameras/touchCamera";
  41118. export * from "babylonjs/Cameras/arcRotateCamera";
  41119. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41120. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41121. export * from "babylonjs/Cameras/flyCamera";
  41122. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41123. export * from "babylonjs/Cameras/followCamera";
  41124. export * from "babylonjs/Cameras/gamepadCamera";
  41125. export * from "babylonjs/Cameras/Stereoscopic/index";
  41126. export * from "babylonjs/Cameras/universalCamera";
  41127. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41128. export * from "babylonjs/Cameras/VR/index";
  41129. export * from "babylonjs/Cameras/XR/index";
  41130. export * from "babylonjs/Cameras/RigModes/index";
  41131. }
  41132. declare module "babylonjs/Collisions/index" {
  41133. export * from "babylonjs/Collisions/collider";
  41134. export * from "babylonjs/Collisions/collisionCoordinator";
  41135. export * from "babylonjs/Collisions/pickingInfo";
  41136. export * from "babylonjs/Collisions/intersectionInfo";
  41137. }
  41138. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41139. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41140. import { Vector3, Plane } from "babylonjs/Maths/math";
  41141. import { Ray } from "babylonjs/Culling/ray";
  41142. /**
  41143. * Contains an array of blocks representing the octree
  41144. */
  41145. export interface IOctreeContainer<T> {
  41146. /**
  41147. * Blocks within the octree
  41148. */
  41149. blocks: Array<OctreeBlock<T>>;
  41150. }
  41151. /**
  41152. * Class used to store a cell in an octree
  41153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41154. */
  41155. export class OctreeBlock<T> {
  41156. /**
  41157. * Gets the content of the current block
  41158. */
  41159. entries: T[];
  41160. /**
  41161. * Gets the list of block children
  41162. */
  41163. blocks: Array<OctreeBlock<T>>;
  41164. private _depth;
  41165. private _maxDepth;
  41166. private _capacity;
  41167. private _minPoint;
  41168. private _maxPoint;
  41169. private _boundingVectors;
  41170. private _creationFunc;
  41171. /**
  41172. * Creates a new block
  41173. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41174. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41175. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41176. * @param depth defines the current depth of this block in the octree
  41177. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41178. * @param creationFunc defines a callback to call when an element is added to the block
  41179. */
  41180. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41181. /**
  41182. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41183. */
  41184. readonly capacity: number;
  41185. /**
  41186. * Gets the minimum vector (in world space) of the block's bounding box
  41187. */
  41188. readonly minPoint: Vector3;
  41189. /**
  41190. * Gets the maximum vector (in world space) of the block's bounding box
  41191. */
  41192. readonly maxPoint: Vector3;
  41193. /**
  41194. * Add a new element to this block
  41195. * @param entry defines the element to add
  41196. */
  41197. addEntry(entry: T): void;
  41198. /**
  41199. * Remove an element from this block
  41200. * @param entry defines the element to remove
  41201. */
  41202. removeEntry(entry: T): void;
  41203. /**
  41204. * Add an array of elements to this block
  41205. * @param entries defines the array of elements to add
  41206. */
  41207. addEntries(entries: T[]): void;
  41208. /**
  41209. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41210. * @param frustumPlanes defines the frustum planes to test
  41211. * @param selection defines the array to store current content if selection is positive
  41212. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41213. */
  41214. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41215. /**
  41216. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41217. * @param sphereCenter defines the bounding sphere center
  41218. * @param sphereRadius defines the bounding sphere radius
  41219. * @param selection defines the array to store current content if selection is positive
  41220. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41221. */
  41222. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41223. /**
  41224. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41225. * @param ray defines the ray to test with
  41226. * @param selection defines the array to store current content if selection is positive
  41227. */
  41228. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41229. /**
  41230. * Subdivide the content into child blocks (this block will then be empty)
  41231. */
  41232. createInnerBlocks(): void;
  41233. /**
  41234. * @hidden
  41235. */
  41236. 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;
  41237. }
  41238. }
  41239. declare module "babylonjs/Culling/Octrees/octree" {
  41240. import { SmartArray } from "babylonjs/Misc/smartArray";
  41241. import { Vector3, Plane } from "babylonjs/Maths/math";
  41242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41244. import { Ray } from "babylonjs/Culling/ray";
  41245. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41246. /**
  41247. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41248. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41249. */
  41250. export class Octree<T> {
  41251. /** 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.) */
  41252. maxDepth: number;
  41253. /**
  41254. * Blocks within the octree containing objects
  41255. */
  41256. blocks: Array<OctreeBlock<T>>;
  41257. /**
  41258. * Content stored in the octree
  41259. */
  41260. dynamicContent: T[];
  41261. private _maxBlockCapacity;
  41262. private _selectionContent;
  41263. private _creationFunc;
  41264. /**
  41265. * Creates a octree
  41266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41267. * @param creationFunc function to be used to instatiate the octree
  41268. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41269. * @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.)
  41270. */
  41271. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41272. /** 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.) */
  41273. maxDepth?: number);
  41274. /**
  41275. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41276. * @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);
  41277. * @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);
  41278. * @param entries meshes to be added to the octree blocks
  41279. */
  41280. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41281. /**
  41282. * Adds a mesh to the octree
  41283. * @param entry Mesh to add to the octree
  41284. */
  41285. addMesh(entry: T): void;
  41286. /**
  41287. * Remove an element from the octree
  41288. * @param entry defines the element to remove
  41289. */
  41290. removeMesh(entry: T): void;
  41291. /**
  41292. * Selects an array of meshes within the frustum
  41293. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41294. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41295. * @returns array of meshes within the frustum
  41296. */
  41297. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41298. /**
  41299. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41300. * @param sphereCenter defines the bounding sphere center
  41301. * @param sphereRadius defines the bounding sphere radius
  41302. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41303. * @returns an array of objects that intersect the sphere
  41304. */
  41305. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41306. /**
  41307. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41308. * @param ray defines the ray to test with
  41309. * @returns array of intersected objects
  41310. */
  41311. intersectsRay(ray: Ray): SmartArray<T>;
  41312. /**
  41313. * Adds a mesh into the octree block if it intersects the block
  41314. */
  41315. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41316. /**
  41317. * Adds a submesh into the octree block if it intersects the block
  41318. */
  41319. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41320. }
  41321. }
  41322. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41323. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41324. import { Scene } from "babylonjs/scene";
  41325. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41327. import { Ray } from "babylonjs/Culling/ray";
  41328. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41329. import { Collider } from "babylonjs/Collisions/collider";
  41330. module "babylonjs/scene" {
  41331. interface Scene {
  41332. /**
  41333. * @hidden
  41334. * Backing Filed
  41335. */
  41336. _selectionOctree: Octree<AbstractMesh>;
  41337. /**
  41338. * Gets the octree used to boost mesh selection (picking)
  41339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41340. */
  41341. selectionOctree: Octree<AbstractMesh>;
  41342. /**
  41343. * Creates or updates the octree used to boost selection (picking)
  41344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41345. * @param maxCapacity defines the maximum capacity per leaf
  41346. * @param maxDepth defines the maximum depth of the octree
  41347. * @returns an octree of AbstractMesh
  41348. */
  41349. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41350. }
  41351. }
  41352. module "babylonjs/Meshes/abstractMesh" {
  41353. interface AbstractMesh {
  41354. /**
  41355. * @hidden
  41356. * Backing Field
  41357. */
  41358. _submeshesOctree: Octree<SubMesh>;
  41359. /**
  41360. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41361. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41362. * @param maxCapacity defines the maximum size of each block (64 by default)
  41363. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41364. * @returns the new octree
  41365. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41367. */
  41368. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41369. }
  41370. }
  41371. /**
  41372. * Defines the octree scene component responsible to manage any octrees
  41373. * in a given scene.
  41374. */
  41375. export class OctreeSceneComponent {
  41376. /**
  41377. * The component name helpfull to identify the component in the list of scene components.
  41378. */
  41379. readonly name: string;
  41380. /**
  41381. * The scene the component belongs to.
  41382. */
  41383. scene: Scene;
  41384. /**
  41385. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41386. */
  41387. readonly checksIsEnabled: boolean;
  41388. /**
  41389. * Creates a new instance of the component for the given scene
  41390. * @param scene Defines the scene to register the component in
  41391. */
  41392. constructor(scene: Scene);
  41393. /**
  41394. * Registers the component in a given scene
  41395. */
  41396. register(): void;
  41397. /**
  41398. * Return the list of active meshes
  41399. * @returns the list of active meshes
  41400. */
  41401. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41402. /**
  41403. * Return the list of active sub meshes
  41404. * @param mesh The mesh to get the candidates sub meshes from
  41405. * @returns the list of active sub meshes
  41406. */
  41407. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41408. private _tempRay;
  41409. /**
  41410. * Return the list of sub meshes intersecting with a given local ray
  41411. * @param mesh defines the mesh to find the submesh for
  41412. * @param localRay defines the ray in local space
  41413. * @returns the list of intersecting sub meshes
  41414. */
  41415. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41416. /**
  41417. * Return the list of sub meshes colliding with a collider
  41418. * @param mesh defines the mesh to find the submesh for
  41419. * @param collider defines the collider to evaluate the collision against
  41420. * @returns the list of colliding sub meshes
  41421. */
  41422. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41423. /**
  41424. * Rebuilds the elements related to this component in case of
  41425. * context lost for instance.
  41426. */
  41427. rebuild(): void;
  41428. /**
  41429. * Disposes the component and the associated ressources.
  41430. */
  41431. dispose(): void;
  41432. }
  41433. }
  41434. declare module "babylonjs/Culling/Octrees/index" {
  41435. export * from "babylonjs/Culling/Octrees/octree";
  41436. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41437. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41438. }
  41439. declare module "babylonjs/Culling/index" {
  41440. export * from "babylonjs/Culling/boundingBox";
  41441. export * from "babylonjs/Culling/boundingInfo";
  41442. export * from "babylonjs/Culling/boundingSphere";
  41443. export * from "babylonjs/Culling/Octrees/index";
  41444. export * from "babylonjs/Culling/ray";
  41445. }
  41446. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41447. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41448. import { Nullable } from "babylonjs/types";
  41449. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41450. import { Scene } from "babylonjs/scene";
  41451. /**
  41452. * Class containing static functions to help procedurally build meshes
  41453. */
  41454. export class LinesBuilder {
  41455. /**
  41456. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41457. * * 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
  41458. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41459. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41460. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41461. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41462. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41463. * * 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
  41464. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41467. * @param name defines the name of the new line system
  41468. * @param options defines the options used to create the line system
  41469. * @param scene defines the hosting scene
  41470. * @returns a new line system mesh
  41471. */
  41472. static CreateLineSystem(name: string, options: {
  41473. lines: Vector3[][];
  41474. updatable?: boolean;
  41475. instance?: Nullable<LinesMesh>;
  41476. colors?: Nullable<Color4[][]>;
  41477. useVertexAlpha?: boolean;
  41478. }, scene: Nullable<Scene>): LinesMesh;
  41479. /**
  41480. * Creates a line mesh
  41481. * 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
  41482. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41483. * * The parameter `points` is an array successive Vector3
  41484. * * 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
  41485. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41486. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41487. * * When updating an instance, remember that only point positions can change, not the number of points
  41488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41490. * @param name defines the name of the new line system
  41491. * @param options defines the options used to create the line system
  41492. * @param scene defines the hosting scene
  41493. * @returns a new line mesh
  41494. */
  41495. static CreateLines(name: string, options: {
  41496. points: Vector3[];
  41497. updatable?: boolean;
  41498. instance?: Nullable<LinesMesh>;
  41499. colors?: Color4[];
  41500. useVertexAlpha?: boolean;
  41501. }, scene?: Nullable<Scene>): LinesMesh;
  41502. /**
  41503. * Creates a dashed line mesh
  41504. * * 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
  41505. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41506. * * The parameter `points` is an array successive Vector3
  41507. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41508. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41509. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41510. * * 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
  41511. * * When updating an instance, remember that only point positions can change, not the number of points
  41512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41513. * @param name defines the name of the mesh
  41514. * @param options defines the options used to create the mesh
  41515. * @param scene defines the hosting scene
  41516. * @returns the dashed line mesh
  41517. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41518. */
  41519. static CreateDashedLines(name: string, options: {
  41520. points: Vector3[];
  41521. dashSize?: number;
  41522. gapSize?: number;
  41523. dashNb?: number;
  41524. updatable?: boolean;
  41525. instance?: LinesMesh;
  41526. }, scene?: Nullable<Scene>): LinesMesh;
  41527. }
  41528. }
  41529. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41530. import { IDisposable, Scene } from "babylonjs/scene";
  41531. import { Nullable } from "babylonjs/types";
  41532. import { Observable } from "babylonjs/Misc/observable";
  41533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41534. /**
  41535. * Renders a layer on top of an existing scene
  41536. */
  41537. export class UtilityLayerRenderer implements IDisposable {
  41538. /** the original scene that will be rendered on top of */
  41539. originalScene: Scene;
  41540. private _pointerCaptures;
  41541. private _lastPointerEvents;
  41542. private static _DefaultUtilityLayer;
  41543. private static _DefaultKeepDepthUtilityLayer;
  41544. /**
  41545. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41546. */
  41547. pickUtilitySceneFirst: boolean;
  41548. /**
  41549. * 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)
  41550. */
  41551. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41552. /**
  41553. * 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)
  41554. */
  41555. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41556. /**
  41557. * The scene that is rendered on top of the original scene
  41558. */
  41559. utilityLayerScene: Scene;
  41560. /**
  41561. * If the utility layer should automatically be rendered on top of existing scene
  41562. */
  41563. shouldRender: boolean;
  41564. /**
  41565. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41566. */
  41567. onlyCheckPointerDownEvents: boolean;
  41568. /**
  41569. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41570. */
  41571. processAllEvents: boolean;
  41572. /**
  41573. * Observable raised when the pointer move from the utility layer scene to the main scene
  41574. */
  41575. onPointerOutObservable: Observable<number>;
  41576. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41577. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41578. private _afterRenderObserver;
  41579. private _sceneDisposeObserver;
  41580. private _originalPointerObserver;
  41581. /**
  41582. * Instantiates a UtilityLayerRenderer
  41583. * @param originalScene the original scene that will be rendered on top of
  41584. * @param handleEvents boolean indicating if the utility layer should handle events
  41585. */
  41586. constructor(
  41587. /** the original scene that will be rendered on top of */
  41588. originalScene: Scene, handleEvents?: boolean);
  41589. private _notifyObservers;
  41590. /**
  41591. * Renders the utility layers scene on top of the original scene
  41592. */
  41593. render(): void;
  41594. /**
  41595. * Disposes of the renderer
  41596. */
  41597. dispose(): void;
  41598. private _updateCamera;
  41599. }
  41600. }
  41601. declare module "babylonjs/Gizmos/gizmo" {
  41602. import { Nullable } from "babylonjs/types";
  41603. import { IDisposable } from "babylonjs/scene";
  41604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41605. import { Mesh } from "babylonjs/Meshes/mesh";
  41606. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41607. /**
  41608. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41609. */
  41610. export class Gizmo implements IDisposable {
  41611. /** The utility layer the gizmo will be added to */
  41612. gizmoLayer: UtilityLayerRenderer;
  41613. /**
  41614. * The root mesh of the gizmo
  41615. */
  41616. _rootMesh: Mesh;
  41617. private _attachedMesh;
  41618. /**
  41619. * Ratio for the scale of the gizmo (Default: 1)
  41620. */
  41621. scaleRatio: number;
  41622. private _tmpMatrix;
  41623. /**
  41624. * If a custom mesh has been set (Default: false)
  41625. */
  41626. protected _customMeshSet: boolean;
  41627. /**
  41628. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41629. * * When set, interactions will be enabled
  41630. */
  41631. attachedMesh: Nullable<AbstractMesh>;
  41632. /**
  41633. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41634. * @param mesh The mesh to replace the default mesh of the gizmo
  41635. */
  41636. setCustomMesh(mesh: Mesh): void;
  41637. /**
  41638. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41639. */
  41640. updateGizmoRotationToMatchAttachedMesh: boolean;
  41641. /**
  41642. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41643. */
  41644. updateGizmoPositionToMatchAttachedMesh: boolean;
  41645. /**
  41646. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41647. */
  41648. protected _updateScale: boolean;
  41649. protected _interactionsEnabled: boolean;
  41650. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41651. private _beforeRenderObserver;
  41652. /**
  41653. * Creates a gizmo
  41654. * @param gizmoLayer The utility layer the gizmo will be added to
  41655. */
  41656. constructor(
  41657. /** The utility layer the gizmo will be added to */
  41658. gizmoLayer?: UtilityLayerRenderer);
  41659. private _tempVector;
  41660. /**
  41661. * @hidden
  41662. * Updates the gizmo to match the attached mesh's position/rotation
  41663. */
  41664. protected _update(): void;
  41665. /**
  41666. * Disposes of the gizmo
  41667. */
  41668. dispose(): void;
  41669. }
  41670. }
  41671. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41672. import { Observable } from "babylonjs/Misc/observable";
  41673. import { Nullable } from "babylonjs/types";
  41674. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41677. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41678. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41679. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41680. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41681. import { Scene } from "babylonjs/scene";
  41682. /**
  41683. * Single axis drag gizmo
  41684. */
  41685. export class AxisDragGizmo extends Gizmo {
  41686. /**
  41687. * Drag behavior responsible for the gizmos dragging interactions
  41688. */
  41689. dragBehavior: PointerDragBehavior;
  41690. private _pointerObserver;
  41691. /**
  41692. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41693. */
  41694. snapDistance: number;
  41695. /**
  41696. * Event that fires each time the gizmo snaps to a new location.
  41697. * * snapDistance is the the change in distance
  41698. */
  41699. onSnapObservable: Observable<{
  41700. snapDistance: number;
  41701. }>;
  41702. /** @hidden */
  41703. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41704. /** @hidden */
  41705. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41706. /**
  41707. * Creates an AxisDragGizmo
  41708. * @param gizmoLayer The utility layer the gizmo will be added to
  41709. * @param dragAxis The axis which the gizmo will be able to drag on
  41710. * @param color The color of the gizmo
  41711. */
  41712. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41713. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41714. /**
  41715. * Disposes of the gizmo
  41716. */
  41717. dispose(): void;
  41718. }
  41719. }
  41720. declare module "babylonjs/Debug/axesViewer" {
  41721. import { Vector3 } from "babylonjs/Maths/math";
  41722. import { Nullable } from "babylonjs/types";
  41723. import { Scene } from "babylonjs/scene";
  41724. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41725. /**
  41726. * The Axes viewer will show 3 axes in a specific point in space
  41727. */
  41728. export class AxesViewer {
  41729. private _xAxis;
  41730. private _yAxis;
  41731. private _zAxis;
  41732. private _scaleLinesFactor;
  41733. private _instanced;
  41734. /**
  41735. * Gets the hosting scene
  41736. */
  41737. scene: Scene;
  41738. /**
  41739. * Gets or sets a number used to scale line length
  41740. */
  41741. scaleLines: number;
  41742. /** Gets the node hierarchy used to render x-axis */
  41743. readonly xAxis: TransformNode;
  41744. /** Gets the node hierarchy used to render y-axis */
  41745. readonly yAxis: TransformNode;
  41746. /** Gets the node hierarchy used to render z-axis */
  41747. readonly zAxis: TransformNode;
  41748. /**
  41749. * Creates a new AxesViewer
  41750. * @param scene defines the hosting scene
  41751. * @param scaleLines defines a number used to scale line length (1 by default)
  41752. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41753. * @param xAxis defines the node hierarchy used to render the x-axis
  41754. * @param yAxis defines the node hierarchy used to render the y-axis
  41755. * @param zAxis defines the node hierarchy used to render the z-axis
  41756. */
  41757. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41758. /**
  41759. * Force the viewer to update
  41760. * @param position defines the position of the viewer
  41761. * @param xaxis defines the x axis of the viewer
  41762. * @param yaxis defines the y axis of the viewer
  41763. * @param zaxis defines the z axis of the viewer
  41764. */
  41765. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41766. /**
  41767. * Creates an instance of this axes viewer.
  41768. * @returns a new axes viewer with instanced meshes
  41769. */
  41770. createInstance(): AxesViewer;
  41771. /** Releases resources */
  41772. dispose(): void;
  41773. private static _SetRenderingGroupId;
  41774. }
  41775. }
  41776. declare module "babylonjs/Debug/boneAxesViewer" {
  41777. import { Nullable } from "babylonjs/types";
  41778. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41779. import { Vector3 } from "babylonjs/Maths/math";
  41780. import { Mesh } from "babylonjs/Meshes/mesh";
  41781. import { Bone } from "babylonjs/Bones/bone";
  41782. import { Scene } from "babylonjs/scene";
  41783. /**
  41784. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41785. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41786. */
  41787. export class BoneAxesViewer extends AxesViewer {
  41788. /**
  41789. * Gets or sets the target mesh where to display the axes viewer
  41790. */
  41791. mesh: Nullable<Mesh>;
  41792. /**
  41793. * Gets or sets the target bone where to display the axes viewer
  41794. */
  41795. bone: Nullable<Bone>;
  41796. /** Gets current position */
  41797. pos: Vector3;
  41798. /** Gets direction of X axis */
  41799. xaxis: Vector3;
  41800. /** Gets direction of Y axis */
  41801. yaxis: Vector3;
  41802. /** Gets direction of Z axis */
  41803. zaxis: Vector3;
  41804. /**
  41805. * Creates a new BoneAxesViewer
  41806. * @param scene defines the hosting scene
  41807. * @param bone defines the target bone
  41808. * @param mesh defines the target mesh
  41809. * @param scaleLines defines a scaling factor for line length (1 by default)
  41810. */
  41811. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41812. /**
  41813. * Force the viewer to update
  41814. */
  41815. update(): void;
  41816. /** Releases resources */
  41817. dispose(): void;
  41818. }
  41819. }
  41820. declare module "babylonjs/Debug/debugLayer" {
  41821. import { Observable } from "babylonjs/Misc/observable";
  41822. import { Scene } from "babylonjs/scene";
  41823. /**
  41824. * Interface used to define scene explorer extensibility option
  41825. */
  41826. export interface IExplorerExtensibilityOption {
  41827. /**
  41828. * Define the option label
  41829. */
  41830. label: string;
  41831. /**
  41832. * Defines the action to execute on click
  41833. */
  41834. action: (entity: any) => void;
  41835. }
  41836. /**
  41837. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41838. */
  41839. export interface IExplorerExtensibilityGroup {
  41840. /**
  41841. * Defines a predicate to test if a given type mut be extended
  41842. */
  41843. predicate: (entity: any) => boolean;
  41844. /**
  41845. * Gets the list of options added to a type
  41846. */
  41847. entries: IExplorerExtensibilityOption[];
  41848. }
  41849. /**
  41850. * Interface used to define the options to use to create the Inspector
  41851. */
  41852. export interface IInspectorOptions {
  41853. /**
  41854. * Display in overlay mode (default: false)
  41855. */
  41856. overlay?: boolean;
  41857. /**
  41858. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41859. */
  41860. globalRoot?: HTMLElement;
  41861. /**
  41862. * Display the Scene explorer
  41863. */
  41864. showExplorer?: boolean;
  41865. /**
  41866. * Display the property inspector
  41867. */
  41868. showInspector?: boolean;
  41869. /**
  41870. * Display in embed mode (both panes on the right)
  41871. */
  41872. embedMode?: boolean;
  41873. /**
  41874. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41875. */
  41876. handleResize?: boolean;
  41877. /**
  41878. * Allow the panes to popup (default: true)
  41879. */
  41880. enablePopup?: boolean;
  41881. /**
  41882. * Allow the panes to be closed by users (default: true)
  41883. */
  41884. enableClose?: boolean;
  41885. /**
  41886. * Optional list of extensibility entries
  41887. */
  41888. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41889. /**
  41890. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41891. */
  41892. inspectorURL?: string;
  41893. }
  41894. module "babylonjs/scene" {
  41895. interface Scene {
  41896. /**
  41897. * @hidden
  41898. * Backing field
  41899. */
  41900. _debugLayer: DebugLayer;
  41901. /**
  41902. * Gets the debug layer (aka Inspector) associated with the scene
  41903. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41904. */
  41905. debugLayer: DebugLayer;
  41906. }
  41907. }
  41908. /**
  41909. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41910. * what is happening in your scene
  41911. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41912. */
  41913. export class DebugLayer {
  41914. /**
  41915. * Define the url to get the inspector script from.
  41916. * By default it uses the babylonjs CDN.
  41917. * @ignoreNaming
  41918. */
  41919. static InspectorURL: string;
  41920. private _scene;
  41921. private BJSINSPECTOR;
  41922. /**
  41923. * Observable triggered when a property is changed through the inspector.
  41924. */
  41925. onPropertyChangedObservable: Observable<{
  41926. object: any;
  41927. property: string;
  41928. value: any;
  41929. initialValue: any;
  41930. }>;
  41931. /**
  41932. * Instantiates a new debug layer.
  41933. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41934. * what is happening in your scene
  41935. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41936. * @param scene Defines the scene to inspect
  41937. */
  41938. constructor(scene: Scene);
  41939. /** Creates the inspector window. */
  41940. private _createInspector;
  41941. /**
  41942. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41943. * @param entity defines the entity to select
  41944. * @param lineContainerTitle defines the specific block to highlight
  41945. */
  41946. select(entity: any, lineContainerTitle?: string): void;
  41947. /** Get the inspector from bundle or global */
  41948. private _getGlobalInspector;
  41949. /**
  41950. * Get if the inspector is visible or not.
  41951. * @returns true if visible otherwise, false
  41952. */
  41953. isVisible(): boolean;
  41954. /**
  41955. * Hide the inspector and close its window.
  41956. */
  41957. hide(): void;
  41958. /**
  41959. * Launch the debugLayer.
  41960. * @param config Define the configuration of the inspector
  41961. * @return a promise fulfilled when the debug layer is visible
  41962. */
  41963. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41964. }
  41965. }
  41966. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41967. import { Nullable } from "babylonjs/types";
  41968. import { Scene } from "babylonjs/scene";
  41969. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41970. import { Mesh } from "babylonjs/Meshes/mesh";
  41971. /**
  41972. * Class containing static functions to help procedurally build meshes
  41973. */
  41974. export class BoxBuilder {
  41975. /**
  41976. * Creates a box mesh
  41977. * * The parameter `size` sets the size (float) of each box side (default 1)
  41978. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41979. * * 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)
  41980. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41984. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41985. * @param name defines the name of the mesh
  41986. * @param options defines the options used to create the mesh
  41987. * @param scene defines the hosting scene
  41988. * @returns the box mesh
  41989. */
  41990. static CreateBox(name: string, options: {
  41991. size?: number;
  41992. width?: number;
  41993. height?: number;
  41994. depth?: number;
  41995. faceUV?: Vector4[];
  41996. faceColors?: Color4[];
  41997. sideOrientation?: number;
  41998. frontUVs?: Vector4;
  41999. backUVs?: Vector4;
  42000. updatable?: boolean;
  42001. }, scene?: Nullable<Scene>): Mesh;
  42002. }
  42003. }
  42004. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42005. import { Vector4 } from "babylonjs/Maths/math";
  42006. import { Mesh } from "babylonjs/Meshes/mesh";
  42007. /**
  42008. * Class containing static functions to help procedurally build meshes
  42009. */
  42010. export class SphereBuilder {
  42011. /**
  42012. * Creates a sphere mesh
  42013. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42014. * * 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`)
  42015. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42016. * * 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
  42017. * * 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)
  42018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42021. * @param name defines the name of the mesh
  42022. * @param options defines the options used to create the mesh
  42023. * @param scene defines the hosting scene
  42024. * @returns the sphere mesh
  42025. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42026. */
  42027. static CreateSphere(name: string, options: {
  42028. segments?: number;
  42029. diameter?: number;
  42030. diameterX?: number;
  42031. diameterY?: number;
  42032. diameterZ?: number;
  42033. arc?: number;
  42034. slice?: number;
  42035. sideOrientation?: number;
  42036. frontUVs?: Vector4;
  42037. backUVs?: Vector4;
  42038. updatable?: boolean;
  42039. }, scene: any): Mesh;
  42040. }
  42041. }
  42042. declare module "babylonjs/Debug/physicsViewer" {
  42043. import { Nullable } from "babylonjs/types";
  42044. import { Scene } from "babylonjs/scene";
  42045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42046. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42047. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42048. /**
  42049. * Used to show the physics impostor around the specific mesh
  42050. */
  42051. export class PhysicsViewer {
  42052. /** @hidden */
  42053. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42054. /** @hidden */
  42055. protected _meshes: Array<Nullable<AbstractMesh>>;
  42056. /** @hidden */
  42057. protected _scene: Nullable<Scene>;
  42058. /** @hidden */
  42059. protected _numMeshes: number;
  42060. /** @hidden */
  42061. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42062. private _renderFunction;
  42063. private _utilityLayer;
  42064. private _debugBoxMesh;
  42065. private _debugSphereMesh;
  42066. private _debugMaterial;
  42067. /**
  42068. * Creates a new PhysicsViewer
  42069. * @param scene defines the hosting scene
  42070. */
  42071. constructor(scene: Scene);
  42072. /** @hidden */
  42073. protected _updateDebugMeshes(): void;
  42074. /**
  42075. * Renders a specified physic impostor
  42076. * @param impostor defines the impostor to render
  42077. * @returns the new debug mesh used to render the impostor
  42078. */
  42079. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  42080. /**
  42081. * Hides a specified physic impostor
  42082. * @param impostor defines the impostor to hide
  42083. */
  42084. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42085. private _getDebugMaterial;
  42086. private _getDebugBoxMesh;
  42087. private _getDebugSphereMesh;
  42088. private _getDebugMesh;
  42089. /** Releases all resources */
  42090. dispose(): void;
  42091. }
  42092. }
  42093. declare module "babylonjs/Debug/rayHelper" {
  42094. import { Nullable } from "babylonjs/types";
  42095. import { Ray } from "babylonjs/Culling/ray";
  42096. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42097. import { Scene } from "babylonjs/scene";
  42098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42099. import "babylonjs/Meshes/Builders/linesBuilder";
  42100. /**
  42101. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42102. * in order to better appreciate the issue one might have.
  42103. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42104. */
  42105. export class RayHelper {
  42106. /**
  42107. * Defines the ray we are currently tryin to visualize.
  42108. */
  42109. ray: Nullable<Ray>;
  42110. private _renderPoints;
  42111. private _renderLine;
  42112. private _renderFunction;
  42113. private _scene;
  42114. private _updateToMeshFunction;
  42115. private _attachedToMesh;
  42116. private _meshSpaceDirection;
  42117. private _meshSpaceOrigin;
  42118. /**
  42119. * Helper function to create a colored helper in a scene in one line.
  42120. * @param ray Defines the ray we are currently tryin to visualize
  42121. * @param scene Defines the scene the ray is used in
  42122. * @param color Defines the color we want to see the ray in
  42123. * @returns The newly created ray helper.
  42124. */
  42125. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42126. /**
  42127. * Instantiate a new ray helper.
  42128. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42129. * in order to better appreciate the issue one might have.
  42130. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42131. * @param ray Defines the ray we are currently tryin to visualize
  42132. */
  42133. constructor(ray: Ray);
  42134. /**
  42135. * Shows the ray we are willing to debug.
  42136. * @param scene Defines the scene the ray needs to be rendered in
  42137. * @param color Defines the color the ray needs to be rendered in
  42138. */
  42139. show(scene: Scene, color?: Color3): void;
  42140. /**
  42141. * Hides the ray we are debugging.
  42142. */
  42143. hide(): void;
  42144. private _render;
  42145. /**
  42146. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42147. * @param mesh Defines the mesh we want the helper attached to
  42148. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42149. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42150. * @param length Defines the length of the ray
  42151. */
  42152. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42153. /**
  42154. * Detach the ray helper from the mesh it has previously been attached to.
  42155. */
  42156. detachFromMesh(): void;
  42157. private _updateToMesh;
  42158. /**
  42159. * Dispose the helper and release its associated resources.
  42160. */
  42161. dispose(): void;
  42162. }
  42163. }
  42164. declare module "babylonjs/Debug/skeletonViewer" {
  42165. import { Color3 } from "babylonjs/Maths/math";
  42166. import { Scene } from "babylonjs/scene";
  42167. import { Nullable } from "babylonjs/types";
  42168. import { Skeleton } from "babylonjs/Bones/skeleton";
  42169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42170. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42171. /**
  42172. * Class used to render a debug view of a given skeleton
  42173. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42174. */
  42175. export class SkeletonViewer {
  42176. /** defines the skeleton to render */
  42177. skeleton: Skeleton;
  42178. /** defines the mesh attached to the skeleton */
  42179. mesh: AbstractMesh;
  42180. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42181. autoUpdateBonesMatrices: boolean;
  42182. /** defines the rendering group id to use with the viewer */
  42183. renderingGroupId: number;
  42184. /** Gets or sets the color used to render the skeleton */
  42185. color: Color3;
  42186. private _scene;
  42187. private _debugLines;
  42188. private _debugMesh;
  42189. private _isEnabled;
  42190. private _renderFunction;
  42191. private _utilityLayer;
  42192. /**
  42193. * Returns the mesh used to render the bones
  42194. */
  42195. readonly debugMesh: Nullable<LinesMesh>;
  42196. /**
  42197. * Creates a new SkeletonViewer
  42198. * @param skeleton defines the skeleton to render
  42199. * @param mesh defines the mesh attached to the skeleton
  42200. * @param scene defines the hosting scene
  42201. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42202. * @param renderingGroupId defines the rendering group id to use with the viewer
  42203. */
  42204. constructor(
  42205. /** defines the skeleton to render */
  42206. skeleton: Skeleton,
  42207. /** defines the mesh attached to the skeleton */
  42208. mesh: AbstractMesh, scene: Scene,
  42209. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42210. autoUpdateBonesMatrices?: boolean,
  42211. /** defines the rendering group id to use with the viewer */
  42212. renderingGroupId?: number);
  42213. /** Gets or sets a boolean indicating if the viewer is enabled */
  42214. isEnabled: boolean;
  42215. private _getBonePosition;
  42216. private _getLinesForBonesWithLength;
  42217. private _getLinesForBonesNoLength;
  42218. /** Update the viewer to sync with current skeleton state */
  42219. update(): void;
  42220. /** Release associated resources */
  42221. dispose(): void;
  42222. }
  42223. }
  42224. declare module "babylonjs/Debug/index" {
  42225. export * from "babylonjs/Debug/axesViewer";
  42226. export * from "babylonjs/Debug/boneAxesViewer";
  42227. export * from "babylonjs/Debug/debugLayer";
  42228. export * from "babylonjs/Debug/physicsViewer";
  42229. export * from "babylonjs/Debug/rayHelper";
  42230. export * from "babylonjs/Debug/skeletonViewer";
  42231. }
  42232. declare module "babylonjs/Engines/nullEngine" {
  42233. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42234. import { Scene } from "babylonjs/scene";
  42235. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42236. import { Engine } from "babylonjs/Engines/engine";
  42237. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42238. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42239. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42240. import { Effect } from "babylonjs/Materials/effect";
  42241. /**
  42242. * Options to create the null engine
  42243. */
  42244. export class NullEngineOptions {
  42245. /**
  42246. * Render width (Default: 512)
  42247. */
  42248. renderWidth: number;
  42249. /**
  42250. * Render height (Default: 256)
  42251. */
  42252. renderHeight: number;
  42253. /**
  42254. * Texture size (Default: 512)
  42255. */
  42256. textureSize: number;
  42257. /**
  42258. * If delta time between frames should be constant
  42259. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42260. */
  42261. deterministicLockstep: boolean;
  42262. /**
  42263. * Maximum about of steps between frames (Default: 4)
  42264. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42265. */
  42266. lockstepMaxSteps: number;
  42267. }
  42268. /**
  42269. * The null engine class provides support for headless version of babylon.js.
  42270. * This can be used in server side scenario or for testing purposes
  42271. */
  42272. export class NullEngine extends Engine {
  42273. private _options;
  42274. /**
  42275. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42276. */
  42277. isDeterministicLockStep(): boolean;
  42278. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42279. getLockstepMaxSteps(): number;
  42280. /**
  42281. * Sets hardware scaling, used to save performance if needed
  42282. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42283. */
  42284. getHardwareScalingLevel(): number;
  42285. constructor(options?: NullEngineOptions);
  42286. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42287. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42288. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42289. getRenderWidth(useScreen?: boolean): number;
  42290. getRenderHeight(useScreen?: boolean): number;
  42291. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42292. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42293. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42294. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42295. bindSamplers(effect: Effect): void;
  42296. enableEffect(effect: Effect): void;
  42297. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42298. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42299. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42300. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42301. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42302. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42303. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42304. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42305. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42306. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42307. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42308. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42309. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42310. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42311. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42312. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42313. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42314. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42315. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42316. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42317. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42318. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42319. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42320. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42321. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42322. bindBuffers(vertexBuffers: {
  42323. [key: string]: VertexBuffer;
  42324. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42325. wipeCaches(bruteForce?: boolean): void;
  42326. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42327. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42328. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42329. /** @hidden */
  42330. _createTexture(): WebGLTexture;
  42331. /** @hidden */
  42332. _releaseTexture(texture: InternalTexture): void;
  42333. 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;
  42334. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42335. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42336. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42337. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42338. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42339. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42340. areAllEffectsReady(): boolean;
  42341. /**
  42342. * @hidden
  42343. * Get the current error code of the webGL context
  42344. * @returns the error code
  42345. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42346. */
  42347. getError(): number;
  42348. /** @hidden */
  42349. _getUnpackAlignement(): number;
  42350. /** @hidden */
  42351. _unpackFlipY(value: boolean): void;
  42352. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42353. /**
  42354. * Updates a dynamic vertex buffer.
  42355. * @param vertexBuffer the vertex buffer to update
  42356. * @param data the data used to update the vertex buffer
  42357. * @param byteOffset the byte offset of the data (optional)
  42358. * @param byteLength the byte length of the data (optional)
  42359. */
  42360. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42361. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42362. /** @hidden */
  42363. _bindTexture(channel: number, texture: InternalTexture): void;
  42364. /** @hidden */
  42365. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42366. releaseEffects(): void;
  42367. displayLoadingUI(): void;
  42368. hideLoadingUI(): void;
  42369. /** @hidden */
  42370. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42371. /** @hidden */
  42372. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42373. /** @hidden */
  42374. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42375. /** @hidden */
  42376. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42377. }
  42378. }
  42379. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42380. import { Nullable, int } from "babylonjs/types";
  42381. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42382. /** @hidden */
  42383. export class _OcclusionDataStorage {
  42384. /** @hidden */
  42385. occlusionInternalRetryCounter: number;
  42386. /** @hidden */
  42387. isOcclusionQueryInProgress: boolean;
  42388. /** @hidden */
  42389. isOccluded: boolean;
  42390. /** @hidden */
  42391. occlusionRetryCount: number;
  42392. /** @hidden */
  42393. occlusionType: number;
  42394. /** @hidden */
  42395. occlusionQueryAlgorithmType: number;
  42396. }
  42397. module "babylonjs/Engines/engine" {
  42398. interface Engine {
  42399. /**
  42400. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42401. * @return the new query
  42402. */
  42403. createQuery(): WebGLQuery;
  42404. /**
  42405. * Delete and release a webGL query
  42406. * @param query defines the query to delete
  42407. * @return the current engine
  42408. */
  42409. deleteQuery(query: WebGLQuery): Engine;
  42410. /**
  42411. * Check if a given query has resolved and got its value
  42412. * @param query defines the query to check
  42413. * @returns true if the query got its value
  42414. */
  42415. isQueryResultAvailable(query: WebGLQuery): boolean;
  42416. /**
  42417. * Gets the value of a given query
  42418. * @param query defines the query to check
  42419. * @returns the value of the query
  42420. */
  42421. getQueryResult(query: WebGLQuery): number;
  42422. /**
  42423. * Initiates an occlusion query
  42424. * @param algorithmType defines the algorithm to use
  42425. * @param query defines the query to use
  42426. * @returns the current engine
  42427. * @see http://doc.babylonjs.com/features/occlusionquery
  42428. */
  42429. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42430. /**
  42431. * Ends an occlusion query
  42432. * @see http://doc.babylonjs.com/features/occlusionquery
  42433. * @param algorithmType defines the algorithm to use
  42434. * @returns the current engine
  42435. */
  42436. endOcclusionQuery(algorithmType: number): Engine;
  42437. /**
  42438. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42439. * Please note that only one query can be issued at a time
  42440. * @returns a time token used to track the time span
  42441. */
  42442. startTimeQuery(): Nullable<_TimeToken>;
  42443. /**
  42444. * Ends a time query
  42445. * @param token defines the token used to measure the time span
  42446. * @returns the time spent (in ns)
  42447. */
  42448. endTimeQuery(token: _TimeToken): int;
  42449. /** @hidden */
  42450. _currentNonTimestampToken: Nullable<_TimeToken>;
  42451. /** @hidden */
  42452. _createTimeQuery(): WebGLQuery;
  42453. /** @hidden */
  42454. _deleteTimeQuery(query: WebGLQuery): void;
  42455. /** @hidden */
  42456. _getGlAlgorithmType(algorithmType: number): number;
  42457. /** @hidden */
  42458. _getTimeQueryResult(query: WebGLQuery): any;
  42459. /** @hidden */
  42460. _getTimeQueryAvailability(query: WebGLQuery): any;
  42461. }
  42462. }
  42463. module "babylonjs/Meshes/abstractMesh" {
  42464. interface AbstractMesh {
  42465. /**
  42466. * Backing filed
  42467. * @hidden
  42468. */
  42469. __occlusionDataStorage: _OcclusionDataStorage;
  42470. /**
  42471. * Access property
  42472. * @hidden
  42473. */
  42474. _occlusionDataStorage: _OcclusionDataStorage;
  42475. /**
  42476. * 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.
  42477. * The default value is -1 which means don't break the query and wait till the result
  42478. * @see http://doc.babylonjs.com/features/occlusionquery
  42479. */
  42480. occlusionRetryCount: number;
  42481. /**
  42482. * 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:
  42483. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42484. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42485. * * 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.
  42486. * @see http://doc.babylonjs.com/features/occlusionquery
  42487. */
  42488. occlusionType: number;
  42489. /**
  42490. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42491. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42492. * * 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.
  42493. * @see http://doc.babylonjs.com/features/occlusionquery
  42494. */
  42495. occlusionQueryAlgorithmType: number;
  42496. /**
  42497. * 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
  42498. * @see http://doc.babylonjs.com/features/occlusionquery
  42499. */
  42500. isOccluded: boolean;
  42501. /**
  42502. * Flag to check the progress status of the query
  42503. * @see http://doc.babylonjs.com/features/occlusionquery
  42504. */
  42505. isOcclusionQueryInProgress: boolean;
  42506. }
  42507. }
  42508. }
  42509. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42510. import { Nullable } from "babylonjs/types";
  42511. /** @hidden */
  42512. export var _forceTransformFeedbackToBundle: boolean;
  42513. module "babylonjs/Engines/engine" {
  42514. interface Engine {
  42515. /**
  42516. * Creates a webGL transform feedback object
  42517. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42518. * @returns the webGL transform feedback object
  42519. */
  42520. createTransformFeedback(): WebGLTransformFeedback;
  42521. /**
  42522. * Delete a webGL transform feedback object
  42523. * @param value defines the webGL transform feedback object to delete
  42524. */
  42525. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42526. /**
  42527. * Bind a webGL transform feedback object to the webgl context
  42528. * @param value defines the webGL transform feedback object to bind
  42529. */
  42530. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42531. /**
  42532. * Begins a transform feedback operation
  42533. * @param usePoints defines if points or triangles must be used
  42534. */
  42535. beginTransformFeedback(usePoints: boolean): void;
  42536. /**
  42537. * Ends a transform feedback operation
  42538. */
  42539. endTransformFeedback(): void;
  42540. /**
  42541. * Specify the varyings to use with transform feedback
  42542. * @param program defines the associated webGL program
  42543. * @param value defines the list of strings representing the varying names
  42544. */
  42545. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42546. /**
  42547. * Bind a webGL buffer for a transform feedback operation
  42548. * @param value defines the webGL buffer to bind
  42549. */
  42550. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42551. }
  42552. }
  42553. }
  42554. declare module "babylonjs/Engines/Extensions/index" {
  42555. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42556. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42557. }
  42558. declare module "babylonjs/Engines/index" {
  42559. export * from "babylonjs/Engines/constants";
  42560. export * from "babylonjs/Engines/engine";
  42561. export * from "babylonjs/Engines/engineStore";
  42562. export * from "babylonjs/Engines/nullEngine";
  42563. export * from "babylonjs/Engines/Extensions/index";
  42564. }
  42565. declare module "babylonjs/Events/clipboardEvents" {
  42566. /**
  42567. * Gather the list of clipboard event types as constants.
  42568. */
  42569. export class ClipboardEventTypes {
  42570. /**
  42571. * The clipboard event is fired when a copy command is active (pressed).
  42572. */
  42573. static readonly COPY: number;
  42574. /**
  42575. * The clipboard event is fired when a cut command is active (pressed).
  42576. */
  42577. static readonly CUT: number;
  42578. /**
  42579. * The clipboard event is fired when a paste command is active (pressed).
  42580. */
  42581. static readonly PASTE: number;
  42582. }
  42583. /**
  42584. * This class is used to store clipboard related info for the onClipboardObservable event.
  42585. */
  42586. export class ClipboardInfo {
  42587. /**
  42588. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42589. */
  42590. type: number;
  42591. /**
  42592. * Defines the related dom event
  42593. */
  42594. event: ClipboardEvent;
  42595. /**
  42596. *Creates an instance of ClipboardInfo.
  42597. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42598. * @param event Defines the related dom event
  42599. */
  42600. constructor(
  42601. /**
  42602. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42603. */
  42604. type: number,
  42605. /**
  42606. * Defines the related dom event
  42607. */
  42608. event: ClipboardEvent);
  42609. /**
  42610. * Get the clipboard event's type from the keycode.
  42611. * @param keyCode Defines the keyCode for the current keyboard event.
  42612. * @return {number}
  42613. */
  42614. static GetTypeFromCharacter(keyCode: number): number;
  42615. }
  42616. }
  42617. declare module "babylonjs/Events/index" {
  42618. export * from "babylonjs/Events/keyboardEvents";
  42619. export * from "babylonjs/Events/pointerEvents";
  42620. export * from "babylonjs/Events/clipboardEvents";
  42621. }
  42622. declare module "babylonjs/Loading/sceneLoader" {
  42623. import { Observable } from "babylonjs/Misc/observable";
  42624. import { Nullable } from "babylonjs/types";
  42625. import { Scene } from "babylonjs/scene";
  42626. import { Engine } from "babylonjs/Engines/engine";
  42627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42628. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42629. import { AssetContainer } from "babylonjs/assetContainer";
  42630. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42631. import { Skeleton } from "babylonjs/Bones/skeleton";
  42632. /**
  42633. * Class used to represent data loading progression
  42634. */
  42635. export class SceneLoaderProgressEvent {
  42636. /** defines if data length to load can be evaluated */
  42637. readonly lengthComputable: boolean;
  42638. /** defines the loaded data length */
  42639. readonly loaded: number;
  42640. /** defines the data length to load */
  42641. readonly total: number;
  42642. /**
  42643. * Create a new progress event
  42644. * @param lengthComputable defines if data length to load can be evaluated
  42645. * @param loaded defines the loaded data length
  42646. * @param total defines the data length to load
  42647. */
  42648. constructor(
  42649. /** defines if data length to load can be evaluated */
  42650. lengthComputable: boolean,
  42651. /** defines the loaded data length */
  42652. loaded: number,
  42653. /** defines the data length to load */
  42654. total: number);
  42655. /**
  42656. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42657. * @param event defines the source event
  42658. * @returns a new SceneLoaderProgressEvent
  42659. */
  42660. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42661. }
  42662. /**
  42663. * Interface used by SceneLoader plugins to define supported file extensions
  42664. */
  42665. export interface ISceneLoaderPluginExtensions {
  42666. /**
  42667. * Defines the list of supported extensions
  42668. */
  42669. [extension: string]: {
  42670. isBinary: boolean;
  42671. };
  42672. }
  42673. /**
  42674. * Interface used by SceneLoader plugin factory
  42675. */
  42676. export interface ISceneLoaderPluginFactory {
  42677. /**
  42678. * Defines the name of the factory
  42679. */
  42680. name: string;
  42681. /**
  42682. * Function called to create a new plugin
  42683. * @return the new plugin
  42684. */
  42685. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42686. /**
  42687. * Boolean indicating if the plugin can direct load specific data
  42688. */
  42689. canDirectLoad?: (data: string) => boolean;
  42690. }
  42691. /**
  42692. * Interface used to define a SceneLoader plugin
  42693. */
  42694. export interface ISceneLoaderPlugin {
  42695. /**
  42696. * The friendly name of this plugin.
  42697. */
  42698. name: string;
  42699. /**
  42700. * The file extensions supported by this plugin.
  42701. */
  42702. extensions: string | ISceneLoaderPluginExtensions;
  42703. /**
  42704. * Import meshes into a scene.
  42705. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42706. * @param scene The scene to import into
  42707. * @param data The data to import
  42708. * @param rootUrl The root url for scene and resources
  42709. * @param meshes The meshes array to import into
  42710. * @param particleSystems The particle systems array to import into
  42711. * @param skeletons The skeletons array to import into
  42712. * @param onError The callback when import fails
  42713. * @returns True if successful or false otherwise
  42714. */
  42715. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42716. /**
  42717. * Load into a scene.
  42718. * @param scene The scene to load into
  42719. * @param data The data to import
  42720. * @param rootUrl The root url for scene and resources
  42721. * @param onError The callback when import fails
  42722. * @returns true if successful or false otherwise
  42723. */
  42724. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42725. /**
  42726. * The callback that returns true if the data can be directly loaded.
  42727. */
  42728. canDirectLoad?: (data: string) => boolean;
  42729. /**
  42730. * The callback that allows custom handling of the root url based on the response url.
  42731. */
  42732. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42733. /**
  42734. * Load into an asset container.
  42735. * @param scene The scene to load into
  42736. * @param data The data to import
  42737. * @param rootUrl The root url for scene and resources
  42738. * @param onError The callback when import fails
  42739. * @returns The loaded asset container
  42740. */
  42741. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42742. }
  42743. /**
  42744. * Interface used to define an async SceneLoader plugin
  42745. */
  42746. export interface ISceneLoaderPluginAsync {
  42747. /**
  42748. * The friendly name of this plugin.
  42749. */
  42750. name: string;
  42751. /**
  42752. * The file extensions supported by this plugin.
  42753. */
  42754. extensions: string | ISceneLoaderPluginExtensions;
  42755. /**
  42756. * Import meshes into a scene.
  42757. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42758. * @param scene The scene to import into
  42759. * @param data The data to import
  42760. * @param rootUrl The root url for scene and resources
  42761. * @param onProgress The callback when the load progresses
  42762. * @param fileName Defines the name of the file to load
  42763. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42764. */
  42765. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42766. meshes: AbstractMesh[];
  42767. particleSystems: IParticleSystem[];
  42768. skeletons: Skeleton[];
  42769. animationGroups: AnimationGroup[];
  42770. }>;
  42771. /**
  42772. * Load into a scene.
  42773. * @param scene The scene to load into
  42774. * @param data The data to import
  42775. * @param rootUrl The root url for scene and resources
  42776. * @param onProgress The callback when the load progresses
  42777. * @param fileName Defines the name of the file to load
  42778. * @returns Nothing
  42779. */
  42780. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42781. /**
  42782. * The callback that returns true if the data can be directly loaded.
  42783. */
  42784. canDirectLoad?: (data: string) => boolean;
  42785. /**
  42786. * The callback that allows custom handling of the root url based on the response url.
  42787. */
  42788. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42789. /**
  42790. * Load into an asset container.
  42791. * @param scene The scene to load into
  42792. * @param data The data to import
  42793. * @param rootUrl The root url for scene and resources
  42794. * @param onProgress The callback when the load progresses
  42795. * @param fileName Defines the name of the file to load
  42796. * @returns The loaded asset container
  42797. */
  42798. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42799. }
  42800. /**
  42801. * Class used to load scene from various file formats using registered plugins
  42802. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42803. */
  42804. export class SceneLoader {
  42805. /**
  42806. * No logging while loading
  42807. */
  42808. static readonly NO_LOGGING: number;
  42809. /**
  42810. * Minimal logging while loading
  42811. */
  42812. static readonly MINIMAL_LOGGING: number;
  42813. /**
  42814. * Summary logging while loading
  42815. */
  42816. static readonly SUMMARY_LOGGING: number;
  42817. /**
  42818. * Detailled logging while loading
  42819. */
  42820. static readonly DETAILED_LOGGING: number;
  42821. /**
  42822. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42823. */
  42824. static ForceFullSceneLoadingForIncremental: boolean;
  42825. /**
  42826. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42827. */
  42828. static ShowLoadingScreen: boolean;
  42829. /**
  42830. * Defines the current logging level (while loading the scene)
  42831. * @ignorenaming
  42832. */
  42833. static loggingLevel: number;
  42834. /**
  42835. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42836. */
  42837. static CleanBoneMatrixWeights: boolean;
  42838. /**
  42839. * Event raised when a plugin is used to load a scene
  42840. */
  42841. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42842. private static _registeredPlugins;
  42843. private static _getDefaultPlugin;
  42844. private static _getPluginForExtension;
  42845. private static _getPluginForDirectLoad;
  42846. private static _getPluginForFilename;
  42847. private static _getDirectLoad;
  42848. private static _loadData;
  42849. private static _getFileInfo;
  42850. /**
  42851. * Gets a plugin that can load the given extension
  42852. * @param extension defines the extension to load
  42853. * @returns a plugin or null if none works
  42854. */
  42855. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42856. /**
  42857. * Gets a boolean indicating that the given extension can be loaded
  42858. * @param extension defines the extension to load
  42859. * @returns true if the extension is supported
  42860. */
  42861. static IsPluginForExtensionAvailable(extension: string): boolean;
  42862. /**
  42863. * Adds a new plugin to the list of registered plugins
  42864. * @param plugin defines the plugin to add
  42865. */
  42866. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42867. /**
  42868. * Import meshes into a scene
  42869. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42870. * @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)
  42871. * @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)
  42872. * @param scene the instance of BABYLON.Scene to append to
  42873. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42874. * @param onProgress a callback with a progress event for each file being loaded
  42875. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42876. * @param pluginExtension the extension used to determine the plugin
  42877. * @returns The loaded plugin
  42878. */
  42879. 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>;
  42880. /**
  42881. * Import meshes into a scene
  42882. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42883. * @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)
  42884. * @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)
  42885. * @param scene the instance of BABYLON.Scene to append to
  42886. * @param onProgress a callback with a progress event for each file being loaded
  42887. * @param pluginExtension the extension used to determine the plugin
  42888. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42889. */
  42890. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42891. meshes: AbstractMesh[];
  42892. particleSystems: IParticleSystem[];
  42893. skeletons: Skeleton[];
  42894. animationGroups: AnimationGroup[];
  42895. }>;
  42896. /**
  42897. * Load a scene
  42898. * @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)
  42899. * @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)
  42900. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42901. * @param onSuccess a callback with the scene when import succeeds
  42902. * @param onProgress a callback with a progress event for each file being loaded
  42903. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42904. * @param pluginExtension the extension used to determine the plugin
  42905. * @returns The loaded plugin
  42906. */
  42907. 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>;
  42908. /**
  42909. * Load a scene
  42910. * @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)
  42911. * @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)
  42912. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42913. * @param onProgress a callback with a progress event for each file being loaded
  42914. * @param pluginExtension the extension used to determine the plugin
  42915. * @returns The loaded scene
  42916. */
  42917. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42918. /**
  42919. * Append a scene
  42920. * @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)
  42921. * @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)
  42922. * @param scene is the instance of BABYLON.Scene to append to
  42923. * @param onSuccess a callback with the scene when import succeeds
  42924. * @param onProgress a callback with a progress event for each file being loaded
  42925. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42926. * @param pluginExtension the extension used to determine the plugin
  42927. * @returns The loaded plugin
  42928. */
  42929. 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>;
  42930. /**
  42931. * Append a scene
  42932. * @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)
  42933. * @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)
  42934. * @param scene is the instance of BABYLON.Scene to append to
  42935. * @param onProgress a callback with a progress event for each file being loaded
  42936. * @param pluginExtension the extension used to determine the plugin
  42937. * @returns The given scene
  42938. */
  42939. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42940. /**
  42941. * Load a scene into an asset container
  42942. * @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)
  42943. * @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)
  42944. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42945. * @param onSuccess a callback with the scene when import succeeds
  42946. * @param onProgress a callback with a progress event for each file being loaded
  42947. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42948. * @param pluginExtension the extension used to determine the plugin
  42949. * @returns The loaded plugin
  42950. */
  42951. 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>;
  42952. /**
  42953. * Load a scene into an asset container
  42954. * @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)
  42955. * @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)
  42956. * @param scene is the instance of Scene to append to
  42957. * @param onProgress a callback with a progress event for each file being loaded
  42958. * @param pluginExtension the extension used to determine the plugin
  42959. * @returns The loaded asset container
  42960. */
  42961. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42962. }
  42963. }
  42964. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42965. import { Scene } from "babylonjs/scene";
  42966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42967. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42968. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42969. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42970. /**
  42971. * Google Daydream controller
  42972. */
  42973. export class DaydreamController extends WebVRController {
  42974. /**
  42975. * Base Url for the controller model.
  42976. */
  42977. static MODEL_BASE_URL: string;
  42978. /**
  42979. * File name for the controller model.
  42980. */
  42981. static MODEL_FILENAME: string;
  42982. /**
  42983. * Gamepad Id prefix used to identify Daydream Controller.
  42984. */
  42985. static readonly GAMEPAD_ID_PREFIX: string;
  42986. /**
  42987. * Creates a new DaydreamController from a gamepad
  42988. * @param vrGamepad the gamepad that the controller should be created from
  42989. */
  42990. constructor(vrGamepad: any);
  42991. /**
  42992. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42993. * @param scene scene in which to add meshes
  42994. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42995. */
  42996. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42997. /**
  42998. * Called once for each button that changed state since the last frame
  42999. * @param buttonIdx Which button index changed
  43000. * @param state New state of the button
  43001. * @param changes Which properties on the state changed since last frame
  43002. */
  43003. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43004. }
  43005. }
  43006. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43007. import { Scene } from "babylonjs/scene";
  43008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43009. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43010. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43011. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43012. /**
  43013. * Gear VR Controller
  43014. */
  43015. export class GearVRController extends WebVRController {
  43016. /**
  43017. * Base Url for the controller model.
  43018. */
  43019. static MODEL_BASE_URL: string;
  43020. /**
  43021. * File name for the controller model.
  43022. */
  43023. static MODEL_FILENAME: string;
  43024. /**
  43025. * Gamepad Id prefix used to identify this controller.
  43026. */
  43027. static readonly GAMEPAD_ID_PREFIX: string;
  43028. private readonly _buttonIndexToObservableNameMap;
  43029. /**
  43030. * Creates a new GearVRController from a gamepad
  43031. * @param vrGamepad the gamepad that the controller should be created from
  43032. */
  43033. constructor(vrGamepad: any);
  43034. /**
  43035. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43036. * @param scene scene in which to add meshes
  43037. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43038. */
  43039. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43040. /**
  43041. * Called once for each button that changed state since the last frame
  43042. * @param buttonIdx Which button index changed
  43043. * @param state New state of the button
  43044. * @param changes Which properties on the state changed since last frame
  43045. */
  43046. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43047. }
  43048. }
  43049. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43050. import { Scene } from "babylonjs/scene";
  43051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43052. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43053. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43054. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43055. /**
  43056. * Generic Controller
  43057. */
  43058. export class GenericController extends WebVRController {
  43059. /**
  43060. * Base Url for the controller model.
  43061. */
  43062. static readonly MODEL_BASE_URL: string;
  43063. /**
  43064. * File name for the controller model.
  43065. */
  43066. static readonly MODEL_FILENAME: string;
  43067. /**
  43068. * Creates a new GenericController from a gamepad
  43069. * @param vrGamepad the gamepad that the controller should be created from
  43070. */
  43071. constructor(vrGamepad: any);
  43072. /**
  43073. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43074. * @param scene scene in which to add meshes
  43075. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43076. */
  43077. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43078. /**
  43079. * Called once for each button that changed state since the last frame
  43080. * @param buttonIdx Which button index changed
  43081. * @param state New state of the button
  43082. * @param changes Which properties on the state changed since last frame
  43083. */
  43084. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43085. }
  43086. }
  43087. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43088. import { Observable } from "babylonjs/Misc/observable";
  43089. import { Scene } from "babylonjs/scene";
  43090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43091. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43092. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43093. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43094. /**
  43095. * Oculus Touch Controller
  43096. */
  43097. export class OculusTouchController extends WebVRController {
  43098. /**
  43099. * Base Url for the controller model.
  43100. */
  43101. static MODEL_BASE_URL: string;
  43102. /**
  43103. * File name for the left controller model.
  43104. */
  43105. static MODEL_LEFT_FILENAME: string;
  43106. /**
  43107. * File name for the right controller model.
  43108. */
  43109. static MODEL_RIGHT_FILENAME: string;
  43110. /**
  43111. * Fired when the secondary trigger on this controller is modified
  43112. */
  43113. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43114. /**
  43115. * Fired when the thumb rest on this controller is modified
  43116. */
  43117. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43118. /**
  43119. * Creates a new OculusTouchController from a gamepad
  43120. * @param vrGamepad the gamepad that the controller should be created from
  43121. */
  43122. constructor(vrGamepad: any);
  43123. /**
  43124. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43125. * @param scene scene in which to add meshes
  43126. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43127. */
  43128. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43129. /**
  43130. * Fired when the A button on this controller is modified
  43131. */
  43132. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43133. /**
  43134. * Fired when the B button on this controller is modified
  43135. */
  43136. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43137. /**
  43138. * Fired when the X button on this controller is modified
  43139. */
  43140. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43141. /**
  43142. * Fired when the Y button on this controller is modified
  43143. */
  43144. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43145. /**
  43146. * Called once for each button that changed state since the last frame
  43147. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43148. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43149. * 2) secondary trigger (same)
  43150. * 3) A (right) X (left), touch, pressed = value
  43151. * 4) B / Y
  43152. * 5) thumb rest
  43153. * @param buttonIdx Which button index changed
  43154. * @param state New state of the button
  43155. * @param changes Which properties on the state changed since last frame
  43156. */
  43157. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43158. }
  43159. }
  43160. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43161. import { Scene } from "babylonjs/scene";
  43162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43163. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43164. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43165. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43166. import { Observable } from "babylonjs/Misc/observable";
  43167. /**
  43168. * Vive Controller
  43169. */
  43170. export class ViveController extends WebVRController {
  43171. /**
  43172. * Base Url for the controller model.
  43173. */
  43174. static MODEL_BASE_URL: string;
  43175. /**
  43176. * File name for the controller model.
  43177. */
  43178. static MODEL_FILENAME: string;
  43179. /**
  43180. * Creates a new ViveController from a gamepad
  43181. * @param vrGamepad the gamepad that the controller should be created from
  43182. */
  43183. constructor(vrGamepad: any);
  43184. /**
  43185. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43186. * @param scene scene in which to add meshes
  43187. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43188. */
  43189. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43190. /**
  43191. * Fired when the left button on this controller is modified
  43192. */
  43193. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43194. /**
  43195. * Fired when the right button on this controller is modified
  43196. */
  43197. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43198. /**
  43199. * Fired when the menu button on this controller is modified
  43200. */
  43201. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43202. /**
  43203. * Called once for each button that changed state since the last frame
  43204. * Vive mapping:
  43205. * 0: touchpad
  43206. * 1: trigger
  43207. * 2: left AND right buttons
  43208. * 3: menu button
  43209. * @param buttonIdx Which button index changed
  43210. * @param state New state of the button
  43211. * @param changes Which properties on the state changed since last frame
  43212. */
  43213. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43214. }
  43215. }
  43216. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43217. import { Observable } from "babylonjs/Misc/observable";
  43218. import { Scene } from "babylonjs/scene";
  43219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43220. import { Ray } from "babylonjs/Culling/ray";
  43221. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43222. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43223. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43224. /**
  43225. * Defines the WindowsMotionController object that the state of the windows motion controller
  43226. */
  43227. export class WindowsMotionController extends WebVRController {
  43228. /**
  43229. * The base url used to load the left and right controller models
  43230. */
  43231. static MODEL_BASE_URL: string;
  43232. /**
  43233. * The name of the left controller model file
  43234. */
  43235. static MODEL_LEFT_FILENAME: string;
  43236. /**
  43237. * The name of the right controller model file
  43238. */
  43239. static MODEL_RIGHT_FILENAME: string;
  43240. /**
  43241. * The controller name prefix for this controller type
  43242. */
  43243. static readonly GAMEPAD_ID_PREFIX: string;
  43244. /**
  43245. * The controller id pattern for this controller type
  43246. */
  43247. private static readonly GAMEPAD_ID_PATTERN;
  43248. private _loadedMeshInfo;
  43249. private readonly _mapping;
  43250. /**
  43251. * Fired when the trackpad on this controller is clicked
  43252. */
  43253. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43254. /**
  43255. * Fired when the trackpad on this controller is modified
  43256. */
  43257. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43258. /**
  43259. * The current x and y values of this controller's trackpad
  43260. */
  43261. trackpad: StickValues;
  43262. /**
  43263. * Creates a new WindowsMotionController from a gamepad
  43264. * @param vrGamepad the gamepad that the controller should be created from
  43265. */
  43266. constructor(vrGamepad: any);
  43267. /**
  43268. * Fired when the trigger on this controller is modified
  43269. */
  43270. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43271. /**
  43272. * Fired when the menu button on this controller is modified
  43273. */
  43274. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43275. /**
  43276. * Fired when the grip button on this controller is modified
  43277. */
  43278. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43279. /**
  43280. * Fired when the thumbstick button on this controller is modified
  43281. */
  43282. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43283. /**
  43284. * Fired when the touchpad button on this controller is modified
  43285. */
  43286. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43287. /**
  43288. * Fired when the touchpad values on this controller are modified
  43289. */
  43290. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43291. private _updateTrackpad;
  43292. /**
  43293. * Called once per frame by the engine.
  43294. */
  43295. update(): void;
  43296. /**
  43297. * Called once for each button that changed state since the last frame
  43298. * @param buttonIdx Which button index changed
  43299. * @param state New state of the button
  43300. * @param changes Which properties on the state changed since last frame
  43301. */
  43302. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43303. /**
  43304. * Moves the buttons on the controller mesh based on their current state
  43305. * @param buttonName the name of the button to move
  43306. * @param buttonValue the value of the button which determines the buttons new position
  43307. */
  43308. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43309. /**
  43310. * Moves the axis on the controller mesh based on its current state
  43311. * @param axis the index of the axis
  43312. * @param axisValue the value of the axis which determines the meshes new position
  43313. * @hidden
  43314. */
  43315. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43316. /**
  43317. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43318. * @param scene scene in which to add meshes
  43319. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43320. */
  43321. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43322. /**
  43323. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43324. * can be transformed by button presses and axes values, based on this._mapping.
  43325. *
  43326. * @param scene scene in which the meshes exist
  43327. * @param meshes list of meshes that make up the controller model to process
  43328. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43329. */
  43330. private processModel;
  43331. private createMeshInfo;
  43332. /**
  43333. * Gets the ray of the controller in the direction the controller is pointing
  43334. * @param length the length the resulting ray should be
  43335. * @returns a ray in the direction the controller is pointing
  43336. */
  43337. getForwardRay(length?: number): Ray;
  43338. /**
  43339. * Disposes of the controller
  43340. */
  43341. dispose(): void;
  43342. }
  43343. }
  43344. declare module "babylonjs/Gamepads/Controllers/index" {
  43345. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43346. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43347. export * from "babylonjs/Gamepads/Controllers/genericController";
  43348. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43349. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43350. export * from "babylonjs/Gamepads/Controllers/viveController";
  43351. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43352. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43353. }
  43354. declare module "babylonjs/Gamepads/index" {
  43355. export * from "babylonjs/Gamepads/Controllers/index";
  43356. export * from "babylonjs/Gamepads/gamepad";
  43357. export * from "babylonjs/Gamepads/gamepadManager";
  43358. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43359. export * from "babylonjs/Gamepads/xboxGamepad";
  43360. }
  43361. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43362. import { Observable } from "babylonjs/Misc/observable";
  43363. import { Nullable } from "babylonjs/types";
  43364. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43366. import { Mesh } from "babylonjs/Meshes/mesh";
  43367. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43368. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43369. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43370. /**
  43371. * Single axis scale gizmo
  43372. */
  43373. export class AxisScaleGizmo extends Gizmo {
  43374. private _coloredMaterial;
  43375. /**
  43376. * Drag behavior responsible for the gizmos dragging interactions
  43377. */
  43378. dragBehavior: PointerDragBehavior;
  43379. private _pointerObserver;
  43380. /**
  43381. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43382. */
  43383. snapDistance: number;
  43384. /**
  43385. * Event that fires each time the gizmo snaps to a new location.
  43386. * * snapDistance is the the change in distance
  43387. */
  43388. onSnapObservable: Observable<{
  43389. snapDistance: number;
  43390. }>;
  43391. /**
  43392. * If the scaling operation should be done on all axis (default: false)
  43393. */
  43394. uniformScaling: boolean;
  43395. /**
  43396. * Creates an AxisScaleGizmo
  43397. * @param gizmoLayer The utility layer the gizmo will be added to
  43398. * @param dragAxis The axis which the gizmo will be able to scale on
  43399. * @param color The color of the gizmo
  43400. */
  43401. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43402. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43403. /**
  43404. * Disposes of the gizmo
  43405. */
  43406. dispose(): void;
  43407. /**
  43408. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43409. * @param mesh The mesh to replace the default mesh of the gizmo
  43410. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43411. */
  43412. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43413. }
  43414. }
  43415. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43416. import { Observable } from "babylonjs/Misc/observable";
  43417. import { Nullable } from "babylonjs/types";
  43418. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43420. import { Mesh } from "babylonjs/Meshes/mesh";
  43421. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43422. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43423. import "babylonjs/Meshes/Builders/boxBuilder";
  43424. /**
  43425. * Bounding box gizmo
  43426. */
  43427. export class BoundingBoxGizmo extends Gizmo {
  43428. private _lineBoundingBox;
  43429. private _rotateSpheresParent;
  43430. private _scaleBoxesParent;
  43431. private _boundingDimensions;
  43432. private _renderObserver;
  43433. private _pointerObserver;
  43434. private _scaleDragSpeed;
  43435. private _tmpQuaternion;
  43436. private _tmpVector;
  43437. private _tmpRotationMatrix;
  43438. /**
  43439. * 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)
  43440. */
  43441. ignoreChildren: boolean;
  43442. /**
  43443. * 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)
  43444. */
  43445. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43446. /**
  43447. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43448. */
  43449. rotationSphereSize: number;
  43450. /**
  43451. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43452. */
  43453. scaleBoxSize: number;
  43454. /**
  43455. * 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)
  43456. */
  43457. fixedDragMeshScreenSize: boolean;
  43458. /**
  43459. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43460. */
  43461. fixedDragMeshScreenSizeDistanceFactor: number;
  43462. /**
  43463. * Fired when a rotation sphere or scale box is dragged
  43464. */
  43465. onDragStartObservable: Observable<{}>;
  43466. /**
  43467. * Fired when a scale box is dragged
  43468. */
  43469. onScaleBoxDragObservable: Observable<{}>;
  43470. /**
  43471. * Fired when a scale box drag is ended
  43472. */
  43473. onScaleBoxDragEndObservable: Observable<{}>;
  43474. /**
  43475. * Fired when a rotation sphere is dragged
  43476. */
  43477. onRotationSphereDragObservable: Observable<{}>;
  43478. /**
  43479. * Fired when a rotation sphere drag is ended
  43480. */
  43481. onRotationSphereDragEndObservable: Observable<{}>;
  43482. /**
  43483. * 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)
  43484. */
  43485. scalePivot: Nullable<Vector3>;
  43486. private _anchorMesh;
  43487. private _existingMeshScale;
  43488. private _dragMesh;
  43489. private pointerDragBehavior;
  43490. private coloredMaterial;
  43491. private hoverColoredMaterial;
  43492. /**
  43493. * Sets the color of the bounding box gizmo
  43494. * @param color the color to set
  43495. */
  43496. setColor(color: Color3): void;
  43497. /**
  43498. * Creates an BoundingBoxGizmo
  43499. * @param gizmoLayer The utility layer the gizmo will be added to
  43500. * @param color The color of the gizmo
  43501. */
  43502. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43503. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43504. private _selectNode;
  43505. /**
  43506. * Updates the bounding box information for the Gizmo
  43507. */
  43508. updateBoundingBox(): void;
  43509. private _updateRotationSpheres;
  43510. private _updateScaleBoxes;
  43511. /**
  43512. * Enables rotation on the specified axis and disables rotation on the others
  43513. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43514. */
  43515. setEnabledRotationAxis(axis: string): void;
  43516. /**
  43517. * Enables/disables scaling
  43518. * @param enable if scaling should be enabled
  43519. */
  43520. setEnabledScaling(enable: boolean): void;
  43521. private _updateDummy;
  43522. /**
  43523. * Enables a pointer drag behavior on the bounding box of the gizmo
  43524. */
  43525. enableDragBehavior(): void;
  43526. /**
  43527. * Disposes of the gizmo
  43528. */
  43529. dispose(): void;
  43530. /**
  43531. * 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)
  43532. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43533. * @returns the bounding box mesh with the passed in mesh as a child
  43534. */
  43535. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43536. /**
  43537. * CustomMeshes are not supported by this gizmo
  43538. * @param mesh The mesh to replace the default mesh of the gizmo
  43539. */
  43540. setCustomMesh(mesh: Mesh): void;
  43541. }
  43542. }
  43543. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43544. import { Observable } from "babylonjs/Misc/observable";
  43545. import { Nullable } from "babylonjs/types";
  43546. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43548. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43549. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43550. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43551. import "babylonjs/Meshes/Builders/linesBuilder";
  43552. /**
  43553. * Single plane rotation gizmo
  43554. */
  43555. export class PlaneRotationGizmo extends Gizmo {
  43556. /**
  43557. * Drag behavior responsible for the gizmos dragging interactions
  43558. */
  43559. dragBehavior: PointerDragBehavior;
  43560. private _pointerObserver;
  43561. /**
  43562. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43563. */
  43564. snapDistance: number;
  43565. /**
  43566. * Event that fires each time the gizmo snaps to a new location.
  43567. * * snapDistance is the the change in distance
  43568. */
  43569. onSnapObservable: Observable<{
  43570. snapDistance: number;
  43571. }>;
  43572. /**
  43573. * Creates a PlaneRotationGizmo
  43574. * @param gizmoLayer The utility layer the gizmo will be added to
  43575. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43576. * @param color The color of the gizmo
  43577. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43578. */
  43579. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43580. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43581. /**
  43582. * Disposes of the gizmo
  43583. */
  43584. dispose(): void;
  43585. }
  43586. }
  43587. declare module "babylonjs/Gizmos/rotationGizmo" {
  43588. import { Observable } from "babylonjs/Misc/observable";
  43589. import { Nullable } from "babylonjs/types";
  43590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43591. import { Mesh } from "babylonjs/Meshes/mesh";
  43592. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43593. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43594. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43595. /**
  43596. * Gizmo that enables rotating a mesh along 3 axis
  43597. */
  43598. export class RotationGizmo extends Gizmo {
  43599. /**
  43600. * Internal gizmo used for interactions on the x axis
  43601. */
  43602. xGizmo: PlaneRotationGizmo;
  43603. /**
  43604. * Internal gizmo used for interactions on the y axis
  43605. */
  43606. yGizmo: PlaneRotationGizmo;
  43607. /**
  43608. * Internal gizmo used for interactions on the z axis
  43609. */
  43610. zGizmo: PlaneRotationGizmo;
  43611. /** Fires an event when any of it's sub gizmos are dragged */
  43612. onDragStartObservable: Observable<{}>;
  43613. /** Fires an event when any of it's sub gizmos are released from dragging */
  43614. onDragEndObservable: Observable<{}>;
  43615. attachedMesh: Nullable<AbstractMesh>;
  43616. /**
  43617. * Creates a RotationGizmo
  43618. * @param gizmoLayer The utility layer the gizmo will be added to
  43619. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43620. */
  43621. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43622. updateGizmoRotationToMatchAttachedMesh: boolean;
  43623. /**
  43624. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43625. */
  43626. snapDistance: number;
  43627. /**
  43628. * Ratio for the scale of the gizmo (Default: 1)
  43629. */
  43630. scaleRatio: number;
  43631. /**
  43632. * Disposes of the gizmo
  43633. */
  43634. dispose(): void;
  43635. /**
  43636. * CustomMeshes are not supported by this gizmo
  43637. * @param mesh The mesh to replace the default mesh of the gizmo
  43638. */
  43639. setCustomMesh(mesh: Mesh): void;
  43640. }
  43641. }
  43642. declare module "babylonjs/Gizmos/positionGizmo" {
  43643. import { Observable } from "babylonjs/Misc/observable";
  43644. import { Nullable } from "babylonjs/types";
  43645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43646. import { Mesh } from "babylonjs/Meshes/mesh";
  43647. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43648. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43649. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43650. /**
  43651. * Gizmo that enables dragging a mesh along 3 axis
  43652. */
  43653. export class PositionGizmo extends Gizmo {
  43654. /**
  43655. * Internal gizmo used for interactions on the x axis
  43656. */
  43657. xGizmo: AxisDragGizmo;
  43658. /**
  43659. * Internal gizmo used for interactions on the y axis
  43660. */
  43661. yGizmo: AxisDragGizmo;
  43662. /**
  43663. * Internal gizmo used for interactions on the z axis
  43664. */
  43665. zGizmo: AxisDragGizmo;
  43666. /** Fires an event when any of it's sub gizmos are dragged */
  43667. onDragStartObservable: Observable<{}>;
  43668. /** Fires an event when any of it's sub gizmos are released from dragging */
  43669. onDragEndObservable: Observable<{}>;
  43670. attachedMesh: Nullable<AbstractMesh>;
  43671. /**
  43672. * Creates a PositionGizmo
  43673. * @param gizmoLayer The utility layer the gizmo will be added to
  43674. */
  43675. constructor(gizmoLayer?: UtilityLayerRenderer);
  43676. updateGizmoRotationToMatchAttachedMesh: boolean;
  43677. /**
  43678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43679. */
  43680. snapDistance: number;
  43681. /**
  43682. * Ratio for the scale of the gizmo (Default: 1)
  43683. */
  43684. scaleRatio: number;
  43685. /**
  43686. * Disposes of the gizmo
  43687. */
  43688. dispose(): void;
  43689. /**
  43690. * CustomMeshes are not supported by this gizmo
  43691. * @param mesh The mesh to replace the default mesh of the gizmo
  43692. */
  43693. setCustomMesh(mesh: Mesh): void;
  43694. }
  43695. }
  43696. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43697. import { Scene } from "babylonjs/scene";
  43698. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43699. import { Mesh } from "babylonjs/Meshes/mesh";
  43700. /**
  43701. * Class containing static functions to help procedurally build meshes
  43702. */
  43703. export class PolyhedronBuilder {
  43704. /**
  43705. * Creates a polyhedron mesh
  43706. * * 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
  43707. * * The parameter `size` (positive float, default 1) sets the polygon size
  43708. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43709. * * 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`
  43710. * * 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
  43711. * * 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)`)
  43712. * * 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
  43713. * * 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
  43714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43717. * @param name defines the name of the mesh
  43718. * @param options defines the options used to create the mesh
  43719. * @param scene defines the hosting scene
  43720. * @returns the polyhedron mesh
  43721. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43722. */
  43723. static CreatePolyhedron(name: string, options: {
  43724. type?: number;
  43725. size?: number;
  43726. sizeX?: number;
  43727. sizeY?: number;
  43728. sizeZ?: number;
  43729. custom?: any;
  43730. faceUV?: Vector4[];
  43731. faceColors?: Color4[];
  43732. flat?: boolean;
  43733. updatable?: boolean;
  43734. sideOrientation?: number;
  43735. frontUVs?: Vector4;
  43736. backUVs?: Vector4;
  43737. }, scene: Scene): Mesh;
  43738. }
  43739. }
  43740. declare module "babylonjs/Gizmos/scaleGizmo" {
  43741. import { Observable } from "babylonjs/Misc/observable";
  43742. import { Nullable } from "babylonjs/types";
  43743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43744. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43745. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43746. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43747. /**
  43748. * Gizmo that enables scaling a mesh along 3 axis
  43749. */
  43750. export class ScaleGizmo extends Gizmo {
  43751. /**
  43752. * Internal gizmo used for interactions on the x axis
  43753. */
  43754. xGizmo: AxisScaleGizmo;
  43755. /**
  43756. * Internal gizmo used for interactions on the y axis
  43757. */
  43758. yGizmo: AxisScaleGizmo;
  43759. /**
  43760. * Internal gizmo used for interactions on the z axis
  43761. */
  43762. zGizmo: AxisScaleGizmo;
  43763. /**
  43764. * Internal gizmo used to scale all axis equally
  43765. */
  43766. uniformScaleGizmo: AxisScaleGizmo;
  43767. /** Fires an event when any of it's sub gizmos are dragged */
  43768. onDragStartObservable: Observable<{}>;
  43769. /** Fires an event when any of it's sub gizmos are released from dragging */
  43770. onDragEndObservable: Observable<{}>;
  43771. attachedMesh: Nullable<AbstractMesh>;
  43772. /**
  43773. * Creates a ScaleGizmo
  43774. * @param gizmoLayer The utility layer the gizmo will be added to
  43775. */
  43776. constructor(gizmoLayer?: UtilityLayerRenderer);
  43777. updateGizmoRotationToMatchAttachedMesh: boolean;
  43778. /**
  43779. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43780. */
  43781. snapDistance: number;
  43782. /**
  43783. * Ratio for the scale of the gizmo (Default: 1)
  43784. */
  43785. scaleRatio: number;
  43786. /**
  43787. * Disposes of the gizmo
  43788. */
  43789. dispose(): void;
  43790. }
  43791. }
  43792. declare module "babylonjs/Gizmos/gizmoManager" {
  43793. import { Observable } from "babylonjs/Misc/observable";
  43794. import { Nullable } from "babylonjs/types";
  43795. import { Scene, IDisposable } from "babylonjs/scene";
  43796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43797. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43798. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43799. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43800. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43801. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43802. /**
  43803. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43804. */
  43805. export class GizmoManager implements IDisposable {
  43806. private scene;
  43807. /**
  43808. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43809. */
  43810. gizmos: {
  43811. positionGizmo: Nullable<PositionGizmo>;
  43812. rotationGizmo: Nullable<RotationGizmo>;
  43813. scaleGizmo: Nullable<ScaleGizmo>;
  43814. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43815. };
  43816. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43817. clearGizmoOnEmptyPointerEvent: boolean;
  43818. /** Fires an event when the manager is attached to a mesh */
  43819. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43820. private _gizmosEnabled;
  43821. private _pointerObserver;
  43822. private _attachedMesh;
  43823. private _boundingBoxColor;
  43824. private _defaultUtilityLayer;
  43825. private _defaultKeepDepthUtilityLayer;
  43826. /**
  43827. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43828. */
  43829. boundingBoxDragBehavior: SixDofDragBehavior;
  43830. /**
  43831. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43832. */
  43833. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43834. /**
  43835. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43836. */
  43837. usePointerToAttachGizmos: boolean;
  43838. /**
  43839. * Instatiates a gizmo manager
  43840. * @param scene the scene to overlay the gizmos on top of
  43841. */
  43842. constructor(scene: Scene);
  43843. /**
  43844. * Attaches a set of gizmos to the specified mesh
  43845. * @param mesh The mesh the gizmo's should be attached to
  43846. */
  43847. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43848. /**
  43849. * If the position gizmo is enabled
  43850. */
  43851. positionGizmoEnabled: boolean;
  43852. /**
  43853. * If the rotation gizmo is enabled
  43854. */
  43855. rotationGizmoEnabled: boolean;
  43856. /**
  43857. * If the scale gizmo is enabled
  43858. */
  43859. scaleGizmoEnabled: boolean;
  43860. /**
  43861. * If the boundingBox gizmo is enabled
  43862. */
  43863. boundingBoxGizmoEnabled: boolean;
  43864. /**
  43865. * Disposes of the gizmo manager
  43866. */
  43867. dispose(): void;
  43868. }
  43869. }
  43870. declare module "babylonjs/Gizmos/lightGizmo" {
  43871. import { Nullable } from "babylonjs/types";
  43872. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43873. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43874. import { Light } from "babylonjs/Lights/light";
  43875. /**
  43876. * Gizmo that enables viewing a light
  43877. */
  43878. export class LightGizmo extends Gizmo {
  43879. private _box;
  43880. /**
  43881. * Creates a LightGizmo
  43882. * @param gizmoLayer The utility layer the gizmo will be added to
  43883. */
  43884. constructor(gizmoLayer?: UtilityLayerRenderer);
  43885. private _light;
  43886. /**
  43887. * The light that the gizmo is attached to
  43888. */
  43889. light: Nullable<Light>;
  43890. /**
  43891. * @hidden
  43892. * Updates the gizmo to match the attached mesh's position/rotation
  43893. */
  43894. protected _update(): void;
  43895. }
  43896. }
  43897. declare module "babylonjs/Gizmos/index" {
  43898. export * from "babylonjs/Gizmos/axisDragGizmo";
  43899. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43900. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43901. export * from "babylonjs/Gizmos/gizmo";
  43902. export * from "babylonjs/Gizmos/gizmoManager";
  43903. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43904. export * from "babylonjs/Gizmos/positionGizmo";
  43905. export * from "babylonjs/Gizmos/rotationGizmo";
  43906. export * from "babylonjs/Gizmos/scaleGizmo";
  43907. export * from "babylonjs/Gizmos/lightGizmo";
  43908. }
  43909. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43910. /** @hidden */
  43911. export var backgroundFragmentDeclaration: {
  43912. name: string;
  43913. shader: string;
  43914. };
  43915. }
  43916. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43917. /** @hidden */
  43918. export var backgroundUboDeclaration: {
  43919. name: string;
  43920. shader: string;
  43921. };
  43922. }
  43923. declare module "babylonjs/Shaders/background.fragment" {
  43924. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43925. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43926. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43927. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43928. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43929. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43930. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43931. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43932. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43933. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43934. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43935. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43936. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43937. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43938. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43939. /** @hidden */
  43940. export var backgroundPixelShader: {
  43941. name: string;
  43942. shader: string;
  43943. };
  43944. }
  43945. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43946. /** @hidden */
  43947. export var backgroundVertexDeclaration: {
  43948. name: string;
  43949. shader: string;
  43950. };
  43951. }
  43952. declare module "babylonjs/Shaders/background.vertex" {
  43953. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43954. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43955. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43956. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43957. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43958. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43959. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43960. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43961. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43962. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43963. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43964. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43965. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43966. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43967. /** @hidden */
  43968. export var backgroundVertexShader: {
  43969. name: string;
  43970. shader: string;
  43971. };
  43972. }
  43973. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43974. import { Nullable, int, float } from "babylonjs/types";
  43975. import { Scene } from "babylonjs/scene";
  43976. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43979. import { Mesh } from "babylonjs/Meshes/mesh";
  43980. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43981. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43982. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43983. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43984. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43985. import "babylonjs/Shaders/background.fragment";
  43986. import "babylonjs/Shaders/background.vertex";
  43987. /**
  43988. * Background material used to create an efficient environement around your scene.
  43989. */
  43990. export class BackgroundMaterial extends PushMaterial {
  43991. /**
  43992. * Standard reflectance value at parallel view angle.
  43993. */
  43994. static StandardReflectance0: number;
  43995. /**
  43996. * Standard reflectance value at grazing angle.
  43997. */
  43998. static StandardReflectance90: number;
  43999. protected _primaryColor: Color3;
  44000. /**
  44001. * Key light Color (multiply against the environement texture)
  44002. */
  44003. primaryColor: Color3;
  44004. protected __perceptualColor: Nullable<Color3>;
  44005. /**
  44006. * Experimental Internal Use Only.
  44007. *
  44008. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44009. * This acts as a helper to set the primary color to a more "human friendly" value.
  44010. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44011. * output color as close as possible from the chosen value.
  44012. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44013. * part of lighting setup.)
  44014. */
  44015. _perceptualColor: Nullable<Color3>;
  44016. protected _primaryColorShadowLevel: float;
  44017. /**
  44018. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44019. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44020. */
  44021. primaryColorShadowLevel: float;
  44022. protected _primaryColorHighlightLevel: float;
  44023. /**
  44024. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44025. * The primary color is used at the level chosen to define what the white area would look.
  44026. */
  44027. primaryColorHighlightLevel: float;
  44028. protected _reflectionTexture: Nullable<BaseTexture>;
  44029. /**
  44030. * Reflection Texture used in the material.
  44031. * Should be author in a specific way for the best result (refer to the documentation).
  44032. */
  44033. reflectionTexture: Nullable<BaseTexture>;
  44034. protected _reflectionBlur: float;
  44035. /**
  44036. * Reflection Texture level of blur.
  44037. *
  44038. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44039. * texture twice.
  44040. */
  44041. reflectionBlur: float;
  44042. protected _diffuseTexture: Nullable<BaseTexture>;
  44043. /**
  44044. * Diffuse Texture used in the material.
  44045. * Should be author in a specific way for the best result (refer to the documentation).
  44046. */
  44047. diffuseTexture: Nullable<BaseTexture>;
  44048. protected _shadowLights: Nullable<IShadowLight[]>;
  44049. /**
  44050. * Specify the list of lights casting shadow on the material.
  44051. * All scene shadow lights will be included if null.
  44052. */
  44053. shadowLights: Nullable<IShadowLight[]>;
  44054. protected _shadowLevel: float;
  44055. /**
  44056. * Helps adjusting the shadow to a softer level if required.
  44057. * 0 means black shadows and 1 means no shadows.
  44058. */
  44059. shadowLevel: float;
  44060. protected _sceneCenter: Vector3;
  44061. /**
  44062. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44063. * It is usually zero but might be interesting to modify according to your setup.
  44064. */
  44065. sceneCenter: Vector3;
  44066. protected _opacityFresnel: boolean;
  44067. /**
  44068. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44069. * This helps ensuring a nice transition when the camera goes under the ground.
  44070. */
  44071. opacityFresnel: boolean;
  44072. protected _reflectionFresnel: boolean;
  44073. /**
  44074. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44075. * This helps adding a mirror texture on the ground.
  44076. */
  44077. reflectionFresnel: boolean;
  44078. protected _reflectionFalloffDistance: number;
  44079. /**
  44080. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44081. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44082. */
  44083. reflectionFalloffDistance: number;
  44084. protected _reflectionAmount: number;
  44085. /**
  44086. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44087. */
  44088. reflectionAmount: number;
  44089. protected _reflectionReflectance0: number;
  44090. /**
  44091. * This specifies the weight of the reflection at grazing angle.
  44092. */
  44093. reflectionReflectance0: number;
  44094. protected _reflectionReflectance90: number;
  44095. /**
  44096. * This specifies the weight of the reflection at a perpendicular point of view.
  44097. */
  44098. reflectionReflectance90: number;
  44099. /**
  44100. * Sets the reflection reflectance fresnel values according to the default standard
  44101. * empirically know to work well :-)
  44102. */
  44103. reflectionStandardFresnelWeight: number;
  44104. protected _useRGBColor: boolean;
  44105. /**
  44106. * Helps to directly use the maps channels instead of their level.
  44107. */
  44108. useRGBColor: boolean;
  44109. protected _enableNoise: boolean;
  44110. /**
  44111. * This helps reducing the banding effect that could occur on the background.
  44112. */
  44113. enableNoise: boolean;
  44114. /**
  44115. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44116. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44117. * Recommended to be keep at 1.0 except for special cases.
  44118. */
  44119. fovMultiplier: number;
  44120. private _fovMultiplier;
  44121. /**
  44122. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44123. */
  44124. useEquirectangularFOV: boolean;
  44125. private _maxSimultaneousLights;
  44126. /**
  44127. * Number of Simultaneous lights allowed on the material.
  44128. */
  44129. maxSimultaneousLights: int;
  44130. /**
  44131. * Default configuration related to image processing available in the Background Material.
  44132. */
  44133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44134. /**
  44135. * Keep track of the image processing observer to allow dispose and replace.
  44136. */
  44137. private _imageProcessingObserver;
  44138. /**
  44139. * Attaches a new image processing configuration to the PBR Material.
  44140. * @param configuration (if null the scene configuration will be use)
  44141. */
  44142. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44143. /**
  44144. * Gets the image processing configuration used either in this material.
  44145. */
  44146. /**
  44147. * Sets the Default image processing configuration used either in the this material.
  44148. *
  44149. * If sets to null, the scene one is in use.
  44150. */
  44151. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44152. /**
  44153. * Gets wether the color curves effect is enabled.
  44154. */
  44155. /**
  44156. * Sets wether the color curves effect is enabled.
  44157. */
  44158. cameraColorCurvesEnabled: boolean;
  44159. /**
  44160. * Gets wether the color grading effect is enabled.
  44161. */
  44162. /**
  44163. * Gets wether the color grading effect is enabled.
  44164. */
  44165. cameraColorGradingEnabled: boolean;
  44166. /**
  44167. * Gets wether tonemapping is enabled or not.
  44168. */
  44169. /**
  44170. * Sets wether tonemapping is enabled or not
  44171. */
  44172. cameraToneMappingEnabled: boolean;
  44173. /**
  44174. * The camera exposure used on this material.
  44175. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44176. * This corresponds to a photographic exposure.
  44177. */
  44178. /**
  44179. * The camera exposure used on this material.
  44180. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44181. * This corresponds to a photographic exposure.
  44182. */
  44183. cameraExposure: float;
  44184. /**
  44185. * Gets The camera contrast used on this material.
  44186. */
  44187. /**
  44188. * Sets The camera contrast used on this material.
  44189. */
  44190. cameraContrast: float;
  44191. /**
  44192. * Gets the Color Grading 2D Lookup Texture.
  44193. */
  44194. /**
  44195. * Sets the Color Grading 2D Lookup Texture.
  44196. */
  44197. cameraColorGradingTexture: Nullable<BaseTexture>;
  44198. /**
  44199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44201. * 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;
  44202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44203. */
  44204. /**
  44205. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44206. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44207. * 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;
  44208. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44209. */
  44210. cameraColorCurves: Nullable<ColorCurves>;
  44211. /**
  44212. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44213. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44214. */
  44215. switchToBGR: boolean;
  44216. private _renderTargets;
  44217. private _reflectionControls;
  44218. private _white;
  44219. private _primaryShadowColor;
  44220. private _primaryHighlightColor;
  44221. /**
  44222. * Instantiates a Background Material in the given scene
  44223. * @param name The friendly name of the material
  44224. * @param scene The scene to add the material to
  44225. */
  44226. constructor(name: string, scene: Scene);
  44227. /**
  44228. * Gets a boolean indicating that current material needs to register RTT
  44229. */
  44230. readonly hasRenderTargetTextures: boolean;
  44231. /**
  44232. * The entire material has been created in order to prevent overdraw.
  44233. * @returns false
  44234. */
  44235. needAlphaTesting(): boolean;
  44236. /**
  44237. * The entire material has been created in order to prevent overdraw.
  44238. * @returns true if blending is enable
  44239. */
  44240. needAlphaBlending(): boolean;
  44241. /**
  44242. * Checks wether the material is ready to be rendered for a given mesh.
  44243. * @param mesh The mesh to render
  44244. * @param subMesh The submesh to check against
  44245. * @param useInstances Specify wether or not the material is used with instances
  44246. * @returns true if all the dependencies are ready (Textures, Effects...)
  44247. */
  44248. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44249. /**
  44250. * Compute the primary color according to the chosen perceptual color.
  44251. */
  44252. private _computePrimaryColorFromPerceptualColor;
  44253. /**
  44254. * Compute the highlights and shadow colors according to their chosen levels.
  44255. */
  44256. private _computePrimaryColors;
  44257. /**
  44258. * Build the uniform buffer used in the material.
  44259. */
  44260. buildUniformLayout(): void;
  44261. /**
  44262. * Unbind the material.
  44263. */
  44264. unbind(): void;
  44265. /**
  44266. * Bind only the world matrix to the material.
  44267. * @param world The world matrix to bind.
  44268. */
  44269. bindOnlyWorldMatrix(world: Matrix): void;
  44270. /**
  44271. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44272. * @param world The world matrix to bind.
  44273. * @param subMesh The submesh to bind for.
  44274. */
  44275. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44276. /**
  44277. * Dispose the material.
  44278. * @param forceDisposeEffect Force disposal of the associated effect.
  44279. * @param forceDisposeTextures Force disposal of the associated textures.
  44280. */
  44281. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44282. /**
  44283. * Clones the material.
  44284. * @param name The cloned name.
  44285. * @returns The cloned material.
  44286. */
  44287. clone(name: string): BackgroundMaterial;
  44288. /**
  44289. * Serializes the current material to its JSON representation.
  44290. * @returns The JSON representation.
  44291. */
  44292. serialize(): any;
  44293. /**
  44294. * Gets the class name of the material
  44295. * @returns "BackgroundMaterial"
  44296. */
  44297. getClassName(): string;
  44298. /**
  44299. * Parse a JSON input to create back a background material.
  44300. * @param source The JSON data to parse
  44301. * @param scene The scene to create the parsed material in
  44302. * @param rootUrl The root url of the assets the material depends upon
  44303. * @returns the instantiated BackgroundMaterial.
  44304. */
  44305. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44306. }
  44307. }
  44308. declare module "babylonjs/Helpers/environmentHelper" {
  44309. import { Observable } from "babylonjs/Misc/observable";
  44310. import { Nullable } from "babylonjs/types";
  44311. import { Scene } from "babylonjs/scene";
  44312. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44314. import { Mesh } from "babylonjs/Meshes/mesh";
  44315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44316. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44317. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44318. import "babylonjs/Meshes/Builders/planeBuilder";
  44319. import "babylonjs/Meshes/Builders/boxBuilder";
  44320. /**
  44321. * Represents the different options available during the creation of
  44322. * a Environment helper.
  44323. *
  44324. * This can control the default ground, skybox and image processing setup of your scene.
  44325. */
  44326. export interface IEnvironmentHelperOptions {
  44327. /**
  44328. * Specifies wether or not to create a ground.
  44329. * True by default.
  44330. */
  44331. createGround: boolean;
  44332. /**
  44333. * Specifies the ground size.
  44334. * 15 by default.
  44335. */
  44336. groundSize: number;
  44337. /**
  44338. * The texture used on the ground for the main color.
  44339. * Comes from the BabylonJS CDN by default.
  44340. *
  44341. * Remarks: Can be either a texture or a url.
  44342. */
  44343. groundTexture: string | BaseTexture;
  44344. /**
  44345. * The color mixed in the ground texture by default.
  44346. * BabylonJS clearColor by default.
  44347. */
  44348. groundColor: Color3;
  44349. /**
  44350. * Specifies the ground opacity.
  44351. * 1 by default.
  44352. */
  44353. groundOpacity: number;
  44354. /**
  44355. * Enables the ground to receive shadows.
  44356. * True by default.
  44357. */
  44358. enableGroundShadow: boolean;
  44359. /**
  44360. * Helps preventing the shadow to be fully black on the ground.
  44361. * 0.5 by default.
  44362. */
  44363. groundShadowLevel: number;
  44364. /**
  44365. * Creates a mirror texture attach to the ground.
  44366. * false by default.
  44367. */
  44368. enableGroundMirror: boolean;
  44369. /**
  44370. * Specifies the ground mirror size ratio.
  44371. * 0.3 by default as the default kernel is 64.
  44372. */
  44373. groundMirrorSizeRatio: number;
  44374. /**
  44375. * Specifies the ground mirror blur kernel size.
  44376. * 64 by default.
  44377. */
  44378. groundMirrorBlurKernel: number;
  44379. /**
  44380. * Specifies the ground mirror visibility amount.
  44381. * 1 by default
  44382. */
  44383. groundMirrorAmount: number;
  44384. /**
  44385. * Specifies the ground mirror reflectance weight.
  44386. * This uses the standard weight of the background material to setup the fresnel effect
  44387. * of the mirror.
  44388. * 1 by default.
  44389. */
  44390. groundMirrorFresnelWeight: number;
  44391. /**
  44392. * Specifies the ground mirror Falloff distance.
  44393. * This can helps reducing the size of the reflection.
  44394. * 0 by Default.
  44395. */
  44396. groundMirrorFallOffDistance: number;
  44397. /**
  44398. * Specifies the ground mirror texture type.
  44399. * Unsigned Int by Default.
  44400. */
  44401. groundMirrorTextureType: number;
  44402. /**
  44403. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44404. * the shown objects.
  44405. */
  44406. groundYBias: number;
  44407. /**
  44408. * Specifies wether or not to create a skybox.
  44409. * True by default.
  44410. */
  44411. createSkybox: boolean;
  44412. /**
  44413. * Specifies the skybox size.
  44414. * 20 by default.
  44415. */
  44416. skyboxSize: number;
  44417. /**
  44418. * The texture used on the skybox for the main color.
  44419. * Comes from the BabylonJS CDN by default.
  44420. *
  44421. * Remarks: Can be either a texture or a url.
  44422. */
  44423. skyboxTexture: string | BaseTexture;
  44424. /**
  44425. * The color mixed in the skybox texture by default.
  44426. * BabylonJS clearColor by default.
  44427. */
  44428. skyboxColor: Color3;
  44429. /**
  44430. * The background rotation around the Y axis of the scene.
  44431. * This helps aligning the key lights of your scene with the background.
  44432. * 0 by default.
  44433. */
  44434. backgroundYRotation: number;
  44435. /**
  44436. * Compute automatically the size of the elements to best fit with the scene.
  44437. */
  44438. sizeAuto: boolean;
  44439. /**
  44440. * Default position of the rootMesh if autoSize is not true.
  44441. */
  44442. rootPosition: Vector3;
  44443. /**
  44444. * Sets up the image processing in the scene.
  44445. * true by default.
  44446. */
  44447. setupImageProcessing: boolean;
  44448. /**
  44449. * The texture used as your environment texture in the scene.
  44450. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44451. *
  44452. * Remarks: Can be either a texture or a url.
  44453. */
  44454. environmentTexture: string | BaseTexture;
  44455. /**
  44456. * The value of the exposure to apply to the scene.
  44457. * 0.6 by default if setupImageProcessing is true.
  44458. */
  44459. cameraExposure: number;
  44460. /**
  44461. * The value of the contrast to apply to the scene.
  44462. * 1.6 by default if setupImageProcessing is true.
  44463. */
  44464. cameraContrast: number;
  44465. /**
  44466. * Specifies wether or not tonemapping should be enabled in the scene.
  44467. * true by default if setupImageProcessing is true.
  44468. */
  44469. toneMappingEnabled: boolean;
  44470. }
  44471. /**
  44472. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44473. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44474. * It also helps with the default setup of your imageProcessing configuration.
  44475. */
  44476. export class EnvironmentHelper {
  44477. /**
  44478. * Default ground texture URL.
  44479. */
  44480. private static _groundTextureCDNUrl;
  44481. /**
  44482. * Default skybox texture URL.
  44483. */
  44484. private static _skyboxTextureCDNUrl;
  44485. /**
  44486. * Default environment texture URL.
  44487. */
  44488. private static _environmentTextureCDNUrl;
  44489. /**
  44490. * Creates the default options for the helper.
  44491. */
  44492. private static _getDefaultOptions;
  44493. private _rootMesh;
  44494. /**
  44495. * Gets the root mesh created by the helper.
  44496. */
  44497. readonly rootMesh: Mesh;
  44498. private _skybox;
  44499. /**
  44500. * Gets the skybox created by the helper.
  44501. */
  44502. readonly skybox: Nullable<Mesh>;
  44503. private _skyboxTexture;
  44504. /**
  44505. * Gets the skybox texture created by the helper.
  44506. */
  44507. readonly skyboxTexture: Nullable<BaseTexture>;
  44508. private _skyboxMaterial;
  44509. /**
  44510. * Gets the skybox material created by the helper.
  44511. */
  44512. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44513. private _ground;
  44514. /**
  44515. * Gets the ground mesh created by the helper.
  44516. */
  44517. readonly ground: Nullable<Mesh>;
  44518. private _groundTexture;
  44519. /**
  44520. * Gets the ground texture created by the helper.
  44521. */
  44522. readonly groundTexture: Nullable<BaseTexture>;
  44523. private _groundMirror;
  44524. /**
  44525. * Gets the ground mirror created by the helper.
  44526. */
  44527. readonly groundMirror: Nullable<MirrorTexture>;
  44528. /**
  44529. * Gets the ground mirror render list to helps pushing the meshes
  44530. * you wish in the ground reflection.
  44531. */
  44532. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44533. private _groundMaterial;
  44534. /**
  44535. * Gets the ground material created by the helper.
  44536. */
  44537. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44538. /**
  44539. * Stores the creation options.
  44540. */
  44541. private readonly _scene;
  44542. private _options;
  44543. /**
  44544. * This observable will be notified with any error during the creation of the environment,
  44545. * mainly texture creation errors.
  44546. */
  44547. onErrorObservable: Observable<{
  44548. message?: string;
  44549. exception?: any;
  44550. }>;
  44551. /**
  44552. * constructor
  44553. * @param options Defines the options we want to customize the helper
  44554. * @param scene The scene to add the material to
  44555. */
  44556. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44557. /**
  44558. * Updates the background according to the new options
  44559. * @param options
  44560. */
  44561. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44562. /**
  44563. * Sets the primary color of all the available elements.
  44564. * @param color the main color to affect to the ground and the background
  44565. */
  44566. setMainColor(color: Color3): void;
  44567. /**
  44568. * Setup the image processing according to the specified options.
  44569. */
  44570. private _setupImageProcessing;
  44571. /**
  44572. * Setup the environment texture according to the specified options.
  44573. */
  44574. private _setupEnvironmentTexture;
  44575. /**
  44576. * Setup the background according to the specified options.
  44577. */
  44578. private _setupBackground;
  44579. /**
  44580. * Get the scene sizes according to the setup.
  44581. */
  44582. private _getSceneSize;
  44583. /**
  44584. * Setup the ground according to the specified options.
  44585. */
  44586. private _setupGround;
  44587. /**
  44588. * Setup the ground material according to the specified options.
  44589. */
  44590. private _setupGroundMaterial;
  44591. /**
  44592. * Setup the ground diffuse texture according to the specified options.
  44593. */
  44594. private _setupGroundDiffuseTexture;
  44595. /**
  44596. * Setup the ground mirror texture according to the specified options.
  44597. */
  44598. private _setupGroundMirrorTexture;
  44599. /**
  44600. * Setup the ground to receive the mirror texture.
  44601. */
  44602. private _setupMirrorInGroundMaterial;
  44603. /**
  44604. * Setup the skybox according to the specified options.
  44605. */
  44606. private _setupSkybox;
  44607. /**
  44608. * Setup the skybox material according to the specified options.
  44609. */
  44610. private _setupSkyboxMaterial;
  44611. /**
  44612. * Setup the skybox reflection texture according to the specified options.
  44613. */
  44614. private _setupSkyboxReflectionTexture;
  44615. private _errorHandler;
  44616. /**
  44617. * Dispose all the elements created by the Helper.
  44618. */
  44619. dispose(): void;
  44620. }
  44621. }
  44622. declare module "babylonjs/Helpers/photoDome" {
  44623. import { Observable } from "babylonjs/Misc/observable";
  44624. import { Nullable } from "babylonjs/types";
  44625. import { Scene } from "babylonjs/scene";
  44626. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44627. import { Mesh } from "babylonjs/Meshes/mesh";
  44628. import { Texture } from "babylonjs/Materials/Textures/texture";
  44629. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44630. import "babylonjs/Meshes/Builders/sphereBuilder";
  44631. /**
  44632. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44633. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44634. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44635. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44636. */
  44637. export class PhotoDome extends TransformNode {
  44638. private _useDirectMapping;
  44639. /**
  44640. * The texture being displayed on the sphere
  44641. */
  44642. protected _photoTexture: Texture;
  44643. /**
  44644. * Gets or sets the texture being displayed on the sphere
  44645. */
  44646. photoTexture: Texture;
  44647. /**
  44648. * Observable raised when an error occured while loading the 360 image
  44649. */
  44650. onLoadErrorObservable: Observable<string>;
  44651. /**
  44652. * The skybox material
  44653. */
  44654. protected _material: BackgroundMaterial;
  44655. /**
  44656. * The surface used for the skybox
  44657. */
  44658. protected _mesh: Mesh;
  44659. /**
  44660. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44661. * Also see the options.resolution property.
  44662. */
  44663. fovMultiplier: number;
  44664. /**
  44665. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44666. * @param name Element's name, child elements will append suffixes for their own names.
  44667. * @param urlsOfPhoto defines the url of the photo to display
  44668. * @param options defines an object containing optional or exposed sub element properties
  44669. * @param onError defines a callback called when an error occured while loading the texture
  44670. */
  44671. constructor(name: string, urlOfPhoto: string, options: {
  44672. resolution?: number;
  44673. size?: number;
  44674. useDirectMapping?: boolean;
  44675. faceForward?: boolean;
  44676. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44677. /**
  44678. * Releases resources associated with this node.
  44679. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44680. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44681. */
  44682. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44683. }
  44684. }
  44685. declare module "babylonjs/Misc/textureTools" {
  44686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44687. import { Texture } from "babylonjs/Materials/Textures/texture";
  44688. import { Scene } from "babylonjs/scene";
  44689. /**
  44690. * Class used to host texture specific utilities
  44691. */
  44692. export class TextureTools {
  44693. /**
  44694. * Uses the GPU to create a copy texture rescaled at a given size
  44695. * @param texture Texture to copy from
  44696. * @param width defines the desired width
  44697. * @param height defines the desired height
  44698. * @param useBilinearMode defines if bilinear mode has to be used
  44699. * @return the generated texture
  44700. */
  44701. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44702. /**
  44703. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44704. * @param scene defines the hosting scene
  44705. * @returns the environment BRDF texture
  44706. */
  44707. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44708. private static _environmentBRDFBase64Texture;
  44709. }
  44710. }
  44711. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44712. import { Nullable } from "babylonjs/types";
  44713. import { IAnimatable } from "babylonjs/Misc/tools";
  44714. import { Color3 } from "babylonjs/Maths/math";
  44715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44716. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44717. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44718. import { Engine } from "babylonjs/Engines/engine";
  44719. import { Scene } from "babylonjs/scene";
  44720. /**
  44721. * @hidden
  44722. */
  44723. export interface IMaterialClearCoatDefines {
  44724. CLEARCOAT: boolean;
  44725. CLEARCOAT_DEFAULTIOR: boolean;
  44726. CLEARCOAT_TEXTURE: boolean;
  44727. CLEARCOAT_TEXTUREDIRECTUV: number;
  44728. CLEARCOAT_BUMP: boolean;
  44729. CLEARCOAT_BUMPDIRECTUV: number;
  44730. CLEARCOAT_TINT: boolean;
  44731. CLEARCOAT_TINT_TEXTURE: boolean;
  44732. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44733. /** @hidden */
  44734. _areTexturesDirty: boolean;
  44735. }
  44736. /**
  44737. * Define the code related to the clear coat parameters of the pbr material.
  44738. */
  44739. export class PBRClearCoatConfiguration {
  44740. /**
  44741. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44742. * The default fits with a polyurethane material.
  44743. */
  44744. private static readonly _DefaultIndiceOfRefraction;
  44745. private _isEnabled;
  44746. /**
  44747. * Defines if the clear coat is enabled in the material.
  44748. */
  44749. isEnabled: boolean;
  44750. /**
  44751. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44752. */
  44753. intensity: number;
  44754. /**
  44755. * Defines the clear coat layer roughness.
  44756. */
  44757. roughness: number;
  44758. private _indiceOfRefraction;
  44759. /**
  44760. * Defines the indice of refraction of the clear coat.
  44761. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44762. * The default fits with a polyurethane material.
  44763. * Changing the default value is more performance intensive.
  44764. */
  44765. indiceOfRefraction: number;
  44766. private _texture;
  44767. /**
  44768. * Stores the clear coat values in a texture.
  44769. */
  44770. texture: Nullable<BaseTexture>;
  44771. private _bumpTexture;
  44772. /**
  44773. * Define the clear coat specific bump texture.
  44774. */
  44775. bumpTexture: Nullable<BaseTexture>;
  44776. private _isTintEnabled;
  44777. /**
  44778. * Defines if the clear coat tint is enabled in the material.
  44779. */
  44780. isTintEnabled: boolean;
  44781. /**
  44782. * Defines if the clear coat tint is enabled in the material.
  44783. * This is only use if tint is enabled
  44784. */
  44785. tintColor: Color3;
  44786. /**
  44787. * Defines if the distance at which the tint color should be found in the
  44788. * clear coat media.
  44789. * This is only use if tint is enabled
  44790. */
  44791. tintColorAtDistance: number;
  44792. /**
  44793. * Defines the clear coat layer thickness.
  44794. * This is only use if tint is enabled
  44795. */
  44796. tintThickness: number;
  44797. private _tintTexture;
  44798. /**
  44799. * Stores the clear tint values in a texture.
  44800. * rgb is tint
  44801. * a is a thickness factor
  44802. */
  44803. tintTexture: Nullable<BaseTexture>;
  44804. /** @hidden */
  44805. private _internalMarkAllSubMeshesAsTexturesDirty;
  44806. /** @hidden */
  44807. _markAllSubMeshesAsTexturesDirty(): void;
  44808. /**
  44809. * Instantiate a new istance of clear coat configuration.
  44810. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44811. */
  44812. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44813. /**
  44814. * Specifies that the submesh is ready to be used.
  44815. * @param defines the list of "defines" to update.
  44816. * @param scene defines the scene the material belongs to.
  44817. * @param engine defines the engine the material belongs to.
  44818. * @param disableBumpMap defines wether the material disables bump or not.
  44819. * @returns - boolean indicating that the submesh is ready or not.
  44820. */
  44821. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44822. /**
  44823. * Checks to see if a texture is used in the material.
  44824. * @param defines the list of "defines" to update.
  44825. * @param scene defines the scene to the material belongs to.
  44826. */
  44827. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44828. /**
  44829. * Binds the material data.
  44830. * @param uniformBuffer defines the Uniform buffer to fill in.
  44831. * @param scene defines the scene the material belongs to.
  44832. * @param engine defines the engine the material belongs to.
  44833. * @param disableBumpMap defines wether the material disables bump or not.
  44834. * @param isFrozen defines wether the material is frozen or not.
  44835. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44836. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44837. */
  44838. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44839. /**
  44840. * Checks to see if a texture is used in the material.
  44841. * @param texture - Base texture to use.
  44842. * @returns - Boolean specifying if a texture is used in the material.
  44843. */
  44844. hasTexture(texture: BaseTexture): boolean;
  44845. /**
  44846. * Returns an array of the actively used textures.
  44847. * @param activeTextures Array of BaseTextures
  44848. */
  44849. getActiveTextures(activeTextures: BaseTexture[]): void;
  44850. /**
  44851. * Returns the animatable textures.
  44852. * @param animatables Array of animatable textures.
  44853. */
  44854. getAnimatables(animatables: IAnimatable[]): void;
  44855. /**
  44856. * Disposes the resources of the material.
  44857. * @param forceDisposeTextures - Forces the disposal of all textures.
  44858. */
  44859. dispose(forceDisposeTextures?: boolean): void;
  44860. /**
  44861. * Get the current class name of the texture useful for serialization or dynamic coding.
  44862. * @returns "PBRClearCoatConfiguration"
  44863. */
  44864. getClassName(): string;
  44865. /**
  44866. * Add fallbacks to the effect fallbacks list.
  44867. * @param defines defines the Base texture to use.
  44868. * @param fallbacks defines the current fallback list.
  44869. * @param currentRank defines the current fallback rank.
  44870. * @returns the new fallback rank.
  44871. */
  44872. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44873. /**
  44874. * Add the required uniforms to the current list.
  44875. * @param uniforms defines the current uniform list.
  44876. */
  44877. static AddUniforms(uniforms: string[]): void;
  44878. /**
  44879. * Add the required samplers to the current list.
  44880. * @param samplers defines the current sampler list.
  44881. */
  44882. static AddSamplers(samplers: string[]): void;
  44883. /**
  44884. * Add the required uniforms to the current buffer.
  44885. * @param uniformBuffer defines the current uniform buffer.
  44886. */
  44887. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44888. /**
  44889. * Makes a duplicate of the current configuration into another one.
  44890. * @param clearCoatConfiguration define the config where to copy the info
  44891. */
  44892. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44893. /**
  44894. * Serializes this clear coat configuration.
  44895. * @returns - An object with the serialized config.
  44896. */
  44897. serialize(): any;
  44898. /**
  44899. * Parses a Clear Coat Configuration from a serialized object.
  44900. * @param source - Serialized object.
  44901. */
  44902. parse(source: any): void;
  44903. }
  44904. }
  44905. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44906. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44907. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44909. import { Vector2 } from "babylonjs/Maths/math";
  44910. import { Scene } from "babylonjs/scene";
  44911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44912. import { IAnimatable } from "babylonjs/Misc/tools";
  44913. import { Nullable } from "babylonjs/types";
  44914. /**
  44915. * @hidden
  44916. */
  44917. export interface IMaterialAnisotropicDefines {
  44918. ANISOTROPIC: boolean;
  44919. ANISOTROPIC_TEXTURE: boolean;
  44920. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44921. MAINUV1: boolean;
  44922. _areTexturesDirty: boolean;
  44923. _needUVs: boolean;
  44924. }
  44925. /**
  44926. * Define the code related to the anisotropic parameters of the pbr material.
  44927. */
  44928. export class PBRAnisotropicConfiguration {
  44929. private _isEnabled;
  44930. /**
  44931. * Defines if the anisotropy is enabled in the material.
  44932. */
  44933. isEnabled: boolean;
  44934. /**
  44935. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44936. */
  44937. intensity: number;
  44938. /**
  44939. * Defines if the effect is along the tangents, bitangents or in between.
  44940. * By default, the effect is "strectching" the highlights along the tangents.
  44941. */
  44942. direction: Vector2;
  44943. private _texture;
  44944. /**
  44945. * Stores the anisotropy values in a texture.
  44946. * rg is direction (like normal from -1 to 1)
  44947. * b is a intensity
  44948. */
  44949. texture: Nullable<BaseTexture>;
  44950. /** @hidden */
  44951. private _internalMarkAllSubMeshesAsTexturesDirty;
  44952. /** @hidden */
  44953. _markAllSubMeshesAsTexturesDirty(): void;
  44954. /**
  44955. * Instantiate a new istance of anisotropy configuration.
  44956. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44957. */
  44958. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44959. /**
  44960. * Specifies that the submesh is ready to be used.
  44961. * @param defines the list of "defines" to update.
  44962. * @param scene defines the scene the material belongs to.
  44963. * @returns - boolean indicating that the submesh is ready or not.
  44964. */
  44965. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44966. /**
  44967. * Checks to see if a texture is used in the material.
  44968. * @param defines the list of "defines" to update.
  44969. * @param mesh the mesh we are preparing the defines for.
  44970. * @param scene defines the scene the material belongs to.
  44971. */
  44972. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44973. /**
  44974. * Binds the material data.
  44975. * @param uniformBuffer defines the Uniform buffer to fill in.
  44976. * @param scene defines the scene the material belongs to.
  44977. * @param isFrozen defines wether the material is frozen or not.
  44978. */
  44979. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44980. /**
  44981. * Checks to see if a texture is used in the material.
  44982. * @param texture - Base texture to use.
  44983. * @returns - Boolean specifying if a texture is used in the material.
  44984. */
  44985. hasTexture(texture: BaseTexture): boolean;
  44986. /**
  44987. * Returns an array of the actively used textures.
  44988. * @param activeTextures Array of BaseTextures
  44989. */
  44990. getActiveTextures(activeTextures: BaseTexture[]): void;
  44991. /**
  44992. * Returns the animatable textures.
  44993. * @param animatables Array of animatable textures.
  44994. */
  44995. getAnimatables(animatables: IAnimatable[]): void;
  44996. /**
  44997. * Disposes the resources of the material.
  44998. * @param forceDisposeTextures - Forces the disposal of all textures.
  44999. */
  45000. dispose(forceDisposeTextures?: boolean): void;
  45001. /**
  45002. * Get the current class name of the texture useful for serialization or dynamic coding.
  45003. * @returns "PBRAnisotropicConfiguration"
  45004. */
  45005. getClassName(): string;
  45006. /**
  45007. * Add fallbacks to the effect fallbacks list.
  45008. * @param defines defines the Base texture to use.
  45009. * @param fallbacks defines the current fallback list.
  45010. * @param currentRank defines the current fallback rank.
  45011. * @returns the new fallback rank.
  45012. */
  45013. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45014. /**
  45015. * Add the required uniforms to the current list.
  45016. * @param uniforms defines the current uniform list.
  45017. */
  45018. static AddUniforms(uniforms: string[]): void;
  45019. /**
  45020. * Add the required uniforms to the current buffer.
  45021. * @param uniformBuffer defines the current uniform buffer.
  45022. */
  45023. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45024. /**
  45025. * Add the required samplers to the current list.
  45026. * @param samplers defines the current sampler list.
  45027. */
  45028. static AddSamplers(samplers: string[]): void;
  45029. /**
  45030. * Makes a duplicate of the current configuration into another one.
  45031. * @param anisotropicConfiguration define the config where to copy the info
  45032. */
  45033. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45034. /**
  45035. * Serializes this anisotropy configuration.
  45036. * @returns - An object with the serialized config.
  45037. */
  45038. serialize(): any;
  45039. /**
  45040. * Parses a anisotropy Configuration from a serialized object.
  45041. * @param source - Serialized object.
  45042. */
  45043. parse(source: any): void;
  45044. }
  45045. }
  45046. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45047. /**
  45048. * @hidden
  45049. */
  45050. export interface IMaterialBRDFDefines {
  45051. BRDF_V_HEIGHT_CORRELATED: boolean;
  45052. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45053. /** @hidden */
  45054. _areMiscDirty: boolean;
  45055. }
  45056. /**
  45057. * Define the code related to the BRDF parameters of the pbr material.
  45058. */
  45059. export class PBRBRDFConfiguration {
  45060. private _useEnergyConservation;
  45061. /**
  45062. * Defines if the material uses energy conservation.
  45063. */
  45064. useEnergyConservation: boolean;
  45065. private _useSmithVisibilityHeightCorrelated;
  45066. /**
  45067. * LEGACY Mode set to false
  45068. * Defines if the material uses height smith correlated visibility term.
  45069. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45070. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45071. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45072. * Not relying on height correlated will also disable energy conservation.
  45073. */
  45074. useSmithVisibilityHeightCorrelated: boolean;
  45075. /** @hidden */
  45076. private _internalMarkAllSubMeshesAsMiscDirty;
  45077. /** @hidden */
  45078. _markAllSubMeshesAsMiscDirty(): void;
  45079. /**
  45080. * Instantiate a new istance of clear coat configuration.
  45081. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45082. */
  45083. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45084. /**
  45085. * Checks to see if a texture is used in the material.
  45086. * @param defines the list of "defines" to update.
  45087. */
  45088. prepareDefines(defines: IMaterialBRDFDefines): void;
  45089. /**
  45090. * Get the current class name of the texture useful for serialization or dynamic coding.
  45091. * @returns "PBRClearCoatConfiguration"
  45092. */
  45093. getClassName(): string;
  45094. /**
  45095. * Makes a duplicate of the current configuration into another one.
  45096. * @param brdfConfiguration define the config where to copy the info
  45097. */
  45098. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45099. /**
  45100. * Serializes this BRDF configuration.
  45101. * @returns - An object with the serialized config.
  45102. */
  45103. serialize(): any;
  45104. /**
  45105. * Parses a BRDF Configuration from a serialized object.
  45106. * @param source - Serialized object.
  45107. */
  45108. parse(source: any): void;
  45109. }
  45110. }
  45111. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45112. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45113. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45114. import { Color3 } from "babylonjs/Maths/math";
  45115. import { Scene } from "babylonjs/scene";
  45116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45117. import { IAnimatable } from "babylonjs/Misc/tools";
  45118. import { Nullable } from "babylonjs/types";
  45119. /**
  45120. * @hidden
  45121. */
  45122. export interface IMaterialSheenDefines {
  45123. SHEEN: boolean;
  45124. SHEEN_TEXTURE: boolean;
  45125. SHEEN_TEXTUREDIRECTUV: number;
  45126. SHEEN_LINKWITHALBEDO: boolean;
  45127. /** @hidden */
  45128. _areTexturesDirty: boolean;
  45129. }
  45130. /**
  45131. * Define the code related to the Sheen parameters of the pbr material.
  45132. */
  45133. export class PBRSheenConfiguration {
  45134. private _isEnabled;
  45135. /**
  45136. * Defines if the material uses sheen.
  45137. */
  45138. isEnabled: boolean;
  45139. private _linkSheenWithAlbedo;
  45140. /**
  45141. * Defines if the sheen is linked to the sheen color.
  45142. */
  45143. linkSheenWithAlbedo: boolean;
  45144. /**
  45145. * Defines the sheen intensity.
  45146. */
  45147. intensity: number;
  45148. /**
  45149. * Defines the sheen color.
  45150. */
  45151. color: Color3;
  45152. private _texture;
  45153. /**
  45154. * Stores the sheen tint values in a texture.
  45155. * rgb is tint
  45156. * a is a intensity
  45157. */
  45158. texture: Nullable<BaseTexture>;
  45159. /** @hidden */
  45160. private _internalMarkAllSubMeshesAsTexturesDirty;
  45161. /** @hidden */
  45162. _markAllSubMeshesAsTexturesDirty(): void;
  45163. /**
  45164. * Instantiate a new istance of clear coat configuration.
  45165. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45166. */
  45167. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45168. /**
  45169. * Specifies that the submesh is ready to be used.
  45170. * @param defines the list of "defines" to update.
  45171. * @param scene defines the scene the material belongs to.
  45172. * @returns - boolean indicating that the submesh is ready or not.
  45173. */
  45174. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45175. /**
  45176. * Checks to see if a texture is used in the material.
  45177. * @param defines the list of "defines" to update.
  45178. * @param scene defines the scene the material belongs to.
  45179. */
  45180. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45181. /**
  45182. * Binds the material data.
  45183. * @param uniformBuffer defines the Uniform buffer to fill in.
  45184. * @param scene defines the scene the material belongs to.
  45185. * @param isFrozen defines wether the material is frozen or not.
  45186. */
  45187. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45188. /**
  45189. * Checks to see if a texture is used in the material.
  45190. * @param texture - Base texture to use.
  45191. * @returns - Boolean specifying if a texture is used in the material.
  45192. */
  45193. hasTexture(texture: BaseTexture): boolean;
  45194. /**
  45195. * Returns an array of the actively used textures.
  45196. * @param activeTextures Array of BaseTextures
  45197. */
  45198. getActiveTextures(activeTextures: BaseTexture[]): void;
  45199. /**
  45200. * Returns the animatable textures.
  45201. * @param animatables Array of animatable textures.
  45202. */
  45203. getAnimatables(animatables: IAnimatable[]): void;
  45204. /**
  45205. * Disposes the resources of the material.
  45206. * @param forceDisposeTextures - Forces the disposal of all textures.
  45207. */
  45208. dispose(forceDisposeTextures?: boolean): void;
  45209. /**
  45210. * Get the current class name of the texture useful for serialization or dynamic coding.
  45211. * @returns "PBRSheenConfiguration"
  45212. */
  45213. getClassName(): string;
  45214. /**
  45215. * Add fallbacks to the effect fallbacks list.
  45216. * @param defines defines the Base texture to use.
  45217. * @param fallbacks defines the current fallback list.
  45218. * @param currentRank defines the current fallback rank.
  45219. * @returns the new fallback rank.
  45220. */
  45221. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45222. /**
  45223. * Add the required uniforms to the current list.
  45224. * @param uniforms defines the current uniform list.
  45225. */
  45226. static AddUniforms(uniforms: string[]): void;
  45227. /**
  45228. * Add the required uniforms to the current buffer.
  45229. * @param uniformBuffer defines the current uniform buffer.
  45230. */
  45231. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45232. /**
  45233. * Add the required samplers to the current list.
  45234. * @param samplers defines the current sampler list.
  45235. */
  45236. static AddSamplers(samplers: string[]): void;
  45237. /**
  45238. * Makes a duplicate of the current configuration into another one.
  45239. * @param sheenConfiguration define the config where to copy the info
  45240. */
  45241. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45242. /**
  45243. * Serializes this BRDF configuration.
  45244. * @returns - An object with the serialized config.
  45245. */
  45246. serialize(): any;
  45247. /**
  45248. * Parses a Sheen Configuration from a serialized object.
  45249. * @param source - Serialized object.
  45250. */
  45251. parse(source: any): void;
  45252. }
  45253. }
  45254. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45255. /** @hidden */
  45256. export var pbrFragmentDeclaration: {
  45257. name: string;
  45258. shader: string;
  45259. };
  45260. }
  45261. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45262. /** @hidden */
  45263. export var pbrUboDeclaration: {
  45264. name: string;
  45265. shader: string;
  45266. };
  45267. }
  45268. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  45269. /** @hidden */
  45270. export var pbrFunctions: {
  45271. name: string;
  45272. shader: string;
  45273. };
  45274. }
  45275. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45276. /** @hidden */
  45277. export var harmonicsFunctions: {
  45278. name: string;
  45279. shader: string;
  45280. };
  45281. }
  45282. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  45283. /** @hidden */
  45284. export var pbrPreLightingFunctions: {
  45285. name: string;
  45286. shader: string;
  45287. };
  45288. }
  45289. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  45290. /** @hidden */
  45291. export var pbrFalloffLightingFunctions: {
  45292. name: string;
  45293. shader: string;
  45294. };
  45295. }
  45296. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  45297. /** @hidden */
  45298. export var pbrLightingFunctions: {
  45299. name: string;
  45300. shader: string;
  45301. };
  45302. }
  45303. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45304. /** @hidden */
  45305. export var pbrDebug: {
  45306. name: string;
  45307. shader: string;
  45308. };
  45309. }
  45310. declare module "babylonjs/Shaders/pbr.fragment" {
  45311. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45312. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45313. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45314. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45315. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45316. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45317. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45318. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45319. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45320. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  45321. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45322. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  45323. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  45324. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  45325. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45326. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45327. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45328. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45329. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45330. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45331. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45332. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45333. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45334. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45335. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45336. /** @hidden */
  45337. export var pbrPixelShader: {
  45338. name: string;
  45339. shader: string;
  45340. };
  45341. }
  45342. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45343. /** @hidden */
  45344. export var pbrVertexDeclaration: {
  45345. name: string;
  45346. shader: string;
  45347. };
  45348. }
  45349. declare module "babylonjs/Shaders/pbr.vertex" {
  45350. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45351. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45352. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45353. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45354. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45355. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45356. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45357. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45358. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45359. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45360. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45361. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45363. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45364. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45365. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45366. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45367. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45368. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45369. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45370. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45371. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45372. /** @hidden */
  45373. export var pbrVertexShader: {
  45374. name: string;
  45375. shader: string;
  45376. };
  45377. }
  45378. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45379. import { IAnimatable } from "babylonjs/Misc/tools";
  45380. import { Nullable } from "babylonjs/types";
  45381. import { Scene } from "babylonjs/scene";
  45382. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45385. import { Mesh } from "babylonjs/Meshes/mesh";
  45386. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45387. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45388. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45389. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45390. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45391. import { Material } from "babylonjs/Materials/material";
  45392. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45394. import "babylonjs/Shaders/pbr.fragment";
  45395. import "babylonjs/Shaders/pbr.vertex";
  45396. /**
  45397. * The Physically based material base class of BJS.
  45398. *
  45399. * This offers the main features of a standard PBR material.
  45400. * For more information, please refer to the documentation :
  45401. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45402. */
  45403. export abstract class PBRBaseMaterial extends PushMaterial {
  45404. /**
  45405. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45406. */
  45407. static readonly PBRMATERIAL_OPAQUE: number;
  45408. /**
  45409. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45410. */
  45411. static readonly PBRMATERIAL_ALPHATEST: number;
  45412. /**
  45413. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45414. */
  45415. static readonly PBRMATERIAL_ALPHABLEND: number;
  45416. /**
  45417. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45418. * They are also discarded below the alpha cutoff threshold to improve performances.
  45419. */
  45420. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45421. /**
  45422. * Defines the default value of how much AO map is occluding the analytical lights
  45423. * (point spot...).
  45424. */
  45425. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45426. /**
  45427. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45428. */
  45429. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45430. /**
  45431. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45432. * to enhance interoperability with other engines.
  45433. */
  45434. static readonly LIGHTFALLOFF_GLTF: number;
  45435. /**
  45436. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45437. * to enhance interoperability with other materials.
  45438. */
  45439. static readonly LIGHTFALLOFF_STANDARD: number;
  45440. /**
  45441. * Intensity of the direct lights e.g. the four lights available in your scene.
  45442. * This impacts both the direct diffuse and specular highlights.
  45443. */
  45444. protected _directIntensity: number;
  45445. /**
  45446. * Intensity of the emissive part of the material.
  45447. * This helps controlling the emissive effect without modifying the emissive color.
  45448. */
  45449. protected _emissiveIntensity: number;
  45450. /**
  45451. * Intensity of the environment e.g. how much the environment will light the object
  45452. * either through harmonics for rough material or through the refelction for shiny ones.
  45453. */
  45454. protected _environmentIntensity: number;
  45455. /**
  45456. * This is a special control allowing the reduction of the specular highlights coming from the
  45457. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45458. */
  45459. protected _specularIntensity: number;
  45460. /**
  45461. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45462. */
  45463. private _lightingInfos;
  45464. /**
  45465. * Debug Control allowing disabling the bump map on this material.
  45466. */
  45467. protected _disableBumpMap: boolean;
  45468. /**
  45469. * AKA Diffuse Texture in standard nomenclature.
  45470. */
  45471. protected _albedoTexture: BaseTexture;
  45472. /**
  45473. * AKA Occlusion Texture in other nomenclature.
  45474. */
  45475. protected _ambientTexture: BaseTexture;
  45476. /**
  45477. * AKA Occlusion Texture Intensity in other nomenclature.
  45478. */
  45479. protected _ambientTextureStrength: number;
  45480. /**
  45481. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45482. * 1 means it completely occludes it
  45483. * 0 mean it has no impact
  45484. */
  45485. protected _ambientTextureImpactOnAnalyticalLights: number;
  45486. /**
  45487. * Stores the alpha values in a texture.
  45488. */
  45489. protected _opacityTexture: BaseTexture;
  45490. /**
  45491. * Stores the reflection values in a texture.
  45492. */
  45493. protected _reflectionTexture: BaseTexture;
  45494. /**
  45495. * Stores the refraction values in a texture.
  45496. */
  45497. protected _refractionTexture: BaseTexture;
  45498. /**
  45499. * Stores the emissive values in a texture.
  45500. */
  45501. protected _emissiveTexture: BaseTexture;
  45502. /**
  45503. * AKA Specular texture in other nomenclature.
  45504. */
  45505. protected _reflectivityTexture: BaseTexture;
  45506. /**
  45507. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45508. */
  45509. protected _metallicTexture: BaseTexture;
  45510. /**
  45511. * Specifies the metallic scalar of the metallic/roughness workflow.
  45512. * Can also be used to scale the metalness values of the metallic texture.
  45513. */
  45514. protected _metallic: Nullable<number>;
  45515. /**
  45516. * Specifies the roughness scalar of the metallic/roughness workflow.
  45517. * Can also be used to scale the roughness values of the metallic texture.
  45518. */
  45519. protected _roughness: Nullable<number>;
  45520. /**
  45521. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45522. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45523. */
  45524. protected _microSurfaceTexture: BaseTexture;
  45525. /**
  45526. * Stores surface normal data used to displace a mesh in a texture.
  45527. */
  45528. protected _bumpTexture: BaseTexture;
  45529. /**
  45530. * Stores the pre-calculated light information of a mesh in a texture.
  45531. */
  45532. protected _lightmapTexture: BaseTexture;
  45533. /**
  45534. * The color of a material in ambient lighting.
  45535. */
  45536. protected _ambientColor: Color3;
  45537. /**
  45538. * AKA Diffuse Color in other nomenclature.
  45539. */
  45540. protected _albedoColor: Color3;
  45541. /**
  45542. * AKA Specular Color in other nomenclature.
  45543. */
  45544. protected _reflectivityColor: Color3;
  45545. /**
  45546. * The color applied when light is reflected from a material.
  45547. */
  45548. protected _reflectionColor: Color3;
  45549. /**
  45550. * The color applied when light is emitted from a material.
  45551. */
  45552. protected _emissiveColor: Color3;
  45553. /**
  45554. * AKA Glossiness in other nomenclature.
  45555. */
  45556. protected _microSurface: number;
  45557. /**
  45558. * source material index of refraction (IOR)' / 'destination material IOR.
  45559. */
  45560. protected _indexOfRefraction: number;
  45561. /**
  45562. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45563. */
  45564. protected _invertRefractionY: boolean;
  45565. /**
  45566. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45567. * Materials half opaque for instance using refraction could benefit from this control.
  45568. */
  45569. protected _linkRefractionWithTransparency: boolean;
  45570. /**
  45571. * Specifies that the material will use the light map as a show map.
  45572. */
  45573. protected _useLightmapAsShadowmap: boolean;
  45574. /**
  45575. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45576. * makes the reflect vector face the model (under horizon).
  45577. */
  45578. protected _useHorizonOcclusion: boolean;
  45579. /**
  45580. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45581. * too much the area relying on ambient texture to define their ambient occlusion.
  45582. */
  45583. protected _useRadianceOcclusion: boolean;
  45584. /**
  45585. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45586. */
  45587. protected _useAlphaFromAlbedoTexture: boolean;
  45588. /**
  45589. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45590. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45591. */
  45592. protected _useSpecularOverAlpha: boolean;
  45593. /**
  45594. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45595. */
  45596. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45597. /**
  45598. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45599. */
  45600. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45601. /**
  45602. * Specifies if the metallic texture contains the roughness information in its green channel.
  45603. */
  45604. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45605. /**
  45606. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45607. */
  45608. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45609. /**
  45610. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45611. */
  45612. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45613. /**
  45614. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45615. */
  45616. protected _useAmbientInGrayScale: boolean;
  45617. /**
  45618. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45619. * The material will try to infer what glossiness each pixel should be.
  45620. */
  45621. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45622. /**
  45623. * Defines the falloff type used in this material.
  45624. * It by default is Physical.
  45625. */
  45626. protected _lightFalloff: number;
  45627. /**
  45628. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45629. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45630. */
  45631. protected _useRadianceOverAlpha: boolean;
  45632. /**
  45633. * Allows using an object space normal map (instead of tangent space).
  45634. */
  45635. protected _useObjectSpaceNormalMap: boolean;
  45636. /**
  45637. * Allows using the bump map in parallax mode.
  45638. */
  45639. protected _useParallax: boolean;
  45640. /**
  45641. * Allows using the bump map in parallax occlusion mode.
  45642. */
  45643. protected _useParallaxOcclusion: boolean;
  45644. /**
  45645. * Controls the scale bias of the parallax mode.
  45646. */
  45647. protected _parallaxScaleBias: number;
  45648. /**
  45649. * If sets to true, disables all the lights affecting the material.
  45650. */
  45651. protected _disableLighting: boolean;
  45652. /**
  45653. * Number of Simultaneous lights allowed on the material.
  45654. */
  45655. protected _maxSimultaneousLights: number;
  45656. /**
  45657. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45658. */
  45659. protected _invertNormalMapX: boolean;
  45660. /**
  45661. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45662. */
  45663. protected _invertNormalMapY: boolean;
  45664. /**
  45665. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45666. */
  45667. protected _twoSidedLighting: boolean;
  45668. /**
  45669. * Defines the alpha limits in alpha test mode.
  45670. */
  45671. protected _alphaCutOff: number;
  45672. /**
  45673. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45674. */
  45675. protected _forceAlphaTest: boolean;
  45676. /**
  45677. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45678. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45679. */
  45680. protected _useAlphaFresnel: boolean;
  45681. /**
  45682. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45683. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45684. */
  45685. protected _useLinearAlphaFresnel: boolean;
  45686. /**
  45687. * The transparency mode of the material.
  45688. */
  45689. protected _transparencyMode: Nullable<number>;
  45690. /**
  45691. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45692. * from cos thetav and roughness:
  45693. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45694. */
  45695. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45696. /**
  45697. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45698. */
  45699. protected _forceIrradianceInFragment: boolean;
  45700. /**
  45701. * Force normal to face away from face.
  45702. */
  45703. protected _forceNormalForward: boolean;
  45704. /**
  45705. * Enables specular anti aliasing in the PBR shader.
  45706. * It will both interacts on the Geometry for analytical and IBL lighting.
  45707. * It also prefilter the roughness map based on the bump values.
  45708. */
  45709. protected _enableSpecularAntiAliasing: boolean;
  45710. /**
  45711. * Default configuration related to image processing available in the PBR Material.
  45712. */
  45713. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45714. /**
  45715. * Keep track of the image processing observer to allow dispose and replace.
  45716. */
  45717. private _imageProcessingObserver;
  45718. /**
  45719. * Attaches a new image processing configuration to the PBR Material.
  45720. * @param configuration
  45721. */
  45722. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45723. /**
  45724. * Stores the available render targets.
  45725. */
  45726. private _renderTargets;
  45727. /**
  45728. * Sets the global ambient color for the material used in lighting calculations.
  45729. */
  45730. private _globalAmbientColor;
  45731. /**
  45732. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45733. */
  45734. private _useLogarithmicDepth;
  45735. /**
  45736. * If set to true, no lighting calculations will be applied.
  45737. */
  45738. private _unlit;
  45739. private _debugMode;
  45740. /**
  45741. * @hidden
  45742. * This is reserved for the inspector.
  45743. * Defines the material debug mode.
  45744. * It helps seeing only some components of the material while troubleshooting.
  45745. */
  45746. debugMode: number;
  45747. /**
  45748. * @hidden
  45749. * This is reserved for the inspector.
  45750. * Specify from where on screen the debug mode should start.
  45751. * The value goes from -1 (full screen) to 1 (not visible)
  45752. * It helps with side by side comparison against the final render
  45753. * This defaults to -1
  45754. */
  45755. private debugLimit;
  45756. /**
  45757. * @hidden
  45758. * This is reserved for the inspector.
  45759. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45760. * You can use the factor to better multiply the final value.
  45761. */
  45762. private debugFactor;
  45763. /**
  45764. * Defines the clear coat layer parameters for the material.
  45765. */
  45766. readonly clearCoat: PBRClearCoatConfiguration;
  45767. /**
  45768. * Defines the anisotropic parameters for the material.
  45769. */
  45770. readonly anisotropy: PBRAnisotropicConfiguration;
  45771. /**
  45772. * Defines the BRDF parameters for the material.
  45773. */
  45774. readonly brdf: PBRBRDFConfiguration;
  45775. /**
  45776. * Defines the Sheen parameters for the material.
  45777. */
  45778. readonly sheen: PBRSheenConfiguration;
  45779. /**
  45780. * Instantiates a new PBRMaterial instance.
  45781. *
  45782. * @param name The material name
  45783. * @param scene The scene the material will be use in.
  45784. */
  45785. constructor(name: string, scene: Scene);
  45786. /**
  45787. * Gets a boolean indicating that current material needs to register RTT
  45788. */
  45789. readonly hasRenderTargetTextures: boolean;
  45790. /**
  45791. * Gets the name of the material class.
  45792. */
  45793. getClassName(): string;
  45794. /**
  45795. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45796. */
  45797. /**
  45798. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45799. */
  45800. useLogarithmicDepth: boolean;
  45801. /**
  45802. * Gets the current transparency mode.
  45803. */
  45804. /**
  45805. * Sets the transparency mode of the material.
  45806. *
  45807. * | Value | Type | Description |
  45808. * | ----- | ----------------------------------- | ----------- |
  45809. * | 0 | OPAQUE | |
  45810. * | 1 | ALPHATEST | |
  45811. * | 2 | ALPHABLEND | |
  45812. * | 3 | ALPHATESTANDBLEND | |
  45813. *
  45814. */
  45815. transparencyMode: Nullable<number>;
  45816. /**
  45817. * Returns true if alpha blending should be disabled.
  45818. */
  45819. private readonly _disableAlphaBlending;
  45820. /**
  45821. * Specifies whether or not this material should be rendered in alpha blend mode.
  45822. */
  45823. needAlphaBlending(): boolean;
  45824. /**
  45825. * Specifies if the mesh will require alpha blending.
  45826. * @param mesh - BJS mesh.
  45827. */
  45828. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45829. /**
  45830. * Specifies whether or not this material should be rendered in alpha test mode.
  45831. */
  45832. needAlphaTesting(): boolean;
  45833. /**
  45834. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45835. */
  45836. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45837. /**
  45838. * Gets the texture used for the alpha test.
  45839. */
  45840. getAlphaTestTexture(): BaseTexture;
  45841. /**
  45842. * Specifies that the submesh is ready to be used.
  45843. * @param mesh - BJS mesh.
  45844. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45845. * @param useInstances - Specifies that instances should be used.
  45846. * @returns - boolean indicating that the submesh is ready or not.
  45847. */
  45848. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45849. /**
  45850. * Specifies if the material uses metallic roughness workflow.
  45851. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45852. */
  45853. isMetallicWorkflow(): boolean;
  45854. private _prepareEffect;
  45855. private _prepareDefines;
  45856. /**
  45857. * Force shader compilation
  45858. */
  45859. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45860. clipPlane: boolean;
  45861. }>): void;
  45862. /**
  45863. * Initializes the uniform buffer layout for the shader.
  45864. */
  45865. buildUniformLayout(): void;
  45866. /**
  45867. * Unbinds the textures.
  45868. */
  45869. unbind(): void;
  45870. /**
  45871. * Binds the submesh data.
  45872. * @param world - The world matrix.
  45873. * @param mesh - The BJS mesh.
  45874. * @param subMesh - A submesh of the BJS mesh.
  45875. */
  45876. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45877. /**
  45878. * Returns the animatable textures.
  45879. * @returns - Array of animatable textures.
  45880. */
  45881. getAnimatables(): IAnimatable[];
  45882. /**
  45883. * Returns the texture used for reflections.
  45884. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45885. */
  45886. private _getReflectionTexture;
  45887. /**
  45888. * Returns the texture used for refraction or null if none is used.
  45889. * @returns - Refection texture if present. If no refraction texture and refraction
  45890. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45891. */
  45892. private _getRefractionTexture;
  45893. /**
  45894. * Returns an array of the actively used textures.
  45895. * @returns - Array of BaseTextures
  45896. */
  45897. getActiveTextures(): BaseTexture[];
  45898. /**
  45899. * Checks to see if a texture is used in the material.
  45900. * @param texture - Base texture to use.
  45901. * @returns - Boolean specifying if a texture is used in the material.
  45902. */
  45903. hasTexture(texture: BaseTexture): boolean;
  45904. /**
  45905. * Disposes the resources of the material.
  45906. * @param forceDisposeEffect - Forces the disposal of effects.
  45907. * @param forceDisposeTextures - Forces the disposal of all textures.
  45908. */
  45909. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45910. }
  45911. }
  45912. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45913. import { Nullable } from "babylonjs/types";
  45914. import { Scene } from "babylonjs/scene";
  45915. import { Color3 } from "babylonjs/Maths/math";
  45916. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45917. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45919. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45920. /**
  45921. * The Physically based material of BJS.
  45922. *
  45923. * This offers the main features of a standard PBR material.
  45924. * For more information, please refer to the documentation :
  45925. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45926. */
  45927. export class PBRMaterial extends PBRBaseMaterial {
  45928. /**
  45929. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45930. */
  45931. static readonly PBRMATERIAL_OPAQUE: number;
  45932. /**
  45933. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45934. */
  45935. static readonly PBRMATERIAL_ALPHATEST: number;
  45936. /**
  45937. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45938. */
  45939. static readonly PBRMATERIAL_ALPHABLEND: number;
  45940. /**
  45941. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45942. * They are also discarded below the alpha cutoff threshold to improve performances.
  45943. */
  45944. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45945. /**
  45946. * Defines the default value of how much AO map is occluding the analytical lights
  45947. * (point spot...).
  45948. */
  45949. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45950. /**
  45951. * Intensity of the direct lights e.g. the four lights available in your scene.
  45952. * This impacts both the direct diffuse and specular highlights.
  45953. */
  45954. directIntensity: number;
  45955. /**
  45956. * Intensity of the emissive part of the material.
  45957. * This helps controlling the emissive effect without modifying the emissive color.
  45958. */
  45959. emissiveIntensity: number;
  45960. /**
  45961. * Intensity of the environment e.g. how much the environment will light the object
  45962. * either through harmonics for rough material or through the refelction for shiny ones.
  45963. */
  45964. environmentIntensity: number;
  45965. /**
  45966. * This is a special control allowing the reduction of the specular highlights coming from the
  45967. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45968. */
  45969. specularIntensity: number;
  45970. /**
  45971. * Debug Control allowing disabling the bump map on this material.
  45972. */
  45973. disableBumpMap: boolean;
  45974. /**
  45975. * AKA Diffuse Texture in standard nomenclature.
  45976. */
  45977. albedoTexture: BaseTexture;
  45978. /**
  45979. * AKA Occlusion Texture in other nomenclature.
  45980. */
  45981. ambientTexture: BaseTexture;
  45982. /**
  45983. * AKA Occlusion Texture Intensity in other nomenclature.
  45984. */
  45985. ambientTextureStrength: number;
  45986. /**
  45987. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45988. * 1 means it completely occludes it
  45989. * 0 mean it has no impact
  45990. */
  45991. ambientTextureImpactOnAnalyticalLights: number;
  45992. /**
  45993. * Stores the alpha values in a texture.
  45994. */
  45995. opacityTexture: BaseTexture;
  45996. /**
  45997. * Stores the reflection values in a texture.
  45998. */
  45999. reflectionTexture: Nullable<BaseTexture>;
  46000. /**
  46001. * Stores the emissive values in a texture.
  46002. */
  46003. emissiveTexture: BaseTexture;
  46004. /**
  46005. * AKA Specular texture in other nomenclature.
  46006. */
  46007. reflectivityTexture: BaseTexture;
  46008. /**
  46009. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46010. */
  46011. metallicTexture: BaseTexture;
  46012. /**
  46013. * Specifies the metallic scalar of the metallic/roughness workflow.
  46014. * Can also be used to scale the metalness values of the metallic texture.
  46015. */
  46016. metallic: Nullable<number>;
  46017. /**
  46018. * Specifies the roughness scalar of the metallic/roughness workflow.
  46019. * Can also be used to scale the roughness values of the metallic texture.
  46020. */
  46021. roughness: Nullable<number>;
  46022. /**
  46023. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46024. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46025. */
  46026. microSurfaceTexture: BaseTexture;
  46027. /**
  46028. * Stores surface normal data used to displace a mesh in a texture.
  46029. */
  46030. bumpTexture: BaseTexture;
  46031. /**
  46032. * Stores the pre-calculated light information of a mesh in a texture.
  46033. */
  46034. lightmapTexture: BaseTexture;
  46035. /**
  46036. * Stores the refracted light information in a texture.
  46037. */
  46038. refractionTexture: BaseTexture;
  46039. /**
  46040. * The color of a material in ambient lighting.
  46041. */
  46042. ambientColor: Color3;
  46043. /**
  46044. * AKA Diffuse Color in other nomenclature.
  46045. */
  46046. albedoColor: Color3;
  46047. /**
  46048. * AKA Specular Color in other nomenclature.
  46049. */
  46050. reflectivityColor: Color3;
  46051. /**
  46052. * The color reflected from the material.
  46053. */
  46054. reflectionColor: Color3;
  46055. /**
  46056. * The color emitted from the material.
  46057. */
  46058. emissiveColor: Color3;
  46059. /**
  46060. * AKA Glossiness in other nomenclature.
  46061. */
  46062. microSurface: number;
  46063. /**
  46064. * source material index of refraction (IOR)' / 'destination material IOR.
  46065. */
  46066. indexOfRefraction: number;
  46067. /**
  46068. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46069. */
  46070. invertRefractionY: boolean;
  46071. /**
  46072. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46073. * Materials half opaque for instance using refraction could benefit from this control.
  46074. */
  46075. linkRefractionWithTransparency: boolean;
  46076. /**
  46077. * If true, the light map contains occlusion information instead of lighting info.
  46078. */
  46079. useLightmapAsShadowmap: boolean;
  46080. /**
  46081. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46082. */
  46083. useAlphaFromAlbedoTexture: boolean;
  46084. /**
  46085. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46086. */
  46087. forceAlphaTest: boolean;
  46088. /**
  46089. * Defines the alpha limits in alpha test mode.
  46090. */
  46091. alphaCutOff: number;
  46092. /**
  46093. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46094. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46095. */
  46096. useSpecularOverAlpha: boolean;
  46097. /**
  46098. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46099. */
  46100. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46101. /**
  46102. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46103. */
  46104. useRoughnessFromMetallicTextureAlpha: boolean;
  46105. /**
  46106. * Specifies if the metallic texture contains the roughness information in its green channel.
  46107. */
  46108. useRoughnessFromMetallicTextureGreen: boolean;
  46109. /**
  46110. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46111. */
  46112. useMetallnessFromMetallicTextureBlue: boolean;
  46113. /**
  46114. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46115. */
  46116. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46117. /**
  46118. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46119. */
  46120. useAmbientInGrayScale: boolean;
  46121. /**
  46122. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46123. * The material will try to infer what glossiness each pixel should be.
  46124. */
  46125. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46126. /**
  46127. * BJS is using an harcoded light falloff based on a manually sets up range.
  46128. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46129. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46130. */
  46131. /**
  46132. * BJS is using an harcoded light falloff based on a manually sets up range.
  46133. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46134. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46135. */
  46136. usePhysicalLightFalloff: boolean;
  46137. /**
  46138. * In order to support the falloff compatibility with gltf, a special mode has been added
  46139. * to reproduce the gltf light falloff.
  46140. */
  46141. /**
  46142. * In order to support the falloff compatibility with gltf, a special mode has been added
  46143. * to reproduce the gltf light falloff.
  46144. */
  46145. useGLTFLightFalloff: boolean;
  46146. /**
  46147. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46148. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46149. */
  46150. useRadianceOverAlpha: boolean;
  46151. /**
  46152. * Allows using an object space normal map (instead of tangent space).
  46153. */
  46154. useObjectSpaceNormalMap: boolean;
  46155. /**
  46156. * Allows using the bump map in parallax mode.
  46157. */
  46158. useParallax: boolean;
  46159. /**
  46160. * Allows using the bump map in parallax occlusion mode.
  46161. */
  46162. useParallaxOcclusion: boolean;
  46163. /**
  46164. * Controls the scale bias of the parallax mode.
  46165. */
  46166. parallaxScaleBias: number;
  46167. /**
  46168. * If sets to true, disables all the lights affecting the material.
  46169. */
  46170. disableLighting: boolean;
  46171. /**
  46172. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46173. */
  46174. forceIrradianceInFragment: boolean;
  46175. /**
  46176. * Number of Simultaneous lights allowed on the material.
  46177. */
  46178. maxSimultaneousLights: number;
  46179. /**
  46180. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46181. */
  46182. invertNormalMapX: boolean;
  46183. /**
  46184. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46185. */
  46186. invertNormalMapY: boolean;
  46187. /**
  46188. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46189. */
  46190. twoSidedLighting: boolean;
  46191. /**
  46192. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46193. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46194. */
  46195. useAlphaFresnel: boolean;
  46196. /**
  46197. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46198. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46199. */
  46200. useLinearAlphaFresnel: boolean;
  46201. /**
  46202. * Let user defines the brdf lookup texture used for IBL.
  46203. * A default 8bit version is embedded but you could point at :
  46204. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46205. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46206. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46207. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46208. */
  46209. environmentBRDFTexture: Nullable<BaseTexture>;
  46210. /**
  46211. * Force normal to face away from face.
  46212. */
  46213. forceNormalForward: boolean;
  46214. /**
  46215. * Enables specular anti aliasing in the PBR shader.
  46216. * It will both interacts on the Geometry for analytical and IBL lighting.
  46217. * It also prefilter the roughness map based on the bump values.
  46218. */
  46219. enableSpecularAntiAliasing: boolean;
  46220. /**
  46221. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46222. * makes the reflect vector face the model (under horizon).
  46223. */
  46224. useHorizonOcclusion: boolean;
  46225. /**
  46226. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46227. * too much the area relying on ambient texture to define their ambient occlusion.
  46228. */
  46229. useRadianceOcclusion: boolean;
  46230. /**
  46231. * If set to true, no lighting calculations will be applied.
  46232. */
  46233. unlit: boolean;
  46234. /**
  46235. * Gets the image processing configuration used either in this material.
  46236. */
  46237. /**
  46238. * Sets the Default image processing configuration used either in the this material.
  46239. *
  46240. * If sets to null, the scene one is in use.
  46241. */
  46242. imageProcessingConfiguration: ImageProcessingConfiguration;
  46243. /**
  46244. * Gets wether the color curves effect is enabled.
  46245. */
  46246. /**
  46247. * Sets wether the color curves effect is enabled.
  46248. */
  46249. cameraColorCurvesEnabled: boolean;
  46250. /**
  46251. * Gets wether the color grading effect is enabled.
  46252. */
  46253. /**
  46254. * Gets wether the color grading effect is enabled.
  46255. */
  46256. cameraColorGradingEnabled: boolean;
  46257. /**
  46258. * Gets wether tonemapping is enabled or not.
  46259. */
  46260. /**
  46261. * Sets wether tonemapping is enabled or not
  46262. */
  46263. cameraToneMappingEnabled: boolean;
  46264. /**
  46265. * The camera exposure used on this material.
  46266. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46267. * This corresponds to a photographic exposure.
  46268. */
  46269. /**
  46270. * The camera exposure used on this material.
  46271. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46272. * This corresponds to a photographic exposure.
  46273. */
  46274. cameraExposure: number;
  46275. /**
  46276. * Gets The camera contrast used on this material.
  46277. */
  46278. /**
  46279. * Sets The camera contrast used on this material.
  46280. */
  46281. cameraContrast: number;
  46282. /**
  46283. * Gets the Color Grading 2D Lookup Texture.
  46284. */
  46285. /**
  46286. * Sets the Color Grading 2D Lookup Texture.
  46287. */
  46288. cameraColorGradingTexture: Nullable<BaseTexture>;
  46289. /**
  46290. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46291. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46292. * 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;
  46293. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46294. */
  46295. /**
  46296. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46297. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46298. * 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;
  46299. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46300. */
  46301. cameraColorCurves: Nullable<ColorCurves>;
  46302. /**
  46303. * Instantiates a new PBRMaterial instance.
  46304. *
  46305. * @param name The material name
  46306. * @param scene The scene the material will be use in.
  46307. */
  46308. constructor(name: string, scene: Scene);
  46309. /**
  46310. * Returns the name of this material class.
  46311. */
  46312. getClassName(): string;
  46313. /**
  46314. * Makes a duplicate of the current material.
  46315. * @param name - name to use for the new material.
  46316. */
  46317. clone(name: string): PBRMaterial;
  46318. /**
  46319. * Serializes this PBR Material.
  46320. * @returns - An object with the serialized material.
  46321. */
  46322. serialize(): any;
  46323. /**
  46324. * Parses a PBR Material from a serialized object.
  46325. * @param source - Serialized object.
  46326. * @param scene - BJS scene instance.
  46327. * @param rootUrl - url for the scene object
  46328. * @returns - PBRMaterial
  46329. */
  46330. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46331. }
  46332. }
  46333. declare module "babylonjs/Misc/dds" {
  46334. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46335. import { Engine } from "babylonjs/Engines/engine";
  46336. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46337. import { Nullable } from "babylonjs/types";
  46338. import { Scene } from "babylonjs/scene";
  46339. /**
  46340. * Direct draw surface info
  46341. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46342. */
  46343. export interface DDSInfo {
  46344. /**
  46345. * Width of the texture
  46346. */
  46347. width: number;
  46348. /**
  46349. * Width of the texture
  46350. */
  46351. height: number;
  46352. /**
  46353. * Number of Mipmaps for the texture
  46354. * @see https://en.wikipedia.org/wiki/Mipmap
  46355. */
  46356. mipmapCount: number;
  46357. /**
  46358. * If the textures format is a known fourCC format
  46359. * @see https://www.fourcc.org/
  46360. */
  46361. isFourCC: boolean;
  46362. /**
  46363. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46364. */
  46365. isRGB: boolean;
  46366. /**
  46367. * If the texture is a lumincance format
  46368. */
  46369. isLuminance: boolean;
  46370. /**
  46371. * If this is a cube texture
  46372. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46373. */
  46374. isCube: boolean;
  46375. /**
  46376. * If the texture is a compressed format eg. FOURCC_DXT1
  46377. */
  46378. isCompressed: boolean;
  46379. /**
  46380. * The dxgiFormat of the texture
  46381. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46382. */
  46383. dxgiFormat: number;
  46384. /**
  46385. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46386. */
  46387. textureType: number;
  46388. /**
  46389. * Sphericle polynomial created for the dds texture
  46390. */
  46391. sphericalPolynomial?: SphericalPolynomial;
  46392. }
  46393. /**
  46394. * Class used to provide DDS decompression tools
  46395. */
  46396. export class DDSTools {
  46397. /**
  46398. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46399. */
  46400. static StoreLODInAlphaChannel: boolean;
  46401. /**
  46402. * Gets DDS information from an array buffer
  46403. * @param arrayBuffer defines the array buffer to read data from
  46404. * @returns the DDS information
  46405. */
  46406. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46407. private static _FloatView;
  46408. private static _Int32View;
  46409. private static _ToHalfFloat;
  46410. private static _FromHalfFloat;
  46411. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46412. private static _GetHalfFloatRGBAArrayBuffer;
  46413. private static _GetFloatRGBAArrayBuffer;
  46414. private static _GetFloatAsUIntRGBAArrayBuffer;
  46415. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46416. private static _GetRGBAArrayBuffer;
  46417. private static _ExtractLongWordOrder;
  46418. private static _GetRGBArrayBuffer;
  46419. private static _GetLuminanceArrayBuffer;
  46420. /**
  46421. * Uploads DDS Levels to a Babylon Texture
  46422. * @hidden
  46423. */
  46424. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46425. }
  46426. module "babylonjs/Engines/engine" {
  46427. interface Engine {
  46428. /**
  46429. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46430. * @param rootUrl defines the url where the file to load is located
  46431. * @param scene defines the current scene
  46432. * @param lodScale defines scale to apply to the mip map selection
  46433. * @param lodOffset defines offset to apply to the mip map selection
  46434. * @param onLoad defines an optional callback raised when the texture is loaded
  46435. * @param onError defines an optional callback raised if there is an issue to load the texture
  46436. * @param format defines the format of the data
  46437. * @param forcedExtension defines the extension to use to pick the right loader
  46438. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46439. * @returns the cube texture as an InternalTexture
  46440. */
  46441. 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;
  46442. }
  46443. }
  46444. }
  46445. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46446. import { Nullable } from "babylonjs/types";
  46447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46448. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46449. /**
  46450. * Implementation of the DDS Texture Loader.
  46451. * @hidden
  46452. */
  46453. export class _DDSTextureLoader implements IInternalTextureLoader {
  46454. /**
  46455. * Defines wether the loader supports cascade loading the different faces.
  46456. */
  46457. readonly supportCascades: boolean;
  46458. /**
  46459. * This returns if the loader support the current file information.
  46460. * @param extension defines the file extension of the file being loaded
  46461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46462. * @param fallback defines the fallback internal texture if any
  46463. * @param isBase64 defines whether the texture is encoded as a base64
  46464. * @param isBuffer defines whether the texture data are stored as a buffer
  46465. * @returns true if the loader can load the specified file
  46466. */
  46467. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46468. /**
  46469. * Transform the url before loading if required.
  46470. * @param rootUrl the url of the texture
  46471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46472. * @returns the transformed texture
  46473. */
  46474. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46475. /**
  46476. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46477. * @param rootUrl the url of the texture
  46478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46479. * @returns the fallback texture
  46480. */
  46481. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46482. /**
  46483. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46484. * @param data contains the texture data
  46485. * @param texture defines the BabylonJS internal texture
  46486. * @param createPolynomials will be true if polynomials have been requested
  46487. * @param onLoad defines the callback to trigger once the texture is ready
  46488. * @param onError defines the callback to trigger in case of error
  46489. */
  46490. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46491. /**
  46492. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46493. * @param data contains the texture data
  46494. * @param texture defines the BabylonJS internal texture
  46495. * @param callback defines the method to call once ready to upload
  46496. */
  46497. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46498. }
  46499. }
  46500. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46501. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46502. /** @hidden */
  46503. export var rgbdEncodePixelShader: {
  46504. name: string;
  46505. shader: string;
  46506. };
  46507. }
  46508. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46509. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46510. /** @hidden */
  46511. export var rgbdDecodePixelShader: {
  46512. name: string;
  46513. shader: string;
  46514. };
  46515. }
  46516. declare module "babylonjs/Misc/environmentTextureTools" {
  46517. import { Nullable } from "babylonjs/types";
  46518. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46520. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46521. import "babylonjs/Shaders/rgbdEncode.fragment";
  46522. import "babylonjs/Shaders/rgbdDecode.fragment";
  46523. /**
  46524. * Raw texture data and descriptor sufficient for WebGL texture upload
  46525. */
  46526. export interface EnvironmentTextureInfo {
  46527. /**
  46528. * Version of the environment map
  46529. */
  46530. version: number;
  46531. /**
  46532. * Width of image
  46533. */
  46534. width: number;
  46535. /**
  46536. * Irradiance information stored in the file.
  46537. */
  46538. irradiance: any;
  46539. /**
  46540. * Specular information stored in the file.
  46541. */
  46542. specular: any;
  46543. }
  46544. /**
  46545. * Sets of helpers addressing the serialization and deserialization of environment texture
  46546. * stored in a BabylonJS env file.
  46547. * Those files are usually stored as .env files.
  46548. */
  46549. export class EnvironmentTextureTools {
  46550. /**
  46551. * Magic number identifying the env file.
  46552. */
  46553. private static _MagicBytes;
  46554. /**
  46555. * Gets the environment info from an env file.
  46556. * @param data The array buffer containing the .env bytes.
  46557. * @returns the environment file info (the json header) if successfully parsed.
  46558. */
  46559. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46560. /**
  46561. * Creates an environment texture from a loaded cube texture.
  46562. * @param texture defines the cube texture to convert in env file
  46563. * @return a promise containing the environment data if succesfull.
  46564. */
  46565. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46566. /**
  46567. * Creates a JSON representation of the spherical data.
  46568. * @param texture defines the texture containing the polynomials
  46569. * @return the JSON representation of the spherical info
  46570. */
  46571. private static _CreateEnvTextureIrradiance;
  46572. /**
  46573. * Uploads the texture info contained in the env file to the GPU.
  46574. * @param texture defines the internal texture to upload to
  46575. * @param arrayBuffer defines the buffer cotaining the data to load
  46576. * @param info defines the texture info retrieved through the GetEnvInfo method
  46577. * @returns a promise
  46578. */
  46579. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46580. /**
  46581. * Uploads the levels of image data to the GPU.
  46582. * @param texture defines the internal texture to upload to
  46583. * @param imageData defines the array buffer views of image data [mipmap][face]
  46584. * @returns a promise
  46585. */
  46586. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46587. /**
  46588. * Uploads spherical polynomials information to the texture.
  46589. * @param texture defines the texture we are trying to upload the information to
  46590. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46591. */
  46592. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46593. /** @hidden */
  46594. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46595. }
  46596. }
  46597. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46598. import { Nullable } from "babylonjs/types";
  46599. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46600. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46601. /**
  46602. * Implementation of the ENV Texture Loader.
  46603. * @hidden
  46604. */
  46605. export class _ENVTextureLoader implements IInternalTextureLoader {
  46606. /**
  46607. * Defines wether the loader supports cascade loading the different faces.
  46608. */
  46609. readonly supportCascades: boolean;
  46610. /**
  46611. * This returns if the loader support the current file information.
  46612. * @param extension defines the file extension of the file being loaded
  46613. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46614. * @param fallback defines the fallback internal texture if any
  46615. * @param isBase64 defines whether the texture is encoded as a base64
  46616. * @param isBuffer defines whether the texture data are stored as a buffer
  46617. * @returns true if the loader can load the specified file
  46618. */
  46619. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46620. /**
  46621. * Transform the url before loading if required.
  46622. * @param rootUrl the url of the texture
  46623. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46624. * @returns the transformed texture
  46625. */
  46626. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46627. /**
  46628. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46629. * @param rootUrl the url of the texture
  46630. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46631. * @returns the fallback texture
  46632. */
  46633. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46634. /**
  46635. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46636. * @param data contains the texture data
  46637. * @param texture defines the BabylonJS internal texture
  46638. * @param createPolynomials will be true if polynomials have been requested
  46639. * @param onLoad defines the callback to trigger once the texture is ready
  46640. * @param onError defines the callback to trigger in case of error
  46641. */
  46642. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46643. /**
  46644. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46645. * @param data contains the texture data
  46646. * @param texture defines the BabylonJS internal texture
  46647. * @param callback defines the method to call once ready to upload
  46648. */
  46649. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46650. }
  46651. }
  46652. declare module "babylonjs/Misc/khronosTextureContainer" {
  46653. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46654. /**
  46655. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46656. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46657. */
  46658. export class KhronosTextureContainer {
  46659. /** contents of the KTX container file */
  46660. arrayBuffer: any;
  46661. private static HEADER_LEN;
  46662. private static COMPRESSED_2D;
  46663. private static COMPRESSED_3D;
  46664. private static TEX_2D;
  46665. private static TEX_3D;
  46666. /**
  46667. * Gets the openGL type
  46668. */
  46669. glType: number;
  46670. /**
  46671. * Gets the openGL type size
  46672. */
  46673. glTypeSize: number;
  46674. /**
  46675. * Gets the openGL format
  46676. */
  46677. glFormat: number;
  46678. /**
  46679. * Gets the openGL internal format
  46680. */
  46681. glInternalFormat: number;
  46682. /**
  46683. * Gets the base internal format
  46684. */
  46685. glBaseInternalFormat: number;
  46686. /**
  46687. * Gets image width in pixel
  46688. */
  46689. pixelWidth: number;
  46690. /**
  46691. * Gets image height in pixel
  46692. */
  46693. pixelHeight: number;
  46694. /**
  46695. * Gets image depth in pixels
  46696. */
  46697. pixelDepth: number;
  46698. /**
  46699. * Gets the number of array elements
  46700. */
  46701. numberOfArrayElements: number;
  46702. /**
  46703. * Gets the number of faces
  46704. */
  46705. numberOfFaces: number;
  46706. /**
  46707. * Gets the number of mipmap levels
  46708. */
  46709. numberOfMipmapLevels: number;
  46710. /**
  46711. * Gets the bytes of key value data
  46712. */
  46713. bytesOfKeyValueData: number;
  46714. /**
  46715. * Gets the load type
  46716. */
  46717. loadType: number;
  46718. /**
  46719. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46720. */
  46721. isInvalid: boolean;
  46722. /**
  46723. * Creates a new KhronosTextureContainer
  46724. * @param arrayBuffer contents of the KTX container file
  46725. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46726. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46727. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46728. */
  46729. constructor(
  46730. /** contents of the KTX container file */
  46731. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46732. /**
  46733. * Uploads KTX content to a Babylon Texture.
  46734. * It is assumed that the texture has already been created & is currently bound
  46735. * @hidden
  46736. */
  46737. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46738. private _upload2DCompressedLevels;
  46739. }
  46740. }
  46741. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46742. import { Nullable } from "babylonjs/types";
  46743. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46744. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46745. /**
  46746. * Implementation of the KTX Texture Loader.
  46747. * @hidden
  46748. */
  46749. export class _KTXTextureLoader implements IInternalTextureLoader {
  46750. /**
  46751. * Defines wether the loader supports cascade loading the different faces.
  46752. */
  46753. readonly supportCascades: boolean;
  46754. /**
  46755. * This returns if the loader support the current file information.
  46756. * @param extension defines the file extension of the file being loaded
  46757. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46758. * @param fallback defines the fallback internal texture if any
  46759. * @param isBase64 defines whether the texture is encoded as a base64
  46760. * @param isBuffer defines whether the texture data are stored as a buffer
  46761. * @returns true if the loader can load the specified file
  46762. */
  46763. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46764. /**
  46765. * Transform the url before loading if required.
  46766. * @param rootUrl the url of the texture
  46767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46768. * @returns the transformed texture
  46769. */
  46770. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46771. /**
  46772. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46773. * @param rootUrl the url of the texture
  46774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46775. * @returns the fallback texture
  46776. */
  46777. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46778. /**
  46779. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46780. * @param data contains the texture data
  46781. * @param texture defines the BabylonJS internal texture
  46782. * @param createPolynomials will be true if polynomials have been requested
  46783. * @param onLoad defines the callback to trigger once the texture is ready
  46784. * @param onError defines the callback to trigger in case of error
  46785. */
  46786. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46787. /**
  46788. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46789. * @param data contains the texture data
  46790. * @param texture defines the BabylonJS internal texture
  46791. * @param callback defines the method to call once ready to upload
  46792. */
  46793. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46794. }
  46795. }
  46796. declare module "babylonjs/Helpers/sceneHelpers" {
  46797. import { Nullable } from "babylonjs/types";
  46798. import { Mesh } from "babylonjs/Meshes/mesh";
  46799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46800. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46801. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46802. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46803. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46804. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46805. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46806. import "babylonjs/Meshes/Builders/boxBuilder";
  46807. /** @hidden */
  46808. export var _forceSceneHelpersToBundle: boolean;
  46809. module "babylonjs/scene" {
  46810. interface Scene {
  46811. /**
  46812. * Creates a default light for the scene.
  46813. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46814. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46815. */
  46816. createDefaultLight(replace?: boolean): void;
  46817. /**
  46818. * Creates a default camera for the scene.
  46819. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46820. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46821. * @param replace has default false, when true replaces the active camera in the scene
  46822. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46823. */
  46824. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46825. /**
  46826. * Creates a default camera and a default light.
  46827. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46828. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46829. * @param replace has the default false, when true replaces the active camera/light in the scene
  46830. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46831. */
  46832. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46833. /**
  46834. * Creates a new sky box
  46835. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46836. * @param environmentTexture defines the texture to use as environment texture
  46837. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46838. * @param scale defines the overall scale of the skybox
  46839. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46840. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46841. * @returns a new mesh holding the sky box
  46842. */
  46843. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46844. /**
  46845. * Creates a new environment
  46846. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46847. * @param options defines the options you can use to configure the environment
  46848. * @returns the new EnvironmentHelper
  46849. */
  46850. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46851. /**
  46852. * Creates a new VREXperienceHelper
  46853. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46854. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46855. * @returns a new VREXperienceHelper
  46856. */
  46857. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46858. /**
  46859. * Creates a new XREXperienceHelper
  46860. * @see http://doc.babylonjs.com/how_to/webxr
  46861. * @returns a promise for a new XREXperienceHelper
  46862. */
  46863. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46864. }
  46865. }
  46866. }
  46867. declare module "babylonjs/Helpers/videoDome" {
  46868. import { Scene } from "babylonjs/scene";
  46869. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46870. import { Mesh } from "babylonjs/Meshes/mesh";
  46871. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46872. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46873. import "babylonjs/Meshes/Builders/sphereBuilder";
  46874. /**
  46875. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46876. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46877. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46878. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46879. */
  46880. export class VideoDome extends TransformNode {
  46881. /**
  46882. * Define the video source as a Monoscopic panoramic 360 video.
  46883. */
  46884. static readonly MODE_MONOSCOPIC: number;
  46885. /**
  46886. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46887. */
  46888. static readonly MODE_TOPBOTTOM: number;
  46889. /**
  46890. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46891. */
  46892. static readonly MODE_SIDEBYSIDE: number;
  46893. private _useDirectMapping;
  46894. /**
  46895. * The video texture being displayed on the sphere
  46896. */
  46897. protected _videoTexture: VideoTexture;
  46898. /**
  46899. * Gets the video texture being displayed on the sphere
  46900. */
  46901. readonly videoTexture: VideoTexture;
  46902. /**
  46903. * The skybox material
  46904. */
  46905. protected _material: BackgroundMaterial;
  46906. /**
  46907. * The surface used for the skybox
  46908. */
  46909. protected _mesh: Mesh;
  46910. /**
  46911. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46912. * Also see the options.resolution property.
  46913. */
  46914. fovMultiplier: number;
  46915. private _videoMode;
  46916. /**
  46917. * Gets or set the current video mode for the video. It can be:
  46918. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46919. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46920. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46921. */
  46922. videoMode: number;
  46923. /**
  46924. * Oberserver used in Stereoscopic VR Mode.
  46925. */
  46926. private _onBeforeCameraRenderObserver;
  46927. /**
  46928. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46929. * @param name Element's name, child elements will append suffixes for their own names.
  46930. * @param urlsOrVideo defines the url(s) or the video element to use
  46931. * @param options An object containing optional or exposed sub element properties
  46932. */
  46933. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46934. resolution?: number;
  46935. clickToPlay?: boolean;
  46936. autoPlay?: boolean;
  46937. loop?: boolean;
  46938. size?: number;
  46939. poster?: string;
  46940. faceForward?: boolean;
  46941. useDirectMapping?: boolean;
  46942. }, scene: Scene);
  46943. private _changeVideoMode;
  46944. /**
  46945. * Releases resources associated with this node.
  46946. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46947. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46948. */
  46949. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46950. }
  46951. }
  46952. declare module "babylonjs/Helpers/index" {
  46953. export * from "babylonjs/Helpers/environmentHelper";
  46954. export * from "babylonjs/Helpers/photoDome";
  46955. export * from "babylonjs/Helpers/sceneHelpers";
  46956. export * from "babylonjs/Helpers/videoDome";
  46957. }
  46958. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46959. import { PerfCounter } from "babylonjs/Misc/tools";
  46960. import { IDisposable } from "babylonjs/scene";
  46961. import { Engine } from "babylonjs/Engines/engine";
  46962. /**
  46963. * This class can be used to get instrumentation data from a Babylon engine
  46964. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46965. */
  46966. export class EngineInstrumentation implements IDisposable {
  46967. /**
  46968. * Define the instrumented engine.
  46969. */
  46970. engine: Engine;
  46971. private _captureGPUFrameTime;
  46972. private _gpuFrameTimeToken;
  46973. private _gpuFrameTime;
  46974. private _captureShaderCompilationTime;
  46975. private _shaderCompilationTime;
  46976. private _onBeginFrameObserver;
  46977. private _onEndFrameObserver;
  46978. private _onBeforeShaderCompilationObserver;
  46979. private _onAfterShaderCompilationObserver;
  46980. /**
  46981. * Gets the perf counter used for GPU frame time
  46982. */
  46983. readonly gpuFrameTimeCounter: PerfCounter;
  46984. /**
  46985. * Gets the GPU frame time capture status
  46986. */
  46987. /**
  46988. * Enable or disable the GPU frame time capture
  46989. */
  46990. captureGPUFrameTime: boolean;
  46991. /**
  46992. * Gets the perf counter used for shader compilation time
  46993. */
  46994. readonly shaderCompilationTimeCounter: PerfCounter;
  46995. /**
  46996. * Gets the shader compilation time capture status
  46997. */
  46998. /**
  46999. * Enable or disable the shader compilation time capture
  47000. */
  47001. captureShaderCompilationTime: boolean;
  47002. /**
  47003. * Instantiates a new engine instrumentation.
  47004. * This class can be used to get instrumentation data from a Babylon engine
  47005. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47006. * @param engine Defines the engine to instrument
  47007. */
  47008. constructor(
  47009. /**
  47010. * Define the instrumented engine.
  47011. */
  47012. engine: Engine);
  47013. /**
  47014. * Dispose and release associated resources.
  47015. */
  47016. dispose(): void;
  47017. }
  47018. }
  47019. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  47020. import { PerfCounter } from "babylonjs/Misc/tools";
  47021. import { Scene, IDisposable } from "babylonjs/scene";
  47022. /**
  47023. * This class can be used to get instrumentation data from a Babylon engine
  47024. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47025. */
  47026. export class SceneInstrumentation implements IDisposable {
  47027. /**
  47028. * Defines the scene to instrument
  47029. */
  47030. scene: Scene;
  47031. private _captureActiveMeshesEvaluationTime;
  47032. private _activeMeshesEvaluationTime;
  47033. private _captureRenderTargetsRenderTime;
  47034. private _renderTargetsRenderTime;
  47035. private _captureFrameTime;
  47036. private _frameTime;
  47037. private _captureRenderTime;
  47038. private _renderTime;
  47039. private _captureInterFrameTime;
  47040. private _interFrameTime;
  47041. private _captureParticlesRenderTime;
  47042. private _particlesRenderTime;
  47043. private _captureSpritesRenderTime;
  47044. private _spritesRenderTime;
  47045. private _capturePhysicsTime;
  47046. private _physicsTime;
  47047. private _captureAnimationsTime;
  47048. private _animationsTime;
  47049. private _captureCameraRenderTime;
  47050. private _cameraRenderTime;
  47051. private _onBeforeActiveMeshesEvaluationObserver;
  47052. private _onAfterActiveMeshesEvaluationObserver;
  47053. private _onBeforeRenderTargetsRenderObserver;
  47054. private _onAfterRenderTargetsRenderObserver;
  47055. private _onAfterRenderObserver;
  47056. private _onBeforeDrawPhaseObserver;
  47057. private _onAfterDrawPhaseObserver;
  47058. private _onBeforeAnimationsObserver;
  47059. private _onBeforeParticlesRenderingObserver;
  47060. private _onAfterParticlesRenderingObserver;
  47061. private _onBeforeSpritesRenderingObserver;
  47062. private _onAfterSpritesRenderingObserver;
  47063. private _onBeforePhysicsObserver;
  47064. private _onAfterPhysicsObserver;
  47065. private _onAfterAnimationsObserver;
  47066. private _onBeforeCameraRenderObserver;
  47067. private _onAfterCameraRenderObserver;
  47068. /**
  47069. * Gets the perf counter used for active meshes evaluation time
  47070. */
  47071. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47072. /**
  47073. * Gets the active meshes evaluation time capture status
  47074. */
  47075. /**
  47076. * Enable or disable the active meshes evaluation time capture
  47077. */
  47078. captureActiveMeshesEvaluationTime: boolean;
  47079. /**
  47080. * Gets the perf counter used for render targets render time
  47081. */
  47082. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47083. /**
  47084. * Gets the render targets render time capture status
  47085. */
  47086. /**
  47087. * Enable or disable the render targets render time capture
  47088. */
  47089. captureRenderTargetsRenderTime: boolean;
  47090. /**
  47091. * Gets the perf counter used for particles render time
  47092. */
  47093. readonly particlesRenderTimeCounter: PerfCounter;
  47094. /**
  47095. * Gets the particles render time capture status
  47096. */
  47097. /**
  47098. * Enable or disable the particles render time capture
  47099. */
  47100. captureParticlesRenderTime: boolean;
  47101. /**
  47102. * Gets the perf counter used for sprites render time
  47103. */
  47104. readonly spritesRenderTimeCounter: PerfCounter;
  47105. /**
  47106. * Gets the sprites render time capture status
  47107. */
  47108. /**
  47109. * Enable or disable the sprites render time capture
  47110. */
  47111. captureSpritesRenderTime: boolean;
  47112. /**
  47113. * Gets the perf counter used for physics time
  47114. */
  47115. readonly physicsTimeCounter: PerfCounter;
  47116. /**
  47117. * Gets the physics time capture status
  47118. */
  47119. /**
  47120. * Enable or disable the physics time capture
  47121. */
  47122. capturePhysicsTime: boolean;
  47123. /**
  47124. * Gets the perf counter used for animations time
  47125. */
  47126. readonly animationsTimeCounter: PerfCounter;
  47127. /**
  47128. * Gets the animations time capture status
  47129. */
  47130. /**
  47131. * Enable or disable the animations time capture
  47132. */
  47133. captureAnimationsTime: boolean;
  47134. /**
  47135. * Gets the perf counter used for frame time capture
  47136. */
  47137. readonly frameTimeCounter: PerfCounter;
  47138. /**
  47139. * Gets the frame time capture status
  47140. */
  47141. /**
  47142. * Enable or disable the frame time capture
  47143. */
  47144. captureFrameTime: boolean;
  47145. /**
  47146. * Gets the perf counter used for inter-frames time capture
  47147. */
  47148. readonly interFrameTimeCounter: PerfCounter;
  47149. /**
  47150. * Gets the inter-frames time capture status
  47151. */
  47152. /**
  47153. * Enable or disable the inter-frames time capture
  47154. */
  47155. captureInterFrameTime: boolean;
  47156. /**
  47157. * Gets the perf counter used for render time capture
  47158. */
  47159. readonly renderTimeCounter: PerfCounter;
  47160. /**
  47161. * Gets the render time capture status
  47162. */
  47163. /**
  47164. * Enable or disable the render time capture
  47165. */
  47166. captureRenderTime: boolean;
  47167. /**
  47168. * Gets the perf counter used for camera render time capture
  47169. */
  47170. readonly cameraRenderTimeCounter: PerfCounter;
  47171. /**
  47172. * Gets the camera render time capture status
  47173. */
  47174. /**
  47175. * Enable or disable the camera render time capture
  47176. */
  47177. captureCameraRenderTime: boolean;
  47178. /**
  47179. * Gets the perf counter used for draw calls
  47180. */
  47181. readonly drawCallsCounter: PerfCounter;
  47182. /**
  47183. * Gets the perf counter used for texture collisions
  47184. */
  47185. readonly textureCollisionsCounter: PerfCounter;
  47186. /**
  47187. * Instantiates a new scene instrumentation.
  47188. * This class can be used to get instrumentation data from a Babylon engine
  47189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47190. * @param scene Defines the scene to instrument
  47191. */
  47192. constructor(
  47193. /**
  47194. * Defines the scene to instrument
  47195. */
  47196. scene: Scene);
  47197. /**
  47198. * Dispose and release associated resources.
  47199. */
  47200. dispose(): void;
  47201. }
  47202. }
  47203. declare module "babylonjs/Instrumentation/index" {
  47204. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47205. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47206. export * from "babylonjs/Instrumentation/timeToken";
  47207. }
  47208. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47209. /** @hidden */
  47210. export var glowMapGenerationPixelShader: {
  47211. name: string;
  47212. shader: string;
  47213. };
  47214. }
  47215. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  47216. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47217. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47218. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47219. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47220. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47221. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47222. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47223. /** @hidden */
  47224. export var glowMapGenerationVertexShader: {
  47225. name: string;
  47226. shader: string;
  47227. };
  47228. }
  47229. declare module "babylonjs/Layers/effectLayer" {
  47230. import { Observable } from "babylonjs/Misc/observable";
  47231. import { Nullable } from "babylonjs/types";
  47232. import { Camera } from "babylonjs/Cameras/camera";
  47233. import { Scene } from "babylonjs/scene";
  47234. import { Color4, ISize } from "babylonjs/Maths/math";
  47235. import { Engine } from "babylonjs/Engines/engine";
  47236. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47238. import { Mesh } from "babylonjs/Meshes/mesh";
  47239. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47240. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47241. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47242. import { Effect } from "babylonjs/Materials/effect";
  47243. import { Material } from "babylonjs/Materials/material";
  47244. import "babylonjs/Shaders/glowMapGeneration.fragment";
  47245. import "babylonjs/Shaders/glowMapGeneration.vertex";
  47246. /**
  47247. * Effect layer options. This helps customizing the behaviour
  47248. * of the effect layer.
  47249. */
  47250. export interface IEffectLayerOptions {
  47251. /**
  47252. * Multiplication factor apply to the canvas size to compute the render target size
  47253. * used to generated the objects (the smaller the faster).
  47254. */
  47255. mainTextureRatio: number;
  47256. /**
  47257. * Enforces a fixed size texture to ensure effect stability across devices.
  47258. */
  47259. mainTextureFixedSize?: number;
  47260. /**
  47261. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47262. */
  47263. alphaBlendingMode: number;
  47264. /**
  47265. * The camera attached to the layer.
  47266. */
  47267. camera: Nullable<Camera>;
  47268. /**
  47269. * The rendering group to draw the layer in.
  47270. */
  47271. renderingGroupId: number;
  47272. }
  47273. /**
  47274. * The effect layer Helps adding post process effect blended with the main pass.
  47275. *
  47276. * This can be for instance use to generate glow or higlight effects on the scene.
  47277. *
  47278. * The effect layer class can not be used directly and is intented to inherited from to be
  47279. * customized per effects.
  47280. */
  47281. export abstract class EffectLayer {
  47282. private _vertexBuffers;
  47283. private _indexBuffer;
  47284. private _cachedDefines;
  47285. private _effectLayerMapGenerationEffect;
  47286. private _effectLayerOptions;
  47287. private _mergeEffect;
  47288. protected _scene: Scene;
  47289. protected _engine: Engine;
  47290. protected _maxSize: number;
  47291. protected _mainTextureDesiredSize: ISize;
  47292. protected _mainTexture: RenderTargetTexture;
  47293. protected _shouldRender: boolean;
  47294. protected _postProcesses: PostProcess[];
  47295. protected _textures: BaseTexture[];
  47296. protected _emissiveTextureAndColor: {
  47297. texture: Nullable<BaseTexture>;
  47298. color: Color4;
  47299. };
  47300. /**
  47301. * The name of the layer
  47302. */
  47303. name: string;
  47304. /**
  47305. * The clear color of the texture used to generate the glow map.
  47306. */
  47307. neutralColor: Color4;
  47308. /**
  47309. * Specifies wether the highlight layer is enabled or not.
  47310. */
  47311. isEnabled: boolean;
  47312. /**
  47313. * Gets the camera attached to the layer.
  47314. */
  47315. readonly camera: Nullable<Camera>;
  47316. /**
  47317. * Gets the rendering group id the layer should render in.
  47318. */
  47319. readonly renderingGroupId: number;
  47320. /**
  47321. * An event triggered when the effect layer has been disposed.
  47322. */
  47323. onDisposeObservable: Observable<EffectLayer>;
  47324. /**
  47325. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47326. */
  47327. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47328. /**
  47329. * An event triggered when the generated texture is being merged in the scene.
  47330. */
  47331. onBeforeComposeObservable: Observable<EffectLayer>;
  47332. /**
  47333. * An event triggered when the generated texture has been merged in the scene.
  47334. */
  47335. onAfterComposeObservable: Observable<EffectLayer>;
  47336. /**
  47337. * An event triggered when the efffect layer changes its size.
  47338. */
  47339. onSizeChangedObservable: Observable<EffectLayer>;
  47340. /** @hidden */
  47341. static _SceneComponentInitialization: (scene: Scene) => void;
  47342. /**
  47343. * Instantiates a new effect Layer and references it in the scene.
  47344. * @param name The name of the layer
  47345. * @param scene The scene to use the layer in
  47346. */
  47347. constructor(
  47348. /** The Friendly of the effect in the scene */
  47349. name: string, scene: Scene);
  47350. /**
  47351. * Get the effect name of the layer.
  47352. * @return The effect name
  47353. */
  47354. abstract getEffectName(): string;
  47355. /**
  47356. * Checks for the readiness of the element composing the layer.
  47357. * @param subMesh the mesh to check for
  47358. * @param useInstances specify wether or not to use instances to render the mesh
  47359. * @return true if ready otherwise, false
  47360. */
  47361. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47362. /**
  47363. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47364. * @returns true if the effect requires stencil during the main canvas render pass.
  47365. */
  47366. abstract needStencil(): boolean;
  47367. /**
  47368. * Create the merge effect. This is the shader use to blit the information back
  47369. * to the main canvas at the end of the scene rendering.
  47370. * @returns The effect containing the shader used to merge the effect on the main canvas
  47371. */
  47372. protected abstract _createMergeEffect(): Effect;
  47373. /**
  47374. * Creates the render target textures and post processes used in the effect layer.
  47375. */
  47376. protected abstract _createTextureAndPostProcesses(): void;
  47377. /**
  47378. * Implementation specific of rendering the generating effect on the main canvas.
  47379. * @param effect The effect used to render through
  47380. */
  47381. protected abstract _internalRender(effect: Effect): void;
  47382. /**
  47383. * Sets the required values for both the emissive texture and and the main color.
  47384. */
  47385. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47386. /**
  47387. * Free any resources and references associated to a mesh.
  47388. * Internal use
  47389. * @param mesh The mesh to free.
  47390. */
  47391. abstract _disposeMesh(mesh: Mesh): void;
  47392. /**
  47393. * Serializes this layer (Glow or Highlight for example)
  47394. * @returns a serialized layer object
  47395. */
  47396. abstract serialize?(): any;
  47397. /**
  47398. * Initializes the effect layer with the required options.
  47399. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47400. */
  47401. protected _init(options: Partial<IEffectLayerOptions>): void;
  47402. /**
  47403. * Generates the index buffer of the full screen quad blending to the main canvas.
  47404. */
  47405. private _generateIndexBuffer;
  47406. /**
  47407. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47408. */
  47409. private _genrateVertexBuffer;
  47410. /**
  47411. * Sets the main texture desired size which is the closest power of two
  47412. * of the engine canvas size.
  47413. */
  47414. private _setMainTextureSize;
  47415. /**
  47416. * Creates the main texture for the effect layer.
  47417. */
  47418. protected _createMainTexture(): void;
  47419. /**
  47420. * Adds specific effects defines.
  47421. * @param defines The defines to add specifics to.
  47422. */
  47423. protected _addCustomEffectDefines(defines: string[]): void;
  47424. /**
  47425. * Checks for the readiness of the element composing the layer.
  47426. * @param subMesh the mesh to check for
  47427. * @param useInstances specify wether or not to use instances to render the mesh
  47428. * @param emissiveTexture the associated emissive texture used to generate the glow
  47429. * @return true if ready otherwise, false
  47430. */
  47431. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47432. /**
  47433. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47434. */
  47435. render(): void;
  47436. /**
  47437. * Determine if a given mesh will be used in the current effect.
  47438. * @param mesh mesh to test
  47439. * @returns true if the mesh will be used
  47440. */
  47441. hasMesh(mesh: AbstractMesh): boolean;
  47442. /**
  47443. * Returns true if the layer contains information to display, otherwise false.
  47444. * @returns true if the glow layer should be rendered
  47445. */
  47446. shouldRender(): boolean;
  47447. /**
  47448. * Returns true if the mesh should render, otherwise false.
  47449. * @param mesh The mesh to render
  47450. * @returns true if it should render otherwise false
  47451. */
  47452. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47453. /**
  47454. * Returns true if the mesh can be rendered, otherwise false.
  47455. * @param mesh The mesh to render
  47456. * @param material The material used on the mesh
  47457. * @returns true if it can be rendered otherwise false
  47458. */
  47459. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47460. /**
  47461. * Returns true if the mesh should render, otherwise false.
  47462. * @param mesh The mesh to render
  47463. * @returns true if it should render otherwise false
  47464. */
  47465. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47466. /**
  47467. * Renders the submesh passed in parameter to the generation map.
  47468. */
  47469. protected _renderSubMesh(subMesh: SubMesh): void;
  47470. /**
  47471. * Rebuild the required buffers.
  47472. * @hidden Internal use only.
  47473. */
  47474. _rebuild(): void;
  47475. /**
  47476. * Dispose only the render target textures and post process.
  47477. */
  47478. private _disposeTextureAndPostProcesses;
  47479. /**
  47480. * Dispose the highlight layer and free resources.
  47481. */
  47482. dispose(): void;
  47483. /**
  47484. * Gets the class name of the effect layer
  47485. * @returns the string with the class name of the effect layer
  47486. */
  47487. getClassName(): string;
  47488. /**
  47489. * Creates an effect layer from parsed effect layer data
  47490. * @param parsedEffectLayer defines effect layer data
  47491. * @param scene defines the current scene
  47492. * @param rootUrl defines the root URL containing the effect layer information
  47493. * @returns a parsed effect Layer
  47494. */
  47495. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47496. }
  47497. }
  47498. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47499. import { Scene } from "babylonjs/scene";
  47500. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47501. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47502. import { AbstractScene } from "babylonjs/abstractScene";
  47503. module "babylonjs/abstractScene" {
  47504. interface AbstractScene {
  47505. /**
  47506. * The list of effect layers (highlights/glow) added to the scene
  47507. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47508. * @see http://doc.babylonjs.com/how_to/glow_layer
  47509. */
  47510. effectLayers: Array<EffectLayer>;
  47511. /**
  47512. * Removes the given effect layer from this scene.
  47513. * @param toRemove defines the effect layer to remove
  47514. * @returns the index of the removed effect layer
  47515. */
  47516. removeEffectLayer(toRemove: EffectLayer): number;
  47517. /**
  47518. * Adds the given effect layer to this scene
  47519. * @param newEffectLayer defines the effect layer to add
  47520. */
  47521. addEffectLayer(newEffectLayer: EffectLayer): void;
  47522. }
  47523. }
  47524. /**
  47525. * Defines the layer scene component responsible to manage any effect layers
  47526. * in a given scene.
  47527. */
  47528. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47529. /**
  47530. * The component name helpfull to identify the component in the list of scene components.
  47531. */
  47532. readonly name: string;
  47533. /**
  47534. * The scene the component belongs to.
  47535. */
  47536. scene: Scene;
  47537. private _engine;
  47538. private _renderEffects;
  47539. private _needStencil;
  47540. private _previousStencilState;
  47541. /**
  47542. * Creates a new instance of the component for the given scene
  47543. * @param scene Defines the scene to register the component in
  47544. */
  47545. constructor(scene: Scene);
  47546. /**
  47547. * Registers the component in a given scene
  47548. */
  47549. register(): void;
  47550. /**
  47551. * Rebuilds the elements related to this component in case of
  47552. * context lost for instance.
  47553. */
  47554. rebuild(): void;
  47555. /**
  47556. * Serializes the component data to the specified json object
  47557. * @param serializationObject The object to serialize to
  47558. */
  47559. serialize(serializationObject: any): void;
  47560. /**
  47561. * Adds all the element from the container to the scene
  47562. * @param container the container holding the elements
  47563. */
  47564. addFromContainer(container: AbstractScene): void;
  47565. /**
  47566. * Removes all the elements in the container from the scene
  47567. * @param container contains the elements to remove
  47568. */
  47569. removeFromContainer(container: AbstractScene): void;
  47570. /**
  47571. * Disposes the component and the associated ressources.
  47572. */
  47573. dispose(): void;
  47574. private _isReadyForMesh;
  47575. private _renderMainTexture;
  47576. private _setStencil;
  47577. private _setStencilBack;
  47578. private _draw;
  47579. private _drawCamera;
  47580. private _drawRenderingGroup;
  47581. }
  47582. }
  47583. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47584. /** @hidden */
  47585. export var glowMapMergePixelShader: {
  47586. name: string;
  47587. shader: string;
  47588. };
  47589. }
  47590. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47591. /** @hidden */
  47592. export var glowMapMergeVertexShader: {
  47593. name: string;
  47594. shader: string;
  47595. };
  47596. }
  47597. declare module "babylonjs/Layers/glowLayer" {
  47598. import { Nullable } from "babylonjs/types";
  47599. import { Camera } from "babylonjs/Cameras/camera";
  47600. import { Scene } from "babylonjs/scene";
  47601. import { Color4 } from "babylonjs/Maths/math";
  47602. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47604. import { Mesh } from "babylonjs/Meshes/mesh";
  47605. import { Texture } from "babylonjs/Materials/Textures/texture";
  47606. import { Effect } from "babylonjs/Materials/effect";
  47607. import { Material } from "babylonjs/Materials/material";
  47608. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47609. import "babylonjs/Shaders/glowMapMerge.fragment";
  47610. import "babylonjs/Shaders/glowMapMerge.vertex";
  47611. import "babylonjs/Layers/effectLayerSceneComponent";
  47612. module "babylonjs/abstractScene" {
  47613. interface AbstractScene {
  47614. /**
  47615. * Return a the first highlight layer of the scene with a given name.
  47616. * @param name The name of the highlight layer to look for.
  47617. * @return The highlight layer if found otherwise null.
  47618. */
  47619. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47620. }
  47621. }
  47622. /**
  47623. * Glow layer options. This helps customizing the behaviour
  47624. * of the glow layer.
  47625. */
  47626. export interface IGlowLayerOptions {
  47627. /**
  47628. * Multiplication factor apply to the canvas size to compute the render target size
  47629. * used to generated the glowing objects (the smaller the faster).
  47630. */
  47631. mainTextureRatio: number;
  47632. /**
  47633. * Enforces a fixed size texture to ensure resize independant blur.
  47634. */
  47635. mainTextureFixedSize?: number;
  47636. /**
  47637. * How big is the kernel of the blur texture.
  47638. */
  47639. blurKernelSize: number;
  47640. /**
  47641. * The camera attached to the layer.
  47642. */
  47643. camera: Nullable<Camera>;
  47644. /**
  47645. * Enable MSAA by chosing the number of samples.
  47646. */
  47647. mainTextureSamples?: number;
  47648. /**
  47649. * The rendering group to draw the layer in.
  47650. */
  47651. renderingGroupId: number;
  47652. }
  47653. /**
  47654. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47655. *
  47656. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47657. * glowy meshes to your scene.
  47658. *
  47659. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47660. */
  47661. export class GlowLayer extends EffectLayer {
  47662. /**
  47663. * Effect Name of the layer.
  47664. */
  47665. static readonly EffectName: string;
  47666. /**
  47667. * The default blur kernel size used for the glow.
  47668. */
  47669. static DefaultBlurKernelSize: number;
  47670. /**
  47671. * The default texture size ratio used for the glow.
  47672. */
  47673. static DefaultTextureRatio: number;
  47674. /**
  47675. * Sets the kernel size of the blur.
  47676. */
  47677. /**
  47678. * Gets the kernel size of the blur.
  47679. */
  47680. blurKernelSize: number;
  47681. /**
  47682. * Sets the glow intensity.
  47683. */
  47684. /**
  47685. * Gets the glow intensity.
  47686. */
  47687. intensity: number;
  47688. private _options;
  47689. private _intensity;
  47690. private _horizontalBlurPostprocess1;
  47691. private _verticalBlurPostprocess1;
  47692. private _horizontalBlurPostprocess2;
  47693. private _verticalBlurPostprocess2;
  47694. private _blurTexture1;
  47695. private _blurTexture2;
  47696. private _postProcesses1;
  47697. private _postProcesses2;
  47698. private _includedOnlyMeshes;
  47699. private _excludedMeshes;
  47700. /**
  47701. * Callback used to let the user override the color selection on a per mesh basis
  47702. */
  47703. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47704. /**
  47705. * Callback used to let the user override the texture selection on a per mesh basis
  47706. */
  47707. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47708. /**
  47709. * Instantiates a new glow Layer and references it to the scene.
  47710. * @param name The name of the layer
  47711. * @param scene The scene to use the layer in
  47712. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47713. */
  47714. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47715. /**
  47716. * Get the effect name of the layer.
  47717. * @return The effect name
  47718. */
  47719. getEffectName(): string;
  47720. /**
  47721. * Create the merge effect. This is the shader use to blit the information back
  47722. * to the main canvas at the end of the scene rendering.
  47723. */
  47724. protected _createMergeEffect(): Effect;
  47725. /**
  47726. * Creates the render target textures and post processes used in the glow layer.
  47727. */
  47728. protected _createTextureAndPostProcesses(): void;
  47729. /**
  47730. * Checks for the readiness of the element composing the layer.
  47731. * @param subMesh the mesh to check for
  47732. * @param useInstances specify wether or not to use instances to render the mesh
  47733. * @param emissiveTexture the associated emissive texture used to generate the glow
  47734. * @return true if ready otherwise, false
  47735. */
  47736. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47737. /**
  47738. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47739. */
  47740. needStencil(): boolean;
  47741. /**
  47742. * Returns true if the mesh can be rendered, otherwise false.
  47743. * @param mesh The mesh to render
  47744. * @param material The material used on the mesh
  47745. * @returns true if it can be rendered otherwise false
  47746. */
  47747. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47748. /**
  47749. * Implementation specific of rendering the generating effect on the main canvas.
  47750. * @param effect The effect used to render through
  47751. */
  47752. protected _internalRender(effect: Effect): void;
  47753. /**
  47754. * Sets the required values for both the emissive texture and and the main color.
  47755. */
  47756. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47757. /**
  47758. * Returns true if the mesh should render, otherwise false.
  47759. * @param mesh The mesh to render
  47760. * @returns true if it should render otherwise false
  47761. */
  47762. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47763. /**
  47764. * Adds specific effects defines.
  47765. * @param defines The defines to add specifics to.
  47766. */
  47767. protected _addCustomEffectDefines(defines: string[]): void;
  47768. /**
  47769. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47770. * @param mesh The mesh to exclude from the glow layer
  47771. */
  47772. addExcludedMesh(mesh: Mesh): void;
  47773. /**
  47774. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47775. * @param mesh The mesh to remove
  47776. */
  47777. removeExcludedMesh(mesh: Mesh): void;
  47778. /**
  47779. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47780. * @param mesh The mesh to include in the glow layer
  47781. */
  47782. addIncludedOnlyMesh(mesh: Mesh): void;
  47783. /**
  47784. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47785. * @param mesh The mesh to remove
  47786. */
  47787. removeIncludedOnlyMesh(mesh: Mesh): void;
  47788. /**
  47789. * Determine if a given mesh will be used in the glow layer
  47790. * @param mesh The mesh to test
  47791. * @returns true if the mesh will be highlighted by the current glow layer
  47792. */
  47793. hasMesh(mesh: AbstractMesh): boolean;
  47794. /**
  47795. * Free any resources and references associated to a mesh.
  47796. * Internal use
  47797. * @param mesh The mesh to free.
  47798. * @hidden
  47799. */
  47800. _disposeMesh(mesh: Mesh): void;
  47801. /**
  47802. * Gets the class name of the effect layer
  47803. * @returns the string with the class name of the effect layer
  47804. */
  47805. getClassName(): string;
  47806. /**
  47807. * Serializes this glow layer
  47808. * @returns a serialized glow layer object
  47809. */
  47810. serialize(): any;
  47811. /**
  47812. * Creates a Glow Layer from parsed glow layer data
  47813. * @param parsedGlowLayer defines glow layer data
  47814. * @param scene defines the current scene
  47815. * @param rootUrl defines the root URL containing the glow layer information
  47816. * @returns a parsed Glow Layer
  47817. */
  47818. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47819. }
  47820. }
  47821. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47822. /** @hidden */
  47823. export var glowBlurPostProcessPixelShader: {
  47824. name: string;
  47825. shader: string;
  47826. };
  47827. }
  47828. declare module "babylonjs/Layers/highlightLayer" {
  47829. import { Observable } from "babylonjs/Misc/observable";
  47830. import { Nullable } from "babylonjs/types";
  47831. import { Camera } from "babylonjs/Cameras/camera";
  47832. import { Scene } from "babylonjs/scene";
  47833. import { Color3, Color4 } from "babylonjs/Maths/math";
  47834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47836. import { Mesh } from "babylonjs/Meshes/mesh";
  47837. import { Effect } from "babylonjs/Materials/effect";
  47838. import { Material } from "babylonjs/Materials/material";
  47839. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47840. import "babylonjs/Shaders/glowMapMerge.fragment";
  47841. import "babylonjs/Shaders/glowMapMerge.vertex";
  47842. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47843. module "babylonjs/abstractScene" {
  47844. interface AbstractScene {
  47845. /**
  47846. * Return a the first highlight layer of the scene with a given name.
  47847. * @param name The name of the highlight layer to look for.
  47848. * @return The highlight layer if found otherwise null.
  47849. */
  47850. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47851. }
  47852. }
  47853. /**
  47854. * Highlight layer options. This helps customizing the behaviour
  47855. * of the highlight layer.
  47856. */
  47857. export interface IHighlightLayerOptions {
  47858. /**
  47859. * Multiplication factor apply to the canvas size to compute the render target size
  47860. * used to generated the glowing objects (the smaller the faster).
  47861. */
  47862. mainTextureRatio: number;
  47863. /**
  47864. * Enforces a fixed size texture to ensure resize independant blur.
  47865. */
  47866. mainTextureFixedSize?: number;
  47867. /**
  47868. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47869. * of the picture to blur (the smaller the faster).
  47870. */
  47871. blurTextureSizeRatio: number;
  47872. /**
  47873. * How big in texel of the blur texture is the vertical blur.
  47874. */
  47875. blurVerticalSize: number;
  47876. /**
  47877. * How big in texel of the blur texture is the horizontal blur.
  47878. */
  47879. blurHorizontalSize: number;
  47880. /**
  47881. * Alpha blending mode used to apply the blur. Default is combine.
  47882. */
  47883. alphaBlendingMode: number;
  47884. /**
  47885. * The camera attached to the layer.
  47886. */
  47887. camera: Nullable<Camera>;
  47888. /**
  47889. * Should we display highlight as a solid stroke?
  47890. */
  47891. isStroke?: boolean;
  47892. /**
  47893. * The rendering group to draw the layer in.
  47894. */
  47895. renderingGroupId: number;
  47896. }
  47897. /**
  47898. * The highlight layer Helps adding a glow effect around a mesh.
  47899. *
  47900. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47901. * glowy meshes to your scene.
  47902. *
  47903. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47904. */
  47905. export class HighlightLayer extends EffectLayer {
  47906. name: string;
  47907. /**
  47908. * Effect Name of the highlight layer.
  47909. */
  47910. static readonly EffectName: string;
  47911. /**
  47912. * The neutral color used during the preparation of the glow effect.
  47913. * This is black by default as the blend operation is a blend operation.
  47914. */
  47915. static NeutralColor: Color4;
  47916. /**
  47917. * Stencil value used for glowing meshes.
  47918. */
  47919. static GlowingMeshStencilReference: number;
  47920. /**
  47921. * Stencil value used for the other meshes in the scene.
  47922. */
  47923. static NormalMeshStencilReference: number;
  47924. /**
  47925. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47926. */
  47927. innerGlow: boolean;
  47928. /**
  47929. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47930. */
  47931. outerGlow: boolean;
  47932. /**
  47933. * Specifies the horizontal size of the blur.
  47934. */
  47935. /**
  47936. * Gets the horizontal size of the blur.
  47937. */
  47938. blurHorizontalSize: number;
  47939. /**
  47940. * Specifies the vertical size of the blur.
  47941. */
  47942. /**
  47943. * Gets the vertical size of the blur.
  47944. */
  47945. blurVerticalSize: number;
  47946. /**
  47947. * An event triggered when the highlight layer is being blurred.
  47948. */
  47949. onBeforeBlurObservable: Observable<HighlightLayer>;
  47950. /**
  47951. * An event triggered when the highlight layer has been blurred.
  47952. */
  47953. onAfterBlurObservable: Observable<HighlightLayer>;
  47954. private _instanceGlowingMeshStencilReference;
  47955. private _options;
  47956. private _downSamplePostprocess;
  47957. private _horizontalBlurPostprocess;
  47958. private _verticalBlurPostprocess;
  47959. private _blurTexture;
  47960. private _meshes;
  47961. private _excludedMeshes;
  47962. /**
  47963. * Instantiates a new highlight Layer and references it to the scene..
  47964. * @param name The name of the layer
  47965. * @param scene The scene to use the layer in
  47966. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47967. */
  47968. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47969. /**
  47970. * Get the effect name of the layer.
  47971. * @return The effect name
  47972. */
  47973. getEffectName(): string;
  47974. /**
  47975. * Create the merge effect. This is the shader use to blit the information back
  47976. * to the main canvas at the end of the scene rendering.
  47977. */
  47978. protected _createMergeEffect(): Effect;
  47979. /**
  47980. * Creates the render target textures and post processes used in the highlight layer.
  47981. */
  47982. protected _createTextureAndPostProcesses(): void;
  47983. /**
  47984. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47985. */
  47986. needStencil(): boolean;
  47987. /**
  47988. * Checks for the readiness of the element composing the layer.
  47989. * @param subMesh the mesh to check for
  47990. * @param useInstances specify wether or not to use instances to render the mesh
  47991. * @param emissiveTexture the associated emissive texture used to generate the glow
  47992. * @return true if ready otherwise, false
  47993. */
  47994. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47995. /**
  47996. * Implementation specific of rendering the generating effect on the main canvas.
  47997. * @param effect The effect used to render through
  47998. */
  47999. protected _internalRender(effect: Effect): void;
  48000. /**
  48001. * Returns true if the layer contains information to display, otherwise false.
  48002. */
  48003. shouldRender(): boolean;
  48004. /**
  48005. * Returns true if the mesh should render, otherwise false.
  48006. * @param mesh The mesh to render
  48007. * @returns true if it should render otherwise false
  48008. */
  48009. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48010. /**
  48011. * Sets the required values for both the emissive texture and and the main color.
  48012. */
  48013. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48014. /**
  48015. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48016. * @param mesh The mesh to exclude from the highlight layer
  48017. */
  48018. addExcludedMesh(mesh: Mesh): void;
  48019. /**
  48020. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48021. * @param mesh The mesh to highlight
  48022. */
  48023. removeExcludedMesh(mesh: Mesh): void;
  48024. /**
  48025. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48026. * @param mesh mesh to test
  48027. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48028. */
  48029. hasMesh(mesh: AbstractMesh): boolean;
  48030. /**
  48031. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48032. * @param mesh The mesh to highlight
  48033. * @param color The color of the highlight
  48034. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48035. */
  48036. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48037. /**
  48038. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48039. * @param mesh The mesh to highlight
  48040. */
  48041. removeMesh(mesh: Mesh): void;
  48042. /**
  48043. * Force the stencil to the normal expected value for none glowing parts
  48044. */
  48045. private _defaultStencilReference;
  48046. /**
  48047. * Free any resources and references associated to a mesh.
  48048. * Internal use
  48049. * @param mesh The mesh to free.
  48050. * @hidden
  48051. */
  48052. _disposeMesh(mesh: Mesh): void;
  48053. /**
  48054. * Dispose the highlight layer and free resources.
  48055. */
  48056. dispose(): void;
  48057. /**
  48058. * Gets the class name of the effect layer
  48059. * @returns the string with the class name of the effect layer
  48060. */
  48061. getClassName(): string;
  48062. /**
  48063. * Serializes this Highlight layer
  48064. * @returns a serialized Highlight layer object
  48065. */
  48066. serialize(): any;
  48067. /**
  48068. * Creates a Highlight layer from parsed Highlight layer data
  48069. * @param parsedHightlightLayer defines the Highlight layer data
  48070. * @param scene defines the current scene
  48071. * @param rootUrl defines the root URL containing the Highlight layer information
  48072. * @returns a parsed Highlight layer
  48073. */
  48074. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48075. }
  48076. }
  48077. declare module "babylonjs/Layers/index" {
  48078. export * from "babylonjs/Layers/effectLayer";
  48079. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48080. export * from "babylonjs/Layers/glowLayer";
  48081. export * from "babylonjs/Layers/highlightLayer";
  48082. export * from "babylonjs/Layers/layer";
  48083. export * from "babylonjs/Layers/layerSceneComponent";
  48084. }
  48085. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48086. /** @hidden */
  48087. export var lensFlarePixelShader: {
  48088. name: string;
  48089. shader: string;
  48090. };
  48091. }
  48092. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48093. /** @hidden */
  48094. export var lensFlareVertexShader: {
  48095. name: string;
  48096. shader: string;
  48097. };
  48098. }
  48099. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48100. import { Scene } from "babylonjs/scene";
  48101. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48103. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48104. import "babylonjs/Shaders/lensFlare.fragment";
  48105. import "babylonjs/Shaders/lensFlare.vertex";
  48106. /**
  48107. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48108. * It is usually composed of several `lensFlare`.
  48109. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48110. */
  48111. export class LensFlareSystem {
  48112. /**
  48113. * Define the name of the lens flare system
  48114. */
  48115. name: string;
  48116. /**
  48117. * List of lens flares used in this system.
  48118. */
  48119. lensFlares: LensFlare[];
  48120. /**
  48121. * Define a limit from the border the lens flare can be visible.
  48122. */
  48123. borderLimit: number;
  48124. /**
  48125. * Define a viewport border we do not want to see the lens flare in.
  48126. */
  48127. viewportBorder: number;
  48128. /**
  48129. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48130. */
  48131. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48132. /**
  48133. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48134. */
  48135. layerMask: number;
  48136. /**
  48137. * Define the id of the lens flare system in the scene.
  48138. * (equal to name by default)
  48139. */
  48140. id: string;
  48141. private _scene;
  48142. private _emitter;
  48143. private _vertexBuffers;
  48144. private _indexBuffer;
  48145. private _effect;
  48146. private _positionX;
  48147. private _positionY;
  48148. private _isEnabled;
  48149. /** @hidden */
  48150. static _SceneComponentInitialization: (scene: Scene) => void;
  48151. /**
  48152. * Instantiates a lens flare system.
  48153. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48154. * It is usually composed of several `lensFlare`.
  48155. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48156. * @param name Define the name of the lens flare system in the scene
  48157. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48158. * @param scene Define the scene the lens flare system belongs to
  48159. */
  48160. constructor(
  48161. /**
  48162. * Define the name of the lens flare system
  48163. */
  48164. name: string, emitter: any, scene: Scene);
  48165. /**
  48166. * Define if the lens flare system is enabled.
  48167. */
  48168. isEnabled: boolean;
  48169. /**
  48170. * Get the scene the effects belongs to.
  48171. * @returns the scene holding the lens flare system
  48172. */
  48173. getScene(): Scene;
  48174. /**
  48175. * Get the emitter of the lens flare system.
  48176. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48177. * @returns the emitter of the lens flare system
  48178. */
  48179. getEmitter(): any;
  48180. /**
  48181. * Set the emitter of the lens flare system.
  48182. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48183. * @param newEmitter Define the new emitter of the system
  48184. */
  48185. setEmitter(newEmitter: any): void;
  48186. /**
  48187. * Get the lens flare system emitter position.
  48188. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48189. * @returns the position
  48190. */
  48191. getEmitterPosition(): Vector3;
  48192. /**
  48193. * @hidden
  48194. */
  48195. computeEffectivePosition(globalViewport: Viewport): boolean;
  48196. /** @hidden */
  48197. _isVisible(): boolean;
  48198. /**
  48199. * @hidden
  48200. */
  48201. render(): boolean;
  48202. /**
  48203. * Dispose and release the lens flare with its associated resources.
  48204. */
  48205. dispose(): void;
  48206. /**
  48207. * Parse a lens flare system from a JSON repressentation
  48208. * @param parsedLensFlareSystem Define the JSON to parse
  48209. * @param scene Define the scene the parsed system should be instantiated in
  48210. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48211. * @returns the parsed system
  48212. */
  48213. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48214. /**
  48215. * Serialize the current Lens Flare System into a JSON representation.
  48216. * @returns the serialized JSON
  48217. */
  48218. serialize(): any;
  48219. }
  48220. }
  48221. declare module "babylonjs/LensFlares/lensFlare" {
  48222. import { Nullable } from "babylonjs/types";
  48223. import { Color3 } from "babylonjs/Maths/math";
  48224. import { Texture } from "babylonjs/Materials/Textures/texture";
  48225. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48226. /**
  48227. * This represents one of the lens effect in a `lensFlareSystem`.
  48228. * It controls one of the indiviual texture used in the effect.
  48229. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48230. */
  48231. export class LensFlare {
  48232. /**
  48233. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48234. */
  48235. size: number;
  48236. /**
  48237. * 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.
  48238. */
  48239. position: number;
  48240. /**
  48241. * Define the lens color.
  48242. */
  48243. color: Color3;
  48244. /**
  48245. * Define the lens texture.
  48246. */
  48247. texture: Nullable<Texture>;
  48248. /**
  48249. * Define the alpha mode to render this particular lens.
  48250. */
  48251. alphaMode: number;
  48252. private _system;
  48253. /**
  48254. * Creates a new Lens Flare.
  48255. * This represents one of the lens effect in a `lensFlareSystem`.
  48256. * It controls one of the indiviual texture used in the effect.
  48257. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48258. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48259. * @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.
  48260. * @param color Define the lens color
  48261. * @param imgUrl Define the lens texture url
  48262. * @param system Define the `lensFlareSystem` this flare is part of
  48263. * @returns The newly created Lens Flare
  48264. */
  48265. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48266. /**
  48267. * Instantiates a new Lens Flare.
  48268. * This represents one of the lens effect in a `lensFlareSystem`.
  48269. * It controls one of the indiviual texture used in the effect.
  48270. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48271. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48272. * @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.
  48273. * @param color Define the lens color
  48274. * @param imgUrl Define the lens texture url
  48275. * @param system Define the `lensFlareSystem` this flare is part of
  48276. */
  48277. constructor(
  48278. /**
  48279. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48280. */
  48281. size: number,
  48282. /**
  48283. * 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.
  48284. */
  48285. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48286. /**
  48287. * Dispose and release the lens flare with its associated resources.
  48288. */
  48289. dispose(): void;
  48290. }
  48291. }
  48292. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  48293. import { Nullable } from "babylonjs/types";
  48294. import { Scene } from "babylonjs/scene";
  48295. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48296. import { AbstractScene } from "babylonjs/abstractScene";
  48297. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48298. module "babylonjs/abstractScene" {
  48299. interface AbstractScene {
  48300. /**
  48301. * The list of lens flare system added to the scene
  48302. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48303. */
  48304. lensFlareSystems: Array<LensFlareSystem>;
  48305. /**
  48306. * Removes the given lens flare system from this scene.
  48307. * @param toRemove The lens flare system to remove
  48308. * @returns The index of the removed lens flare system
  48309. */
  48310. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48311. /**
  48312. * Adds the given lens flare system to this scene
  48313. * @param newLensFlareSystem The lens flare system to add
  48314. */
  48315. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48316. /**
  48317. * Gets a lens flare system using its name
  48318. * @param name defines the name to look for
  48319. * @returns the lens flare system or null if not found
  48320. */
  48321. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48322. /**
  48323. * Gets a lens flare system using its id
  48324. * @param id defines the id to look for
  48325. * @returns the lens flare system or null if not found
  48326. */
  48327. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48328. }
  48329. }
  48330. /**
  48331. * Defines the lens flare scene component responsible to manage any lens flares
  48332. * in a given scene.
  48333. */
  48334. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48335. /**
  48336. * The component name helpfull to identify the component in the list of scene components.
  48337. */
  48338. readonly name: string;
  48339. /**
  48340. * The scene the component belongs to.
  48341. */
  48342. scene: Scene;
  48343. /**
  48344. * Creates a new instance of the component for the given scene
  48345. * @param scene Defines the scene to register the component in
  48346. */
  48347. constructor(scene: Scene);
  48348. /**
  48349. * Registers the component in a given scene
  48350. */
  48351. register(): void;
  48352. /**
  48353. * Rebuilds the elements related to this component in case of
  48354. * context lost for instance.
  48355. */
  48356. rebuild(): void;
  48357. /**
  48358. * Adds all the element from the container to the scene
  48359. * @param container the container holding the elements
  48360. */
  48361. addFromContainer(container: AbstractScene): void;
  48362. /**
  48363. * Removes all the elements in the container from the scene
  48364. * @param container contains the elements to remove
  48365. */
  48366. removeFromContainer(container: AbstractScene): void;
  48367. /**
  48368. * Serializes the component data to the specified json object
  48369. * @param serializationObject The object to serialize to
  48370. */
  48371. serialize(serializationObject: any): void;
  48372. /**
  48373. * Disposes the component and the associated ressources.
  48374. */
  48375. dispose(): void;
  48376. private _draw;
  48377. }
  48378. }
  48379. declare module "babylonjs/LensFlares/index" {
  48380. export * from "babylonjs/LensFlares/lensFlare";
  48381. export * from "babylonjs/LensFlares/lensFlareSystem";
  48382. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48383. }
  48384. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48385. import { Scene } from "babylonjs/scene";
  48386. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48387. import { AbstractScene } from "babylonjs/abstractScene";
  48388. /**
  48389. * Defines the shadow generator component responsible to manage any shadow generators
  48390. * in a given scene.
  48391. */
  48392. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48393. /**
  48394. * The component name helpfull to identify the component in the list of scene components.
  48395. */
  48396. readonly name: string;
  48397. /**
  48398. * The scene the component belongs to.
  48399. */
  48400. scene: Scene;
  48401. /**
  48402. * Creates a new instance of the component for the given scene
  48403. * @param scene Defines the scene to register the component in
  48404. */
  48405. constructor(scene: Scene);
  48406. /**
  48407. * Registers the component in a given scene
  48408. */
  48409. register(): void;
  48410. /**
  48411. * Rebuilds the elements related to this component in case of
  48412. * context lost for instance.
  48413. */
  48414. rebuild(): 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. * Adds all the element from the container to the scene
  48422. * @param container the container holding the elements
  48423. */
  48424. addFromContainer(container: AbstractScene): void;
  48425. /**
  48426. * Removes all the elements in the container from the scene
  48427. * @param container contains the elements to remove
  48428. */
  48429. removeFromContainer(container: AbstractScene): void;
  48430. /**
  48431. * Rebuilds the elements related to this component in case of
  48432. * context lost for instance.
  48433. */
  48434. dispose(): void;
  48435. private _gatherRenderTargets;
  48436. }
  48437. }
  48438. declare module "babylonjs/Lights/Shadows/index" {
  48439. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48440. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48441. }
  48442. declare module "babylonjs/Lights/directionalLight" {
  48443. import { Camera } from "babylonjs/Cameras/camera";
  48444. import { Scene } from "babylonjs/scene";
  48445. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48447. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48448. import { Effect } from "babylonjs/Materials/effect";
  48449. /**
  48450. * A directional light is defined by a direction (what a surprise!).
  48451. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48452. * 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.
  48453. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48454. */
  48455. export class DirectionalLight extends ShadowLight {
  48456. private _shadowFrustumSize;
  48457. /**
  48458. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48459. */
  48460. /**
  48461. * Specifies a fix frustum size for the shadow generation.
  48462. */
  48463. shadowFrustumSize: number;
  48464. private _shadowOrthoScale;
  48465. /**
  48466. * Gets the shadow projection scale against the optimal computed one.
  48467. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48468. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48469. */
  48470. /**
  48471. * Sets the shadow projection scale against the optimal computed one.
  48472. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48473. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48474. */
  48475. shadowOrthoScale: number;
  48476. /**
  48477. * Automatically compute the projection matrix to best fit (including all the casters)
  48478. * on each frame.
  48479. */
  48480. autoUpdateExtends: boolean;
  48481. private _orthoLeft;
  48482. private _orthoRight;
  48483. private _orthoTop;
  48484. private _orthoBottom;
  48485. /**
  48486. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48487. * The directional light is emitted from everywhere in the given direction.
  48488. * It can cast shadows.
  48489. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48490. * @param name The friendly name of the light
  48491. * @param direction The direction of the light
  48492. * @param scene The scene the light belongs to
  48493. */
  48494. constructor(name: string, direction: Vector3, scene: Scene);
  48495. /**
  48496. * Returns the string "DirectionalLight".
  48497. * @return The class name
  48498. */
  48499. getClassName(): string;
  48500. /**
  48501. * Returns the integer 1.
  48502. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48503. */
  48504. getTypeID(): number;
  48505. /**
  48506. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48507. * Returns the DirectionalLight Shadow projection matrix.
  48508. */
  48509. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48510. /**
  48511. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48512. * Returns the DirectionalLight Shadow projection matrix.
  48513. */
  48514. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48515. /**
  48516. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48517. * Returns the DirectionalLight Shadow projection matrix.
  48518. */
  48519. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48520. protected _buildUniformLayout(): void;
  48521. /**
  48522. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48523. * @param effect The effect to update
  48524. * @param lightIndex The index of the light in the effect to update
  48525. * @returns The directional light
  48526. */
  48527. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48528. /**
  48529. * Gets the minZ used for shadow according to both the scene and the light.
  48530. *
  48531. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48532. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48533. * @param activeCamera The camera we are returning the min for
  48534. * @returns the depth min z
  48535. */
  48536. getDepthMinZ(activeCamera: Camera): number;
  48537. /**
  48538. * Gets the maxZ used for shadow according to both the scene and the light.
  48539. *
  48540. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48541. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48542. * @param activeCamera The camera we are returning the max for
  48543. * @returns the depth max z
  48544. */
  48545. getDepthMaxZ(activeCamera: Camera): number;
  48546. /**
  48547. * Prepares the list of defines specific to the light type.
  48548. * @param defines the list of defines
  48549. * @param lightIndex defines the index of the light for the effect
  48550. */
  48551. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48552. }
  48553. }
  48554. declare module "babylonjs/Lights/pointLight" {
  48555. import { Scene } from "babylonjs/scene";
  48556. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48558. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48559. import { Effect } from "babylonjs/Materials/effect";
  48560. /**
  48561. * A point light is a light defined by an unique point in world space.
  48562. * The light is emitted in every direction from this point.
  48563. * A good example of a point light is a standard light bulb.
  48564. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48565. */
  48566. export class PointLight extends ShadowLight {
  48567. private _shadowAngle;
  48568. /**
  48569. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48570. * This specifies what angle the shadow will use to be created.
  48571. *
  48572. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48573. */
  48574. /**
  48575. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48576. * This specifies what angle the shadow will use to be created.
  48577. *
  48578. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48579. */
  48580. shadowAngle: number;
  48581. /**
  48582. * Gets the direction if it has been set.
  48583. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48584. */
  48585. /**
  48586. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48587. */
  48588. direction: Vector3;
  48589. /**
  48590. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48591. * A PointLight emits the light in every direction.
  48592. * It can cast shadows.
  48593. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48594. * ```javascript
  48595. * var pointLight = new PointLight("pl", camera.position, scene);
  48596. * ```
  48597. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48598. * @param name The light friendly name
  48599. * @param position The position of the point light in the scene
  48600. * @param scene The scene the lights belongs to
  48601. */
  48602. constructor(name: string, position: Vector3, scene: Scene);
  48603. /**
  48604. * Returns the string "PointLight"
  48605. * @returns the class name
  48606. */
  48607. getClassName(): string;
  48608. /**
  48609. * Returns the integer 0.
  48610. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48611. */
  48612. getTypeID(): number;
  48613. /**
  48614. * Specifies wether or not the shadowmap should be a cube texture.
  48615. * @returns true if the shadowmap needs to be a cube texture.
  48616. */
  48617. needCube(): boolean;
  48618. /**
  48619. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48620. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48621. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48622. */
  48623. getShadowDirection(faceIndex?: number): Vector3;
  48624. /**
  48625. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48626. * - fov = PI / 2
  48627. * - aspect ratio : 1.0
  48628. * - z-near and far equal to the active camera minZ and maxZ.
  48629. * Returns the PointLight.
  48630. */
  48631. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48632. protected _buildUniformLayout(): void;
  48633. /**
  48634. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48635. * @param effect The effect to update
  48636. * @param lightIndex The index of the light in the effect to update
  48637. * @returns The point light
  48638. */
  48639. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48640. /**
  48641. * Prepares the list of defines specific to the light type.
  48642. * @param defines the list of defines
  48643. * @param lightIndex defines the index of the light for the effect
  48644. */
  48645. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48646. }
  48647. }
  48648. declare module "babylonjs/Lights/spotLight" {
  48649. import { Nullable } from "babylonjs/types";
  48650. import { Scene } from "babylonjs/scene";
  48651. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48653. import { Effect } from "babylonjs/Materials/effect";
  48654. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48655. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48656. /**
  48657. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48658. * These values define a cone of light starting from the position, emitting toward the direction.
  48659. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48660. * and the exponent defines the speed of the decay of the light with distance (reach).
  48661. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48662. */
  48663. export class SpotLight extends ShadowLight {
  48664. private _angle;
  48665. private _innerAngle;
  48666. private _cosHalfAngle;
  48667. private _lightAngleScale;
  48668. private _lightAngleOffset;
  48669. /**
  48670. * Gets the cone angle of the spot light in Radians.
  48671. */
  48672. /**
  48673. * Sets the cone angle of the spot light in Radians.
  48674. */
  48675. angle: number;
  48676. /**
  48677. * Only used in gltf falloff mode, this defines the angle where
  48678. * the directional falloff will start before cutting at angle which could be seen
  48679. * as outer angle.
  48680. */
  48681. /**
  48682. * Only used in gltf falloff mode, this defines the angle where
  48683. * the directional falloff will start before cutting at angle which could be seen
  48684. * as outer angle.
  48685. */
  48686. innerAngle: number;
  48687. private _shadowAngleScale;
  48688. /**
  48689. * Allows scaling the angle of the light for shadow generation only.
  48690. */
  48691. /**
  48692. * Allows scaling the angle of the light for shadow generation only.
  48693. */
  48694. shadowAngleScale: number;
  48695. /**
  48696. * The light decay speed with the distance from the emission spot.
  48697. */
  48698. exponent: number;
  48699. private _projectionTextureMatrix;
  48700. /**
  48701. * Allows reading the projecton texture
  48702. */
  48703. readonly projectionTextureMatrix: Matrix;
  48704. protected _projectionTextureLightNear: number;
  48705. /**
  48706. * Gets the near clip of the Spotlight for texture projection.
  48707. */
  48708. /**
  48709. * Sets the near clip of the Spotlight for texture projection.
  48710. */
  48711. projectionTextureLightNear: number;
  48712. protected _projectionTextureLightFar: number;
  48713. /**
  48714. * Gets the far clip of the Spotlight for texture projection.
  48715. */
  48716. /**
  48717. * Sets the far clip of the Spotlight for texture projection.
  48718. */
  48719. projectionTextureLightFar: number;
  48720. protected _projectionTextureUpDirection: Vector3;
  48721. /**
  48722. * Gets the Up vector of the Spotlight for texture projection.
  48723. */
  48724. /**
  48725. * Sets the Up vector of the Spotlight for texture projection.
  48726. */
  48727. projectionTextureUpDirection: Vector3;
  48728. private _projectionTexture;
  48729. /**
  48730. * Gets the projection texture of the light.
  48731. */
  48732. /**
  48733. * Sets the projection texture of the light.
  48734. */
  48735. projectionTexture: Nullable<BaseTexture>;
  48736. private _projectionTextureViewLightDirty;
  48737. private _projectionTextureProjectionLightDirty;
  48738. private _projectionTextureDirty;
  48739. private _projectionTextureViewTargetVector;
  48740. private _projectionTextureViewLightMatrix;
  48741. private _projectionTextureProjectionLightMatrix;
  48742. private _projectionTextureScalingMatrix;
  48743. /**
  48744. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48745. * It can cast shadows.
  48746. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48747. * @param name The light friendly name
  48748. * @param position The position of the spot light in the scene
  48749. * @param direction The direction of the light in the scene
  48750. * @param angle The cone angle of the light in Radians
  48751. * @param exponent The light decay speed with the distance from the emission spot
  48752. * @param scene The scene the lights belongs to
  48753. */
  48754. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48755. /**
  48756. * Returns the string "SpotLight".
  48757. * @returns the class name
  48758. */
  48759. getClassName(): string;
  48760. /**
  48761. * Returns the integer 2.
  48762. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48763. */
  48764. getTypeID(): number;
  48765. /**
  48766. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48767. */
  48768. protected _setDirection(value: Vector3): void;
  48769. /**
  48770. * Overrides the position setter to recompute the projection texture view light Matrix.
  48771. */
  48772. protected _setPosition(value: Vector3): void;
  48773. /**
  48774. * 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.
  48775. * Returns the SpotLight.
  48776. */
  48777. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48778. protected _computeProjectionTextureViewLightMatrix(): void;
  48779. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48780. /**
  48781. * Main function for light texture projection matrix computing.
  48782. */
  48783. protected _computeProjectionTextureMatrix(): void;
  48784. protected _buildUniformLayout(): void;
  48785. private _computeAngleValues;
  48786. /**
  48787. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48788. * @param effect The effect to update
  48789. * @param lightIndex The index of the light in the effect to update
  48790. * @returns The spot light
  48791. */
  48792. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48793. /**
  48794. * Disposes the light and the associated resources.
  48795. */
  48796. dispose(): void;
  48797. /**
  48798. * Prepares the list of defines specific to the light type.
  48799. * @param defines the list of defines
  48800. * @param lightIndex defines the index of the light for the effect
  48801. */
  48802. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48803. }
  48804. }
  48805. declare module "babylonjs/Lights/index" {
  48806. export * from "babylonjs/Lights/light";
  48807. export * from "babylonjs/Lights/shadowLight";
  48808. export * from "babylonjs/Lights/Shadows/index";
  48809. export * from "babylonjs/Lights/directionalLight";
  48810. export * from "babylonjs/Lights/hemisphericLight";
  48811. export * from "babylonjs/Lights/pointLight";
  48812. export * from "babylonjs/Lights/spotLight";
  48813. }
  48814. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48815. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48816. /**
  48817. * Header information of HDR texture files.
  48818. */
  48819. export interface HDRInfo {
  48820. /**
  48821. * The height of the texture in pixels.
  48822. */
  48823. height: number;
  48824. /**
  48825. * The width of the texture in pixels.
  48826. */
  48827. width: number;
  48828. /**
  48829. * The index of the beginning of the data in the binary file.
  48830. */
  48831. dataPosition: number;
  48832. }
  48833. /**
  48834. * This groups tools to convert HDR texture to native colors array.
  48835. */
  48836. export class HDRTools {
  48837. private static Ldexp;
  48838. private static Rgbe2float;
  48839. private static readStringLine;
  48840. /**
  48841. * Reads header information from an RGBE texture stored in a native array.
  48842. * More information on this format are available here:
  48843. * https://en.wikipedia.org/wiki/RGBE_image_format
  48844. *
  48845. * @param uint8array The binary file stored in native array.
  48846. * @return The header information.
  48847. */
  48848. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48849. /**
  48850. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48851. * This RGBE texture needs to store the information as a panorama.
  48852. *
  48853. * More information on this format are available here:
  48854. * https://en.wikipedia.org/wiki/RGBE_image_format
  48855. *
  48856. * @param buffer The binary file stored in an array buffer.
  48857. * @param size The expected size of the extracted cubemap.
  48858. * @return The Cube Map information.
  48859. */
  48860. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48861. /**
  48862. * Returns the pixels data extracted from an RGBE texture.
  48863. * This pixels will be stored left to right up to down in the R G B order in one array.
  48864. *
  48865. * More information on this format are available here:
  48866. * https://en.wikipedia.org/wiki/RGBE_image_format
  48867. *
  48868. * @param uint8array The binary file stored in an array buffer.
  48869. * @param hdrInfo The header information of the file.
  48870. * @return The pixels data in RGB right to left up to down order.
  48871. */
  48872. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48873. private static RGBE_ReadPixels_RLE;
  48874. }
  48875. }
  48876. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48877. import { Nullable } from "babylonjs/types";
  48878. import { Scene } from "babylonjs/scene";
  48879. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48881. /**
  48882. * This represents a texture coming from an HDR input.
  48883. *
  48884. * The only supported format is currently panorama picture stored in RGBE format.
  48885. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48886. */
  48887. export class HDRCubeTexture extends BaseTexture {
  48888. private static _facesMapping;
  48889. private _generateHarmonics;
  48890. private _noMipmap;
  48891. private _textureMatrix;
  48892. private _size;
  48893. private _onLoad;
  48894. private _onError;
  48895. /**
  48896. * The texture URL.
  48897. */
  48898. url: string;
  48899. /**
  48900. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48901. */
  48902. coordinatesMode: number;
  48903. protected _isBlocking: boolean;
  48904. /**
  48905. * Sets wether or not the texture is blocking during loading.
  48906. */
  48907. /**
  48908. * Gets wether or not the texture is blocking during loading.
  48909. */
  48910. isBlocking: boolean;
  48911. protected _rotationY: number;
  48912. /**
  48913. * Sets texture matrix rotation angle around Y axis in radians.
  48914. */
  48915. /**
  48916. * Gets texture matrix rotation angle around Y axis radians.
  48917. */
  48918. rotationY: number;
  48919. /**
  48920. * Gets or sets the center of the bounding box associated with the cube texture
  48921. * It must define where the camera used to render the texture was set
  48922. */
  48923. boundingBoxPosition: Vector3;
  48924. private _boundingBoxSize;
  48925. /**
  48926. * Gets or sets the size of the bounding box associated with the cube texture
  48927. * When defined, the cubemap will switch to local mode
  48928. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48929. * @example https://www.babylonjs-playground.com/#RNASML
  48930. */
  48931. boundingBoxSize: Vector3;
  48932. /**
  48933. * Instantiates an HDRTexture from the following parameters.
  48934. *
  48935. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48936. * @param scene The scene the texture will be used in
  48937. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48938. * @param noMipmap Forces to not generate the mipmap if true
  48939. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48940. * @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)
  48941. * @param reserved Reserved flag for internal use.
  48942. */
  48943. 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>);
  48944. /**
  48945. * Get the current class name of the texture useful for serialization or dynamic coding.
  48946. * @returns "HDRCubeTexture"
  48947. */
  48948. getClassName(): string;
  48949. /**
  48950. * Occurs when the file is raw .hdr file.
  48951. */
  48952. private loadTexture;
  48953. clone(): HDRCubeTexture;
  48954. delayLoad(): void;
  48955. /**
  48956. * Get the texture reflection matrix used to rotate/transform the reflection.
  48957. * @returns the reflection matrix
  48958. */
  48959. getReflectionTextureMatrix(): Matrix;
  48960. /**
  48961. * Set the texture reflection matrix used to rotate/transform the reflection.
  48962. * @param value Define the reflection matrix to set
  48963. */
  48964. setReflectionTextureMatrix(value: Matrix): void;
  48965. /**
  48966. * Parses a JSON representation of an HDR Texture in order to create the texture
  48967. * @param parsedTexture Define the JSON representation
  48968. * @param scene Define the scene the texture should be created in
  48969. * @param rootUrl Define the root url in case we need to load relative dependencies
  48970. * @returns the newly created texture after parsing
  48971. */
  48972. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48973. serialize(): any;
  48974. }
  48975. }
  48976. declare module "babylonjs/Physics/physicsEngine" {
  48977. import { Nullable } from "babylonjs/types";
  48978. import { Vector3 } from "babylonjs/Maths/math";
  48979. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48980. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48981. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48982. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  48983. /**
  48984. * Class used to control physics engine
  48985. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48986. */
  48987. export class PhysicsEngine implements IPhysicsEngine {
  48988. private _physicsPlugin;
  48989. /**
  48990. * Global value used to control the smallest number supported by the simulation
  48991. */
  48992. static Epsilon: number;
  48993. private _impostors;
  48994. private _joints;
  48995. /**
  48996. * Gets the gravity vector used by the simulation
  48997. */
  48998. gravity: Vector3;
  48999. /**
  49000. * Factory used to create the default physics plugin.
  49001. * @returns The default physics plugin
  49002. */
  49003. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49004. /**
  49005. * Creates a new Physics Engine
  49006. * @param gravity defines the gravity vector used by the simulation
  49007. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49008. */
  49009. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49010. /**
  49011. * Sets the gravity vector used by the simulation
  49012. * @param gravity defines the gravity vector to use
  49013. */
  49014. setGravity(gravity: Vector3): void;
  49015. /**
  49016. * Set the time step of the physics engine.
  49017. * Default is 1/60.
  49018. * To slow it down, enter 1/600 for example.
  49019. * To speed it up, 1/30
  49020. * @param newTimeStep defines the new timestep to apply to this world.
  49021. */
  49022. setTimeStep(newTimeStep?: number): void;
  49023. /**
  49024. * Get the time step of the physics engine.
  49025. * @returns the current time step
  49026. */
  49027. getTimeStep(): number;
  49028. /**
  49029. * Release all resources
  49030. */
  49031. dispose(): void;
  49032. /**
  49033. * Gets the name of the current physics plugin
  49034. * @returns the name of the plugin
  49035. */
  49036. getPhysicsPluginName(): string;
  49037. /**
  49038. * Adding a new impostor for the impostor tracking.
  49039. * This will be done by the impostor itself.
  49040. * @param impostor the impostor to add
  49041. */
  49042. addImpostor(impostor: PhysicsImpostor): void;
  49043. /**
  49044. * Remove an impostor from the engine.
  49045. * This impostor and its mesh will not longer be updated by the physics engine.
  49046. * @param impostor the impostor to remove
  49047. */
  49048. removeImpostor(impostor: PhysicsImpostor): void;
  49049. /**
  49050. * Add a joint to the physics engine
  49051. * @param mainImpostor defines the main impostor to which the joint is added.
  49052. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49053. * @param joint defines the joint that will connect both impostors.
  49054. */
  49055. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49056. /**
  49057. * Removes a joint from the simulation
  49058. * @param mainImpostor defines the impostor used with the joint
  49059. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49060. * @param joint defines the joint to remove
  49061. */
  49062. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49063. /**
  49064. * Called by the scene. No need to call it.
  49065. * @param delta defines the timespam between frames
  49066. */
  49067. _step(delta: number): void;
  49068. /**
  49069. * Gets the current plugin used to run the simulation
  49070. * @returns current plugin
  49071. */
  49072. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49073. /**
  49074. * Gets the list of physic impostors
  49075. * @returns an array of PhysicsImpostor
  49076. */
  49077. getImpostors(): Array<PhysicsImpostor>;
  49078. /**
  49079. * Gets the impostor for a physics enabled object
  49080. * @param object defines the object impersonated by the impostor
  49081. * @returns the PhysicsImpostor or null if not found
  49082. */
  49083. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49084. /**
  49085. * Gets the impostor for a physics body object
  49086. * @param body defines physics body used by the impostor
  49087. * @returns the PhysicsImpostor or null if not found
  49088. */
  49089. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49090. /**
  49091. * Does a raycast in the physics world
  49092. * @param from when should the ray start?
  49093. * @param to when should the ray end?
  49094. * @returns PhysicsRaycastResult
  49095. */
  49096. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49097. }
  49098. }
  49099. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49100. import { Nullable } from "babylonjs/types";
  49101. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49103. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49104. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49105. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49106. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49107. /** @hidden */
  49108. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49109. private _useDeltaForWorldStep;
  49110. world: any;
  49111. name: string;
  49112. private _physicsMaterials;
  49113. private _fixedTimeStep;
  49114. private _cannonRaycastResult;
  49115. private _raycastResult;
  49116. BJSCANNON: any;
  49117. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49118. setGravity(gravity: Vector3): void;
  49119. setTimeStep(timeStep: number): void;
  49120. getTimeStep(): number;
  49121. executeStep(delta: number): void;
  49122. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49123. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49124. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49125. private _processChildMeshes;
  49126. removePhysicsBody(impostor: PhysicsImpostor): void;
  49127. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49128. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49129. private _addMaterial;
  49130. private _checkWithEpsilon;
  49131. private _createShape;
  49132. private _createHeightmap;
  49133. private _minus90X;
  49134. private _plus90X;
  49135. private _tmpPosition;
  49136. private _tmpDeltaPosition;
  49137. private _tmpUnityRotation;
  49138. private _updatePhysicsBodyTransformation;
  49139. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49140. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49141. isSupported(): boolean;
  49142. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49143. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49144. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49145. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49146. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49147. getBodyMass(impostor: PhysicsImpostor): number;
  49148. getBodyFriction(impostor: PhysicsImpostor): number;
  49149. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49150. getBodyRestitution(impostor: PhysicsImpostor): number;
  49151. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49152. sleepBody(impostor: PhysicsImpostor): void;
  49153. wakeUpBody(impostor: PhysicsImpostor): void;
  49154. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49155. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49156. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49157. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49158. getRadius(impostor: PhysicsImpostor): number;
  49159. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49160. dispose(): void;
  49161. private _extendNamespace;
  49162. /**
  49163. * Does a raycast in the physics world
  49164. * @param from when should the ray start?
  49165. * @param to when should the ray end?
  49166. * @returns PhysicsRaycastResult
  49167. */
  49168. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49169. }
  49170. }
  49171. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49172. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49173. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49174. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49176. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49177. import { Nullable } from "babylonjs/types";
  49178. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49179. /** @hidden */
  49180. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49181. world: any;
  49182. name: string;
  49183. BJSOIMO: any;
  49184. private _raycastResult;
  49185. constructor(iterations?: number, oimoInjection?: any);
  49186. setGravity(gravity: Vector3): void;
  49187. setTimeStep(timeStep: number): void;
  49188. getTimeStep(): number;
  49189. private _tmpImpostorsArray;
  49190. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49191. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49192. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49193. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49194. private _tmpPositionVector;
  49195. removePhysicsBody(impostor: PhysicsImpostor): void;
  49196. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49197. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49198. isSupported(): boolean;
  49199. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49200. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49201. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49202. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49203. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49204. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49205. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49206. getBodyMass(impostor: PhysicsImpostor): number;
  49207. getBodyFriction(impostor: PhysicsImpostor): number;
  49208. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49209. getBodyRestitution(impostor: PhysicsImpostor): number;
  49210. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49211. sleepBody(impostor: PhysicsImpostor): void;
  49212. wakeUpBody(impostor: PhysicsImpostor): void;
  49213. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49214. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49215. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49216. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49217. getRadius(impostor: PhysicsImpostor): number;
  49218. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49219. dispose(): void;
  49220. /**
  49221. * Does a raycast in the physics world
  49222. * @param from when should the ray start?
  49223. * @param to when should the ray end?
  49224. * @returns PhysicsRaycastResult
  49225. */
  49226. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49227. }
  49228. }
  49229. declare module "babylonjs/Probes/reflectionProbe" {
  49230. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49231. import { Vector3 } from "babylonjs/Maths/math";
  49232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49233. import { Nullable } from "babylonjs/types";
  49234. import { Scene } from "babylonjs/scene";
  49235. module "babylonjs/abstractScene" {
  49236. interface AbstractScene {
  49237. /**
  49238. * The list of reflection probes added to the scene
  49239. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49240. */
  49241. reflectionProbes: Array<ReflectionProbe>;
  49242. /**
  49243. * Removes the given reflection probe from this scene.
  49244. * @param toRemove The reflection probe to remove
  49245. * @returns The index of the removed reflection probe
  49246. */
  49247. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49248. /**
  49249. * Adds the given reflection probe to this scene.
  49250. * @param newReflectionProbe The reflection probe to add
  49251. */
  49252. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49253. }
  49254. }
  49255. /**
  49256. * Class used to generate realtime reflection / refraction cube textures
  49257. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49258. */
  49259. export class ReflectionProbe {
  49260. /** defines the name of the probe */
  49261. name: string;
  49262. private _scene;
  49263. private _renderTargetTexture;
  49264. private _projectionMatrix;
  49265. private _viewMatrix;
  49266. private _target;
  49267. private _add;
  49268. private _attachedMesh;
  49269. private _invertYAxis;
  49270. /** Gets or sets probe position (center of the cube map) */
  49271. position: Vector3;
  49272. /**
  49273. * Creates a new reflection probe
  49274. * @param name defines the name of the probe
  49275. * @param size defines the texture resolution (for each face)
  49276. * @param scene defines the hosting scene
  49277. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49278. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49279. */
  49280. constructor(
  49281. /** defines the name of the probe */
  49282. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49283. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49284. samples: number;
  49285. /** Gets or sets the refresh rate to use (on every frame by default) */
  49286. refreshRate: number;
  49287. /**
  49288. * Gets the hosting scene
  49289. * @returns a Scene
  49290. */
  49291. getScene(): Scene;
  49292. /** Gets the internal CubeTexture used to render to */
  49293. readonly cubeTexture: RenderTargetTexture;
  49294. /** Gets the list of meshes to render */
  49295. readonly renderList: Nullable<AbstractMesh[]>;
  49296. /**
  49297. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49298. * @param mesh defines the mesh to attach to
  49299. */
  49300. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49301. /**
  49302. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49303. * @param renderingGroupId The rendering group id corresponding to its index
  49304. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49305. */
  49306. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49307. /**
  49308. * Clean all associated resources
  49309. */
  49310. dispose(): void;
  49311. /**
  49312. * Converts the reflection probe information to a readable string for debug purpose.
  49313. * @param fullDetails Supports for multiple levels of logging within scene loading
  49314. * @returns the human readable reflection probe info
  49315. */
  49316. toString(fullDetails?: boolean): string;
  49317. /**
  49318. * Get the class name of the relfection probe.
  49319. * @returns "ReflectionProbe"
  49320. */
  49321. getClassName(): string;
  49322. /**
  49323. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49324. * @returns The JSON representation of the texture
  49325. */
  49326. serialize(): any;
  49327. /**
  49328. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49329. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49330. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49331. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49332. * @returns The parsed reflection probe if successful
  49333. */
  49334. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49335. }
  49336. }
  49337. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  49338. /** @hidden */
  49339. export var _BabylonLoaderRegistered: boolean;
  49340. }
  49341. declare module "babylonjs/Loading/Plugins/index" {
  49342. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  49343. }
  49344. declare module "babylonjs/Loading/index" {
  49345. export * from "babylonjs/Loading/loadingScreen";
  49346. export * from "babylonjs/Loading/Plugins/index";
  49347. export * from "babylonjs/Loading/sceneLoader";
  49348. export * from "babylonjs/Loading/sceneLoaderFlags";
  49349. }
  49350. declare module "babylonjs/Materials/Background/index" {
  49351. export * from "babylonjs/Materials/Background/backgroundMaterial";
  49352. }
  49353. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  49354. import { Scene } from "babylonjs/scene";
  49355. import { Color3 } from "babylonjs/Maths/math";
  49356. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49357. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49358. /**
  49359. * The Physically based simple base material of BJS.
  49360. *
  49361. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49362. * It is used as the base class for both the specGloss and metalRough conventions.
  49363. */
  49364. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49365. /**
  49366. * Number of Simultaneous lights allowed on the material.
  49367. */
  49368. maxSimultaneousLights: number;
  49369. /**
  49370. * If sets to true, disables all the lights affecting the material.
  49371. */
  49372. disableLighting: boolean;
  49373. /**
  49374. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49375. */
  49376. environmentTexture: BaseTexture;
  49377. /**
  49378. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49379. */
  49380. invertNormalMapX: boolean;
  49381. /**
  49382. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49383. */
  49384. invertNormalMapY: boolean;
  49385. /**
  49386. * Normal map used in the model.
  49387. */
  49388. normalTexture: BaseTexture;
  49389. /**
  49390. * Emissivie color used to self-illuminate the model.
  49391. */
  49392. emissiveColor: Color3;
  49393. /**
  49394. * Emissivie texture used to self-illuminate the model.
  49395. */
  49396. emissiveTexture: BaseTexture;
  49397. /**
  49398. * Occlusion Channel Strenght.
  49399. */
  49400. occlusionStrength: number;
  49401. /**
  49402. * Occlusion Texture of the material (adding extra occlusion effects).
  49403. */
  49404. occlusionTexture: BaseTexture;
  49405. /**
  49406. * Defines the alpha limits in alpha test mode.
  49407. */
  49408. alphaCutOff: number;
  49409. /**
  49410. * Gets the current double sided mode.
  49411. */
  49412. /**
  49413. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49414. */
  49415. doubleSided: boolean;
  49416. /**
  49417. * Stores the pre-calculated light information of a mesh in a texture.
  49418. */
  49419. lightmapTexture: BaseTexture;
  49420. /**
  49421. * If true, the light map contains occlusion information instead of lighting info.
  49422. */
  49423. useLightmapAsShadowmap: boolean;
  49424. /**
  49425. * Instantiates a new PBRMaterial instance.
  49426. *
  49427. * @param name The material name
  49428. * @param scene The scene the material will be use in.
  49429. */
  49430. constructor(name: string, scene: Scene);
  49431. getClassName(): string;
  49432. }
  49433. }
  49434. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49435. import { Scene } from "babylonjs/scene";
  49436. import { Color3 } from "babylonjs/Maths/math";
  49437. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49438. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49439. /**
  49440. * The PBR material of BJS following the metal roughness convention.
  49441. *
  49442. * This fits to the PBR convention in the GLTF definition:
  49443. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49444. */
  49445. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49446. /**
  49447. * The base color has two different interpretations depending on the value of metalness.
  49448. * When the material is a metal, the base color is the specific measured reflectance value
  49449. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49450. * of the material.
  49451. */
  49452. baseColor: Color3;
  49453. /**
  49454. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49455. * well as opacity information in the alpha channel.
  49456. */
  49457. baseTexture: BaseTexture;
  49458. /**
  49459. * Specifies the metallic scalar value of the material.
  49460. * Can also be used to scale the metalness values of the metallic texture.
  49461. */
  49462. metallic: number;
  49463. /**
  49464. * Specifies the roughness scalar value of the material.
  49465. * Can also be used to scale the roughness values of the metallic texture.
  49466. */
  49467. roughness: number;
  49468. /**
  49469. * Texture containing both the metallic value in the B channel and the
  49470. * roughness value in the G channel to keep better precision.
  49471. */
  49472. metallicRoughnessTexture: BaseTexture;
  49473. /**
  49474. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49475. *
  49476. * @param name The material name
  49477. * @param scene The scene the material will be use in.
  49478. */
  49479. constructor(name: string, scene: Scene);
  49480. /**
  49481. * Return the currrent class name of the material.
  49482. */
  49483. getClassName(): string;
  49484. /**
  49485. * Makes a duplicate of the current material.
  49486. * @param name - name to use for the new material.
  49487. */
  49488. clone(name: string): PBRMetallicRoughnessMaterial;
  49489. /**
  49490. * Serialize the material to a parsable JSON object.
  49491. */
  49492. serialize(): any;
  49493. /**
  49494. * Parses a JSON object correponding to the serialize function.
  49495. */
  49496. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49497. }
  49498. }
  49499. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49500. import { Scene } from "babylonjs/scene";
  49501. import { Color3 } from "babylonjs/Maths/math";
  49502. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49503. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49504. /**
  49505. * The PBR material of BJS following the specular glossiness convention.
  49506. *
  49507. * This fits to the PBR convention in the GLTF definition:
  49508. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49509. */
  49510. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49511. /**
  49512. * Specifies the diffuse color of the material.
  49513. */
  49514. diffuseColor: Color3;
  49515. /**
  49516. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49517. * channel.
  49518. */
  49519. diffuseTexture: BaseTexture;
  49520. /**
  49521. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49522. */
  49523. specularColor: Color3;
  49524. /**
  49525. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49526. */
  49527. glossiness: number;
  49528. /**
  49529. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49530. */
  49531. specularGlossinessTexture: BaseTexture;
  49532. /**
  49533. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49534. *
  49535. * @param name The material name
  49536. * @param scene The scene the material will be use in.
  49537. */
  49538. constructor(name: string, scene: Scene);
  49539. /**
  49540. * Return the currrent class name of the material.
  49541. */
  49542. getClassName(): string;
  49543. /**
  49544. * Makes a duplicate of the current material.
  49545. * @param name - name to use for the new material.
  49546. */
  49547. clone(name: string): PBRSpecularGlossinessMaterial;
  49548. /**
  49549. * Serialize the material to a parsable JSON object.
  49550. */
  49551. serialize(): any;
  49552. /**
  49553. * Parses a JSON object correponding to the serialize function.
  49554. */
  49555. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49556. }
  49557. }
  49558. declare module "babylonjs/Materials/PBR/index" {
  49559. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49560. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49561. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49562. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49563. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49564. }
  49565. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49566. import { Nullable } from "babylonjs/types";
  49567. import { Scene } from "babylonjs/scene";
  49568. import { Matrix } from "babylonjs/Maths/math";
  49569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49570. /**
  49571. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49572. * It can help converting any input color in a desired output one. This can then be used to create effects
  49573. * from sepia, black and white to sixties or futuristic rendering...
  49574. *
  49575. * The only supported format is currently 3dl.
  49576. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49577. */
  49578. export class ColorGradingTexture extends BaseTexture {
  49579. /**
  49580. * The current texture matrix. (will always be identity in color grading texture)
  49581. */
  49582. private _textureMatrix;
  49583. /**
  49584. * The texture URL.
  49585. */
  49586. url: string;
  49587. /**
  49588. * Empty line regex stored for GC.
  49589. */
  49590. private static _noneEmptyLineRegex;
  49591. private _engine;
  49592. /**
  49593. * Instantiates a ColorGradingTexture from the following parameters.
  49594. *
  49595. * @param url The location of the color gradind data (currently only supporting 3dl)
  49596. * @param scene The scene the texture will be used in
  49597. */
  49598. constructor(url: string, scene: Scene);
  49599. /**
  49600. * Returns the texture matrix used in most of the material.
  49601. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49602. */
  49603. getTextureMatrix(): Matrix;
  49604. /**
  49605. * Occurs when the file being loaded is a .3dl LUT file.
  49606. */
  49607. private load3dlTexture;
  49608. /**
  49609. * Starts the loading process of the texture.
  49610. */
  49611. private loadTexture;
  49612. /**
  49613. * Clones the color gradind texture.
  49614. */
  49615. clone(): ColorGradingTexture;
  49616. /**
  49617. * Called during delayed load for textures.
  49618. */
  49619. delayLoad(): void;
  49620. /**
  49621. * Parses a color grading texture serialized by Babylon.
  49622. * @param parsedTexture The texture information being parsedTexture
  49623. * @param scene The scene to load the texture in
  49624. * @param rootUrl The root url of the data assets to load
  49625. * @return A color gradind texture
  49626. */
  49627. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49628. /**
  49629. * Serializes the LUT texture to json format.
  49630. */
  49631. serialize(): any;
  49632. }
  49633. }
  49634. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  49635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49636. import { Scene } from "babylonjs/scene";
  49637. import { Nullable } from "babylonjs/types";
  49638. /**
  49639. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49640. */
  49641. export class EquiRectangularCubeTexture extends BaseTexture {
  49642. /** The six faces of the cube. */
  49643. private static _FacesMapping;
  49644. private _noMipmap;
  49645. private _onLoad;
  49646. private _onError;
  49647. /** The size of the cubemap. */
  49648. private _size;
  49649. /** The buffer of the image. */
  49650. private _buffer;
  49651. /** The width of the input image. */
  49652. private _width;
  49653. /** The height of the input image. */
  49654. private _height;
  49655. /** The URL to the image. */
  49656. url: string;
  49657. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49658. coordinatesMode: number;
  49659. /**
  49660. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49661. * @param url The location of the image
  49662. * @param scene The scene the texture will be used in
  49663. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49664. * @param noMipmap Forces to not generate the mipmap if true
  49665. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49666. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49667. * @param onLoad — defines a callback called when texture is loaded
  49668. * @param onError — defines a callback called if there is an error
  49669. */
  49670. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49671. /**
  49672. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49673. */
  49674. private loadImage;
  49675. /**
  49676. * Convert the image buffer into a cubemap and create a CubeTexture.
  49677. */
  49678. private loadTexture;
  49679. /**
  49680. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49681. * @param buffer The ArrayBuffer that should be converted.
  49682. * @returns The buffer as Float32Array.
  49683. */
  49684. private getFloat32ArrayFromArrayBuffer;
  49685. /**
  49686. * Get the current class name of the texture useful for serialization or dynamic coding.
  49687. * @returns "EquiRectangularCubeTexture"
  49688. */
  49689. getClassName(): string;
  49690. /**
  49691. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49692. * @returns A clone of the current EquiRectangularCubeTexture.
  49693. */
  49694. clone(): EquiRectangularCubeTexture;
  49695. }
  49696. }
  49697. declare module "babylonjs/Misc/tga" {
  49698. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49699. /**
  49700. * Based on jsTGALoader - Javascript loader for TGA file
  49701. * By Vincent Thibault
  49702. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49703. */
  49704. export class TGATools {
  49705. private static _TYPE_INDEXED;
  49706. private static _TYPE_RGB;
  49707. private static _TYPE_GREY;
  49708. private static _TYPE_RLE_INDEXED;
  49709. private static _TYPE_RLE_RGB;
  49710. private static _TYPE_RLE_GREY;
  49711. private static _ORIGIN_MASK;
  49712. private static _ORIGIN_SHIFT;
  49713. private static _ORIGIN_BL;
  49714. private static _ORIGIN_BR;
  49715. private static _ORIGIN_UL;
  49716. private static _ORIGIN_UR;
  49717. /**
  49718. * Gets the header of a TGA file
  49719. * @param data defines the TGA data
  49720. * @returns the header
  49721. */
  49722. static GetTGAHeader(data: Uint8Array): any;
  49723. /**
  49724. * Uploads TGA content to a Babylon Texture
  49725. * @hidden
  49726. */
  49727. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49728. /** @hidden */
  49729. 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;
  49730. /** @hidden */
  49731. 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;
  49732. /** @hidden */
  49733. 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;
  49734. /** @hidden */
  49735. 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;
  49736. /** @hidden */
  49737. 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;
  49738. /** @hidden */
  49739. 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;
  49740. }
  49741. }
  49742. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49743. import { Nullable } from "babylonjs/types";
  49744. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49745. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49746. /**
  49747. * Implementation of the TGA Texture Loader.
  49748. * @hidden
  49749. */
  49750. export class _TGATextureLoader implements IInternalTextureLoader {
  49751. /**
  49752. * Defines wether the loader supports cascade loading the different faces.
  49753. */
  49754. readonly supportCascades: boolean;
  49755. /**
  49756. * This returns if the loader support the current file information.
  49757. * @param extension defines the file extension of the file being loaded
  49758. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49759. * @param fallback defines the fallback internal texture if any
  49760. * @param isBase64 defines whether the texture is encoded as a base64
  49761. * @param isBuffer defines whether the texture data are stored as a buffer
  49762. * @returns true if the loader can load the specified file
  49763. */
  49764. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49765. /**
  49766. * Transform the url before loading if required.
  49767. * @param rootUrl the url of the texture
  49768. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49769. * @returns the transformed texture
  49770. */
  49771. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49772. /**
  49773. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49774. * @param rootUrl the url of the texture
  49775. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49776. * @returns the fallback texture
  49777. */
  49778. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49779. /**
  49780. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49781. * @param data contains the texture data
  49782. * @param texture defines the BabylonJS internal texture
  49783. * @param createPolynomials will be true if polynomials have been requested
  49784. * @param onLoad defines the callback to trigger once the texture is ready
  49785. * @param onError defines the callback to trigger in case of error
  49786. */
  49787. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49788. /**
  49789. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49790. * @param data contains the texture data
  49791. * @param texture defines the BabylonJS internal texture
  49792. * @param callback defines the method to call once ready to upload
  49793. */
  49794. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49795. }
  49796. }
  49797. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49798. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49799. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49800. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49801. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49802. }
  49803. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49804. import { Scene } from "babylonjs/scene";
  49805. import { Texture } from "babylonjs/Materials/Textures/texture";
  49806. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49807. /**
  49808. * 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.
  49809. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49810. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49811. */
  49812. export class CustomProceduralTexture extends ProceduralTexture {
  49813. private _animate;
  49814. private _time;
  49815. private _config;
  49816. private _texturePath;
  49817. /**
  49818. * Instantiates a new Custom Procedural Texture.
  49819. * 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.
  49820. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49821. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49822. * @param name Define the name of the texture
  49823. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49824. * @param size Define the size of the texture to create
  49825. * @param scene Define the scene the texture belongs to
  49826. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49827. * @param generateMipMaps Define if the texture should creates mip maps or not
  49828. */
  49829. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49830. private _loadJson;
  49831. /**
  49832. * Is the texture ready to be used ? (rendered at least once)
  49833. * @returns true if ready, otherwise, false.
  49834. */
  49835. isReady(): boolean;
  49836. /**
  49837. * Render the texture to its associated render target.
  49838. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49839. */
  49840. render(useCameraPostProcess?: boolean): void;
  49841. /**
  49842. * Update the list of dependant textures samplers in the shader.
  49843. */
  49844. updateTextures(): void;
  49845. /**
  49846. * Update the uniform values of the procedural texture in the shader.
  49847. */
  49848. updateShaderUniforms(): void;
  49849. /**
  49850. * Define if the texture animates or not.
  49851. */
  49852. animate: boolean;
  49853. }
  49854. }
  49855. declare module "babylonjs/Shaders/noise.fragment" {
  49856. /** @hidden */
  49857. export var noisePixelShader: {
  49858. name: string;
  49859. shader: string;
  49860. };
  49861. }
  49862. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49863. import { Nullable } from "babylonjs/types";
  49864. import { Scene } from "babylonjs/scene";
  49865. import { Texture } from "babylonjs/Materials/Textures/texture";
  49866. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49867. import "babylonjs/Shaders/noise.fragment";
  49868. /**
  49869. * Class used to generate noise procedural textures
  49870. */
  49871. export class NoiseProceduralTexture extends ProceduralTexture {
  49872. private _time;
  49873. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49874. brightness: number;
  49875. /** Defines the number of octaves to process */
  49876. octaves: number;
  49877. /** Defines the level of persistence (0.8 by default) */
  49878. persistence: number;
  49879. /** Gets or sets animation speed factor (default is 1) */
  49880. animationSpeedFactor: number;
  49881. /**
  49882. * Creates a new NoiseProceduralTexture
  49883. * @param name defines the name fo the texture
  49884. * @param size defines the size of the texture (default is 256)
  49885. * @param scene defines the hosting scene
  49886. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49887. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49888. */
  49889. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49890. private _updateShaderUniforms;
  49891. protected _getDefines(): string;
  49892. /** Generate the current state of the procedural texture */
  49893. render(useCameraPostProcess?: boolean): void;
  49894. /**
  49895. * Serializes this noise procedural texture
  49896. * @returns a serialized noise procedural texture object
  49897. */
  49898. serialize(): any;
  49899. /**
  49900. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49901. * @param parsedTexture defines parsed texture data
  49902. * @param scene defines the current scene
  49903. * @param rootUrl defines the root URL containing noise procedural texture information
  49904. * @returns a parsed NoiseProceduralTexture
  49905. */
  49906. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49907. }
  49908. }
  49909. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49910. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49911. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49912. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49913. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49914. }
  49915. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49916. import { Nullable } from "babylonjs/types";
  49917. import { Scene } from "babylonjs/scene";
  49918. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49919. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49920. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49921. /**
  49922. * Raw cube texture where the raw buffers are passed in
  49923. */
  49924. export class RawCubeTexture extends CubeTexture {
  49925. /**
  49926. * Creates a cube texture where the raw buffers are passed in.
  49927. * @param scene defines the scene the texture is attached to
  49928. * @param data defines the array of data to use to create each face
  49929. * @param size defines the size of the textures
  49930. * @param format defines the format of the data
  49931. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49932. * @param generateMipMaps defines if the engine should generate the mip levels
  49933. * @param invertY defines if data must be stored with Y axis inverted
  49934. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49935. * @param compression defines the compression used (null by default)
  49936. */
  49937. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49938. /**
  49939. * Updates the raw cube texture.
  49940. * @param data defines the data to store
  49941. * @param format defines the data format
  49942. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49943. * @param invertY defines if data must be stored with Y axis inverted
  49944. * @param compression defines the compression used (null by default)
  49945. * @param level defines which level of the texture to update
  49946. */
  49947. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49948. /**
  49949. * Updates a raw cube texture with RGBD encoded data.
  49950. * @param data defines the array of data [mipmap][face] to use to create each face
  49951. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49952. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49953. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49954. * @returns a promsie that resolves when the operation is complete
  49955. */
  49956. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49957. /**
  49958. * Clones the raw cube texture.
  49959. * @return a new cube texture
  49960. */
  49961. clone(): CubeTexture;
  49962. /** @hidden */
  49963. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49964. }
  49965. }
  49966. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49967. import { Scene } from "babylonjs/scene";
  49968. import { Texture } from "babylonjs/Materials/Textures/texture";
  49969. /**
  49970. * Class used to store 3D textures containing user data
  49971. */
  49972. export class RawTexture3D extends Texture {
  49973. /** Gets or sets the texture format to use */
  49974. format: number;
  49975. private _engine;
  49976. /**
  49977. * Create a new RawTexture3D
  49978. * @param data defines the data of the texture
  49979. * @param width defines the width of the texture
  49980. * @param height defines the height of the texture
  49981. * @param depth defines the depth of the texture
  49982. * @param format defines the texture format to use
  49983. * @param scene defines the hosting scene
  49984. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49985. * @param invertY defines if texture must be stored with Y axis inverted
  49986. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49987. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49988. */
  49989. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49990. /** Gets or sets the texture format to use */
  49991. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49992. /**
  49993. * Update the texture with new data
  49994. * @param data defines the data to store in the texture
  49995. */
  49996. update(data: ArrayBufferView): void;
  49997. }
  49998. }
  49999. declare module "babylonjs/Materials/Textures/refractionTexture" {
  50000. import { Scene } from "babylonjs/scene";
  50001. import { Plane } from "babylonjs/Maths/math";
  50002. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50003. /**
  50004. * Creates a refraction texture used by refraction channel of the standard material.
  50005. * It is like a mirror but to see through a material.
  50006. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50007. */
  50008. export class RefractionTexture extends RenderTargetTexture {
  50009. /**
  50010. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50011. * 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.
  50012. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50013. */
  50014. refractionPlane: Plane;
  50015. /**
  50016. * Define how deep under the surface we should see.
  50017. */
  50018. depth: number;
  50019. /**
  50020. * Creates a refraction texture used by refraction channel of the standard material.
  50021. * It is like a mirror but to see through a material.
  50022. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50023. * @param name Define the texture name
  50024. * @param size Define the size of the underlying texture
  50025. * @param scene Define the scene the refraction belongs to
  50026. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50027. */
  50028. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50029. /**
  50030. * Clone the refraction texture.
  50031. * @returns the cloned texture
  50032. */
  50033. clone(): RefractionTexture;
  50034. /**
  50035. * Serialize the texture to a JSON representation you could use in Parse later on
  50036. * @returns the serialized JSON representation
  50037. */
  50038. serialize(): any;
  50039. }
  50040. }
  50041. declare module "babylonjs/Materials/Textures/index" {
  50042. export * from "babylonjs/Materials/Textures/baseTexture";
  50043. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  50044. export * from "babylonjs/Materials/Textures/cubeTexture";
  50045. export * from "babylonjs/Materials/Textures/dynamicTexture";
  50046. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  50047. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  50048. export * from "babylonjs/Materials/Textures/internalTexture";
  50049. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  50050. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  50051. export * from "babylonjs/Materials/Textures/Loaders/index";
  50052. export * from "babylonjs/Materials/Textures/mirrorTexture";
  50053. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  50054. export * from "babylonjs/Materials/Textures/Procedurals/index";
  50055. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  50056. export * from "babylonjs/Materials/Textures/rawTexture";
  50057. export * from "babylonjs/Materials/Textures/rawTexture3D";
  50058. export * from "babylonjs/Materials/Textures/refractionTexture";
  50059. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  50060. export * from "babylonjs/Materials/Textures/texture";
  50061. export * from "babylonjs/Materials/Textures/videoTexture";
  50062. }
  50063. declare module "babylonjs/Materials/index" {
  50064. export * from "babylonjs/Materials/Background/index";
  50065. export * from "babylonjs/Materials/colorCurves";
  50066. export * from "babylonjs/Materials/effect";
  50067. export * from "babylonjs/Materials/fresnelParameters";
  50068. export * from "babylonjs/Materials/imageProcessingConfiguration";
  50069. export * from "babylonjs/Materials/material";
  50070. export * from "babylonjs/Materials/materialDefines";
  50071. export * from "babylonjs/Materials/materialHelper";
  50072. export * from "babylonjs/Materials/multiMaterial";
  50073. export * from "babylonjs/Materials/PBR/index";
  50074. export * from "babylonjs/Materials/pushMaterial";
  50075. export * from "babylonjs/Materials/shaderMaterial";
  50076. export * from "babylonjs/Materials/standardMaterial";
  50077. export * from "babylonjs/Materials/Textures/index";
  50078. export * from "babylonjs/Materials/uniformBuffer";
  50079. export * from "babylonjs/Materials/materialFlags";
  50080. }
  50081. declare module "babylonjs/Maths/index" {
  50082. export * from "babylonjs/Maths/math.scalar";
  50083. export * from "babylonjs/Maths/math";
  50084. export * from "babylonjs/Maths/sphericalPolynomial";
  50085. }
  50086. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  50087. import { IDisposable } from "babylonjs/scene";
  50088. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50089. /**
  50090. * Configuration for Draco compression
  50091. */
  50092. export interface IDracoCompressionConfiguration {
  50093. /**
  50094. * Configuration for the decoder.
  50095. */
  50096. decoder?: {
  50097. /**
  50098. * The url to the WebAssembly module.
  50099. */
  50100. wasmUrl?: string;
  50101. /**
  50102. * The url to the WebAssembly binary.
  50103. */
  50104. wasmBinaryUrl?: string;
  50105. /**
  50106. * The url to the fallback JavaScript module.
  50107. */
  50108. fallbackUrl?: string;
  50109. };
  50110. }
  50111. /**
  50112. * Draco compression (https://google.github.io/draco/)
  50113. *
  50114. * This class wraps the Draco module.
  50115. *
  50116. * **Encoder**
  50117. *
  50118. * The encoder is not currently implemented.
  50119. *
  50120. * **Decoder**
  50121. *
  50122. * 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.
  50123. *
  50124. * To update the configuration, use the following code:
  50125. * ```javascript
  50126. * DracoCompression.Configuration = {
  50127. * decoder: {
  50128. * wasmUrl: "<url to the WebAssembly library>",
  50129. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  50130. * fallbackUrl: "<url to the fallback JavaScript library>",
  50131. * }
  50132. * };
  50133. * ```
  50134. *
  50135. * 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.
  50136. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  50137. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  50138. *
  50139. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  50140. * ```javascript
  50141. * var dracoCompression = new DracoCompression();
  50142. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  50143. * [VertexBuffer.PositionKind]: 0
  50144. * });
  50145. * ```
  50146. *
  50147. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  50148. */
  50149. export class DracoCompression implements IDisposable {
  50150. private static _DecoderModulePromise;
  50151. /**
  50152. * The configuration. Defaults to the following urls:
  50153. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  50154. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  50155. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  50156. */
  50157. static Configuration: IDracoCompressionConfiguration;
  50158. /**
  50159. * Returns true if the decoder is available.
  50160. */
  50161. static readonly DecoderAvailable: boolean;
  50162. /**
  50163. * Constructor
  50164. */
  50165. constructor();
  50166. /**
  50167. * Stop all async operations and release resources.
  50168. */
  50169. dispose(): void;
  50170. /**
  50171. * Decode Draco compressed mesh data to vertex data.
  50172. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50173. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50174. * @returns A promise that resolves with the decoded vertex data
  50175. */
  50176. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  50177. [kind: string]: number;
  50178. }): Promise<VertexData>;
  50179. private static _GetDecoderModule;
  50180. private static _LoadScriptAsync;
  50181. private static _LoadFileAsync;
  50182. }
  50183. }
  50184. declare module "babylonjs/Meshes/Compression/index" {
  50185. export * from "babylonjs/Meshes/Compression/dracoCompression";
  50186. }
  50187. declare module "babylonjs/Meshes/csg" {
  50188. import { Nullable } from "babylonjs/types";
  50189. import { Scene } from "babylonjs/scene";
  50190. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  50191. import { Mesh } from "babylonjs/Meshes/mesh";
  50192. import { Material } from "babylonjs/Materials/material";
  50193. /**
  50194. * Class for building Constructive Solid Geometry
  50195. */
  50196. export class CSG {
  50197. private polygons;
  50198. /**
  50199. * The world matrix
  50200. */
  50201. matrix: Matrix;
  50202. /**
  50203. * Stores the position
  50204. */
  50205. position: Vector3;
  50206. /**
  50207. * Stores the rotation
  50208. */
  50209. rotation: Vector3;
  50210. /**
  50211. * Stores the rotation quaternion
  50212. */
  50213. rotationQuaternion: Nullable<Quaternion>;
  50214. /**
  50215. * Stores the scaling vector
  50216. */
  50217. scaling: Vector3;
  50218. /**
  50219. * Convert the Mesh to CSG
  50220. * @param mesh The Mesh to convert to CSG
  50221. * @returns A new CSG from the Mesh
  50222. */
  50223. static FromMesh(mesh: Mesh): CSG;
  50224. /**
  50225. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50226. * @param polygons Polygons used to construct a CSG solid
  50227. */
  50228. private static FromPolygons;
  50229. /**
  50230. * Clones, or makes a deep copy, of the CSG
  50231. * @returns A new CSG
  50232. */
  50233. clone(): CSG;
  50234. /**
  50235. * Unions this CSG with another CSG
  50236. * @param csg The CSG to union against this CSG
  50237. * @returns The unioned CSG
  50238. */
  50239. union(csg: CSG): CSG;
  50240. /**
  50241. * Unions this CSG with another CSG in place
  50242. * @param csg The CSG to union against this CSG
  50243. */
  50244. unionInPlace(csg: CSG): void;
  50245. /**
  50246. * Subtracts this CSG with another CSG
  50247. * @param csg The CSG to subtract against this CSG
  50248. * @returns A new CSG
  50249. */
  50250. subtract(csg: CSG): CSG;
  50251. /**
  50252. * Subtracts this CSG with another CSG in place
  50253. * @param csg The CSG to subtact against this CSG
  50254. */
  50255. subtractInPlace(csg: CSG): void;
  50256. /**
  50257. * Intersect this CSG with another CSG
  50258. * @param csg The CSG to intersect against this CSG
  50259. * @returns A new CSG
  50260. */
  50261. intersect(csg: CSG): CSG;
  50262. /**
  50263. * Intersects this CSG with another CSG in place
  50264. * @param csg The CSG to intersect against this CSG
  50265. */
  50266. intersectInPlace(csg: CSG): void;
  50267. /**
  50268. * Return a new CSG solid with solid and empty space switched. This solid is
  50269. * not modified.
  50270. * @returns A new CSG solid with solid and empty space switched
  50271. */
  50272. inverse(): CSG;
  50273. /**
  50274. * Inverses the CSG in place
  50275. */
  50276. inverseInPlace(): void;
  50277. /**
  50278. * This is used to keep meshes transformations so they can be restored
  50279. * when we build back a Babylon Mesh
  50280. * NB : All CSG operations are performed in world coordinates
  50281. * @param csg The CSG to copy the transform attributes from
  50282. * @returns This CSG
  50283. */
  50284. copyTransformAttributes(csg: CSG): CSG;
  50285. /**
  50286. * Build Raw mesh from CSG
  50287. * Coordinates here are in world space
  50288. * @param name The name of the mesh geometry
  50289. * @param scene The Scene
  50290. * @param keepSubMeshes Specifies if the submeshes should be kept
  50291. * @returns A new Mesh
  50292. */
  50293. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50294. /**
  50295. * Build Mesh from CSG taking material and transforms into account
  50296. * @param name The name of the Mesh
  50297. * @param material The material of the Mesh
  50298. * @param scene The Scene
  50299. * @param keepSubMeshes Specifies if submeshes should be kept
  50300. * @returns The new Mesh
  50301. */
  50302. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50303. }
  50304. }
  50305. declare module "babylonjs/Meshes/trailMesh" {
  50306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50307. import { Mesh } from "babylonjs/Meshes/mesh";
  50308. import { Scene } from "babylonjs/scene";
  50309. /**
  50310. * Class used to create a trail following a mesh
  50311. */
  50312. export class TrailMesh extends Mesh {
  50313. private _generator;
  50314. private _autoStart;
  50315. private _running;
  50316. private _diameter;
  50317. private _length;
  50318. private _sectionPolygonPointsCount;
  50319. private _sectionVectors;
  50320. private _sectionNormalVectors;
  50321. private _beforeRenderObserver;
  50322. /**
  50323. * @constructor
  50324. * @param name The value used by scene.getMeshByName() to do a lookup.
  50325. * @param generator The mesh to generate a trail.
  50326. * @param scene The scene to add this mesh to.
  50327. * @param diameter Diameter of trailing mesh. Default is 1.
  50328. * @param length Length of trailing mesh. Default is 60.
  50329. * @param autoStart Automatically start trailing mesh. Default true.
  50330. */
  50331. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50332. /**
  50333. * "TrailMesh"
  50334. * @returns "TrailMesh"
  50335. */
  50336. getClassName(): string;
  50337. private _createMesh;
  50338. /**
  50339. * Start trailing mesh.
  50340. */
  50341. start(): void;
  50342. /**
  50343. * Stop trailing mesh.
  50344. */
  50345. stop(): void;
  50346. /**
  50347. * Update trailing mesh geometry.
  50348. */
  50349. update(): void;
  50350. /**
  50351. * Returns a new TrailMesh object.
  50352. * @param name is a string, the name given to the new mesh
  50353. * @param newGenerator use new generator object for cloned trail mesh
  50354. * @returns a new mesh
  50355. */
  50356. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50357. /**
  50358. * Serializes this trail mesh
  50359. * @param serializationObject object to write serialization to
  50360. */
  50361. serialize(serializationObject: any): void;
  50362. /**
  50363. * Parses a serialized trail mesh
  50364. * @param parsedMesh the serialized mesh
  50365. * @param scene the scene to create the trail mesh in
  50366. * @returns the created trail mesh
  50367. */
  50368. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50369. }
  50370. }
  50371. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50372. import { Nullable } from "babylonjs/types";
  50373. import { Scene } from "babylonjs/scene";
  50374. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50375. import { Mesh } from "babylonjs/Meshes/mesh";
  50376. /**
  50377. * Class containing static functions to help procedurally build meshes
  50378. */
  50379. export class RibbonBuilder {
  50380. /**
  50381. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50382. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50383. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50384. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50385. * * 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
  50386. * * 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
  50387. * * 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
  50388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50390. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50391. * * 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
  50392. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50393. * * 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
  50394. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50396. * @param name defines the name of the mesh
  50397. * @param options defines the options used to create the mesh
  50398. * @param scene defines the hosting scene
  50399. * @returns the ribbon mesh
  50400. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50401. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50402. */
  50403. static CreateRibbon(name: string, options: {
  50404. pathArray: Vector3[][];
  50405. closeArray?: boolean;
  50406. closePath?: boolean;
  50407. offset?: number;
  50408. updatable?: boolean;
  50409. sideOrientation?: number;
  50410. frontUVs?: Vector4;
  50411. backUVs?: Vector4;
  50412. instance?: Mesh;
  50413. invertUV?: boolean;
  50414. uvs?: Vector2[];
  50415. colors?: Color4[];
  50416. }, scene?: Nullable<Scene>): Mesh;
  50417. }
  50418. }
  50419. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50420. import { Vector4 } from "babylonjs/Maths/math";
  50421. import { Mesh } from "babylonjs/Meshes/mesh";
  50422. /**
  50423. * Class containing static functions to help procedurally build meshes
  50424. */
  50425. export class TorusKnotBuilder {
  50426. /**
  50427. * Creates a torus knot mesh
  50428. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50429. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50430. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50431. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50435. * @param name defines the name of the mesh
  50436. * @param options defines the options used to create the mesh
  50437. * @param scene defines the hosting scene
  50438. * @returns the torus knot mesh
  50439. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50440. */
  50441. static CreateTorusKnot(name: string, options: {
  50442. radius?: number;
  50443. tube?: number;
  50444. radialSegments?: number;
  50445. tubularSegments?: number;
  50446. p?: number;
  50447. q?: number;
  50448. updatable?: boolean;
  50449. sideOrientation?: number;
  50450. frontUVs?: Vector4;
  50451. backUVs?: Vector4;
  50452. }, scene: any): Mesh;
  50453. }
  50454. }
  50455. declare module "babylonjs/Meshes/polygonMesh" {
  50456. import { Scene } from "babylonjs/scene";
  50457. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50458. import { Mesh } from "babylonjs/Meshes/mesh";
  50459. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50460. /**
  50461. * Polygon
  50462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50463. */
  50464. export class Polygon {
  50465. /**
  50466. * Creates a rectangle
  50467. * @param xmin bottom X coord
  50468. * @param ymin bottom Y coord
  50469. * @param xmax top X coord
  50470. * @param ymax top Y coord
  50471. * @returns points that make the resulting rectation
  50472. */
  50473. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50474. /**
  50475. * Creates a circle
  50476. * @param radius radius of circle
  50477. * @param cx scale in x
  50478. * @param cy scale in y
  50479. * @param numberOfSides number of sides that make up the circle
  50480. * @returns points that make the resulting circle
  50481. */
  50482. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50483. /**
  50484. * Creates a polygon from input string
  50485. * @param input Input polygon data
  50486. * @returns the parsed points
  50487. */
  50488. static Parse(input: string): Vector2[];
  50489. /**
  50490. * Starts building a polygon from x and y coordinates
  50491. * @param x x coordinate
  50492. * @param y y coordinate
  50493. * @returns the started path2
  50494. */
  50495. static StartingAt(x: number, y: number): Path2;
  50496. }
  50497. /**
  50498. * Builds a polygon
  50499. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50500. */
  50501. export class PolygonMeshBuilder {
  50502. private _points;
  50503. private _outlinepoints;
  50504. private _holes;
  50505. private _name;
  50506. private _scene;
  50507. private _epoints;
  50508. private _eholes;
  50509. private _addToepoint;
  50510. /**
  50511. * Babylon reference to the earcut plugin.
  50512. */
  50513. bjsEarcut: any;
  50514. /**
  50515. * Creates a PolygonMeshBuilder
  50516. * @param name name of the builder
  50517. * @param contours Path of the polygon
  50518. * @param scene scene to add to when creating the mesh
  50519. * @param earcutInjection can be used to inject your own earcut reference
  50520. */
  50521. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50522. /**
  50523. * Adds a whole within the polygon
  50524. * @param hole Array of points defining the hole
  50525. * @returns this
  50526. */
  50527. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50528. /**
  50529. * Creates the polygon
  50530. * @param updatable If the mesh should be updatable
  50531. * @param depth The depth of the mesh created
  50532. * @returns the created mesh
  50533. */
  50534. build(updatable?: boolean, depth?: number): Mesh;
  50535. /**
  50536. * Creates the polygon
  50537. * @param depth The depth of the mesh created
  50538. * @returns the created VertexData
  50539. */
  50540. buildVertexData(depth?: number): VertexData;
  50541. /**
  50542. * Adds a side to the polygon
  50543. * @param positions points that make the polygon
  50544. * @param normals normals of the polygon
  50545. * @param uvs uvs of the polygon
  50546. * @param indices indices of the polygon
  50547. * @param bounds bounds of the polygon
  50548. * @param points points of the polygon
  50549. * @param depth depth of the polygon
  50550. * @param flip flip of the polygon
  50551. */
  50552. private addSide;
  50553. }
  50554. }
  50555. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50556. import { Scene } from "babylonjs/scene";
  50557. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50558. import { Mesh } from "babylonjs/Meshes/mesh";
  50559. /**
  50560. * Class containing static functions to help procedurally build meshes
  50561. */
  50562. export class PolygonBuilder {
  50563. /**
  50564. * Creates a polygon mesh
  50565. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50566. * * 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
  50567. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50570. * * Remember you can only change the shape positions, not their number when updating a polygon
  50571. * @param name defines the name of the mesh
  50572. * @param options defines the options used to create the mesh
  50573. * @param scene defines the hosting scene
  50574. * @param earcutInjection can be used to inject your own earcut reference
  50575. * @returns the polygon mesh
  50576. */
  50577. static CreatePolygon(name: string, options: {
  50578. shape: Vector3[];
  50579. holes?: Vector3[][];
  50580. depth?: number;
  50581. faceUV?: Vector4[];
  50582. faceColors?: Color4[];
  50583. updatable?: boolean;
  50584. sideOrientation?: number;
  50585. frontUVs?: Vector4;
  50586. backUVs?: Vector4;
  50587. }, scene: Scene, earcutInjection?: any): Mesh;
  50588. /**
  50589. * Creates an extruded polygon mesh, with depth in the Y direction.
  50590. * * 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)
  50591. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50592. * @param name defines the name of the mesh
  50593. * @param options defines the options used to create the mesh
  50594. * @param scene defines the hosting scene
  50595. * @param earcutInjection can be used to inject your own earcut reference
  50596. * @returns the polygon mesh
  50597. */
  50598. static ExtrudePolygon(name: string, options: {
  50599. shape: Vector3[];
  50600. holes?: Vector3[][];
  50601. depth?: number;
  50602. faceUV?: Vector4[];
  50603. faceColors?: Color4[];
  50604. updatable?: boolean;
  50605. sideOrientation?: number;
  50606. frontUVs?: Vector4;
  50607. backUVs?: Vector4;
  50608. }, scene: Scene, earcutInjection?: any): Mesh;
  50609. }
  50610. }
  50611. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50612. import { Nullable } from "babylonjs/types";
  50613. import { Scene } from "babylonjs/scene";
  50614. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50615. import { Mesh } from "babylonjs/Meshes/mesh";
  50616. /**
  50617. * Class containing static functions to help procedurally build meshes
  50618. */
  50619. export class ShapeBuilder {
  50620. /**
  50621. * 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.
  50622. * * 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.
  50623. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50624. * * 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.
  50625. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50626. * * 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
  50627. * * 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
  50628. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50631. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50633. * @param name defines the name of the mesh
  50634. * @param options defines the options used to create the mesh
  50635. * @param scene defines the hosting scene
  50636. * @returns the extruded shape mesh
  50637. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50639. */
  50640. static ExtrudeShape(name: string, options: {
  50641. shape: Vector3[];
  50642. path: Vector3[];
  50643. scale?: number;
  50644. rotation?: number;
  50645. cap?: number;
  50646. updatable?: boolean;
  50647. sideOrientation?: number;
  50648. frontUVs?: Vector4;
  50649. backUVs?: Vector4;
  50650. instance?: Mesh;
  50651. invertUV?: boolean;
  50652. }, scene?: Nullable<Scene>): Mesh;
  50653. /**
  50654. * Creates an custom extruded shape mesh.
  50655. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50656. * * 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.
  50657. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50658. * * 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
  50659. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50660. * * 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
  50661. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50662. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50663. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50664. * * 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
  50665. * * 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
  50666. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50669. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50671. * @param name defines the name of the mesh
  50672. * @param options defines the options used to create the mesh
  50673. * @param scene defines the hosting scene
  50674. * @returns the custom extruded shape mesh
  50675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50678. */
  50679. static ExtrudeShapeCustom(name: string, options: {
  50680. shape: Vector3[];
  50681. path: Vector3[];
  50682. scaleFunction?: any;
  50683. rotationFunction?: any;
  50684. ribbonCloseArray?: boolean;
  50685. ribbonClosePath?: boolean;
  50686. cap?: number;
  50687. updatable?: boolean;
  50688. sideOrientation?: number;
  50689. frontUVs?: Vector4;
  50690. backUVs?: Vector4;
  50691. instance?: Mesh;
  50692. invertUV?: boolean;
  50693. }, scene: Scene): Mesh;
  50694. private static _ExtrudeShapeGeneric;
  50695. }
  50696. }
  50697. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50698. import { Scene } from "babylonjs/scene";
  50699. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50700. import { Mesh } from "babylonjs/Meshes/mesh";
  50701. /**
  50702. * Class containing static functions to help procedurally build meshes
  50703. */
  50704. export class LatheBuilder {
  50705. /**
  50706. * Creates lathe mesh.
  50707. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50708. * * 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
  50709. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50710. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50711. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50712. * * 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
  50713. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50714. * * 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
  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 lathe mesh
  50723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50724. */
  50725. static CreateLathe(name: string, options: {
  50726. shape: Vector3[];
  50727. radius?: number;
  50728. tessellation?: number;
  50729. clip?: number;
  50730. arc?: number;
  50731. closed?: boolean;
  50732. updatable?: boolean;
  50733. sideOrientation?: number;
  50734. frontUVs?: Vector4;
  50735. backUVs?: Vector4;
  50736. cap?: number;
  50737. invertUV?: boolean;
  50738. }, scene: Scene): Mesh;
  50739. }
  50740. }
  50741. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50742. import { Scene } from "babylonjs/scene";
  50743. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50744. import { Mesh } from "babylonjs/Meshes/mesh";
  50745. /**
  50746. * Class containing static functions to help procedurally build meshes
  50747. */
  50748. export class TubeBuilder {
  50749. /**
  50750. * Creates a tube mesh.
  50751. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50752. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50753. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50754. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50755. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50756. * * 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)
  50757. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50758. * * 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
  50759. * * 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
  50760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50762. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50764. * @param name defines the name of the mesh
  50765. * @param options defines the options used to create the mesh
  50766. * @param scene defines the hosting scene
  50767. * @returns the tube mesh
  50768. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50769. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50770. */
  50771. static CreateTube(name: string, options: {
  50772. path: Vector3[];
  50773. radius?: number;
  50774. tessellation?: number;
  50775. radiusFunction?: {
  50776. (i: number, distance: number): number;
  50777. };
  50778. cap?: number;
  50779. arc?: number;
  50780. updatable?: boolean;
  50781. sideOrientation?: number;
  50782. frontUVs?: Vector4;
  50783. backUVs?: Vector4;
  50784. instance?: Mesh;
  50785. invertUV?: boolean;
  50786. }, scene: Scene): Mesh;
  50787. }
  50788. }
  50789. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50790. import { Scene } from "babylonjs/scene";
  50791. import { 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 IcoSphereBuilder {
  50797. /**
  50798. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50799. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50800. * * 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`)
  50801. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50802. * * 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
  50803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50806. * @param name defines the name of the mesh
  50807. * @param options defines the options used to create the mesh
  50808. * @param scene defines the hosting scene
  50809. * @returns the icosahedron mesh
  50810. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50811. */
  50812. static CreateIcoSphere(name: string, options: {
  50813. radius?: number;
  50814. radiusX?: number;
  50815. radiusY?: number;
  50816. radiusZ?: number;
  50817. flat?: boolean;
  50818. subdivisions?: number;
  50819. sideOrientation?: number;
  50820. frontUVs?: Vector4;
  50821. backUVs?: Vector4;
  50822. updatable?: boolean;
  50823. }, scene: Scene): Mesh;
  50824. }
  50825. }
  50826. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50827. import { Vector3 } from "babylonjs/Maths/math";
  50828. import { Mesh } from "babylonjs/Meshes/mesh";
  50829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50830. /**
  50831. * Class containing static functions to help procedurally build meshes
  50832. */
  50833. export class DecalBuilder {
  50834. /**
  50835. * Creates a decal mesh.
  50836. * 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
  50837. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50838. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50839. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50840. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50841. * @param name defines the name of the mesh
  50842. * @param sourceMesh defines the mesh where the decal must be applied
  50843. * @param options defines the options used to create the mesh
  50844. * @param scene defines the hosting scene
  50845. * @returns the decal mesh
  50846. * @see https://doc.babylonjs.com/how_to/decals
  50847. */
  50848. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50849. position?: Vector3;
  50850. normal?: Vector3;
  50851. size?: Vector3;
  50852. angle?: number;
  50853. }): Mesh;
  50854. }
  50855. }
  50856. declare module "babylonjs/Meshes/meshBuilder" {
  50857. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50858. import { Nullable } from "babylonjs/types";
  50859. import { Scene } from "babylonjs/scene";
  50860. import { Mesh } from "babylonjs/Meshes/mesh";
  50861. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50862. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50864. /**
  50865. * Class containing static functions to help procedurally build meshes
  50866. */
  50867. export class MeshBuilder {
  50868. /**
  50869. * Creates a box mesh
  50870. * * The parameter `size` sets the size (float) of each box side (default 1)
  50871. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50872. * * 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)
  50873. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50877. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50878. * @param name defines the name of the mesh
  50879. * @param options defines the options used to create the mesh
  50880. * @param scene defines the hosting scene
  50881. * @returns the box mesh
  50882. */
  50883. static CreateBox(name: string, options: {
  50884. size?: number;
  50885. width?: number;
  50886. height?: number;
  50887. depth?: number;
  50888. faceUV?: Vector4[];
  50889. faceColors?: Color4[];
  50890. sideOrientation?: number;
  50891. frontUVs?: Vector4;
  50892. backUVs?: Vector4;
  50893. updatable?: boolean;
  50894. }, scene?: Nullable<Scene>): Mesh;
  50895. /**
  50896. * Creates a sphere mesh
  50897. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50898. * * 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`)
  50899. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50900. * * 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
  50901. * * 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)
  50902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50905. * @param name defines the name of the mesh
  50906. * @param options defines the options used to create the mesh
  50907. * @param scene defines the hosting scene
  50908. * @returns the sphere mesh
  50909. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50910. */
  50911. static CreateSphere(name: string, options: {
  50912. segments?: number;
  50913. diameter?: number;
  50914. diameterX?: number;
  50915. diameterY?: number;
  50916. diameterZ?: number;
  50917. arc?: number;
  50918. slice?: number;
  50919. sideOrientation?: number;
  50920. frontUVs?: Vector4;
  50921. backUVs?: Vector4;
  50922. updatable?: boolean;
  50923. }, scene: any): Mesh;
  50924. /**
  50925. * Creates a plane polygonal mesh. By default, this is a disc
  50926. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50927. * * 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
  50928. * * 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
  50929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50932. * @param name defines the name of the mesh
  50933. * @param options defines the options used to create the mesh
  50934. * @param scene defines the hosting scene
  50935. * @returns the plane polygonal mesh
  50936. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50937. */
  50938. static CreateDisc(name: string, options: {
  50939. radius?: number;
  50940. tessellation?: number;
  50941. arc?: number;
  50942. updatable?: boolean;
  50943. sideOrientation?: number;
  50944. frontUVs?: Vector4;
  50945. backUVs?: Vector4;
  50946. }, scene?: Nullable<Scene>): Mesh;
  50947. /**
  50948. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50949. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50950. * * 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`)
  50951. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50952. * * 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
  50953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50956. * @param name defines the name of the mesh
  50957. * @param options defines the options used to create the mesh
  50958. * @param scene defines the hosting scene
  50959. * @returns the icosahedron mesh
  50960. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50961. */
  50962. static CreateIcoSphere(name: string, options: {
  50963. radius?: number;
  50964. radiusX?: number;
  50965. radiusY?: number;
  50966. radiusZ?: number;
  50967. flat?: boolean;
  50968. subdivisions?: number;
  50969. sideOrientation?: number;
  50970. frontUVs?: Vector4;
  50971. backUVs?: Vector4;
  50972. updatable?: boolean;
  50973. }, scene: Scene): Mesh;
  50974. /**
  50975. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50976. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50977. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50978. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50979. * * 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
  50980. * * 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
  50981. * * 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
  50982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50984. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50985. * * 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
  50986. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50987. * * 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
  50988. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50990. * @param name defines the name of the mesh
  50991. * @param options defines the options used to create the mesh
  50992. * @param scene defines the hosting scene
  50993. * @returns the ribbon mesh
  50994. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50995. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50996. */
  50997. static CreateRibbon(name: string, options: {
  50998. pathArray: Vector3[][];
  50999. closeArray?: boolean;
  51000. closePath?: boolean;
  51001. offset?: number;
  51002. updatable?: boolean;
  51003. sideOrientation?: number;
  51004. frontUVs?: Vector4;
  51005. backUVs?: Vector4;
  51006. instance?: Mesh;
  51007. invertUV?: boolean;
  51008. uvs?: Vector2[];
  51009. colors?: Color4[];
  51010. }, scene?: Nullable<Scene>): Mesh;
  51011. /**
  51012. * Creates a cylinder or a cone mesh
  51013. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51014. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51015. * * 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.
  51016. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51017. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51018. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51019. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51020. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51021. * * 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).
  51022. * * 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
  51023. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51024. * * 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
  51025. * * 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.
  51026. * * If `enclose` is false, a ring surface is one element.
  51027. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51028. * * 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
  51029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51032. * @param name defines the name of the mesh
  51033. * @param options defines the options used to create the mesh
  51034. * @param scene defines the hosting scene
  51035. * @returns the cylinder mesh
  51036. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51037. */
  51038. static CreateCylinder(name: string, options: {
  51039. height?: number;
  51040. diameterTop?: number;
  51041. diameterBottom?: number;
  51042. diameter?: number;
  51043. tessellation?: number;
  51044. subdivisions?: number;
  51045. arc?: number;
  51046. faceColors?: Color4[];
  51047. faceUV?: Vector4[];
  51048. updatable?: boolean;
  51049. hasRings?: boolean;
  51050. enclose?: boolean;
  51051. sideOrientation?: number;
  51052. frontUVs?: Vector4;
  51053. backUVs?: Vector4;
  51054. }, scene: any): Mesh;
  51055. /**
  51056. * Creates a torus mesh
  51057. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51058. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51059. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51063. * @param name defines the name of the mesh
  51064. * @param options defines the options used to create the mesh
  51065. * @param scene defines the hosting scene
  51066. * @returns the torus mesh
  51067. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51068. */
  51069. static CreateTorus(name: string, options: {
  51070. diameter?: number;
  51071. thickness?: number;
  51072. tessellation?: number;
  51073. updatable?: boolean;
  51074. sideOrientation?: number;
  51075. frontUVs?: Vector4;
  51076. backUVs?: Vector4;
  51077. }, scene: any): Mesh;
  51078. /**
  51079. * Creates a torus knot mesh
  51080. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51081. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51082. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51083. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51087. * @param name defines the name of the mesh
  51088. * @param options defines the options used to create the mesh
  51089. * @param scene defines the hosting scene
  51090. * @returns the torus knot mesh
  51091. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51092. */
  51093. static CreateTorusKnot(name: string, options: {
  51094. radius?: number;
  51095. tube?: number;
  51096. radialSegments?: number;
  51097. tubularSegments?: number;
  51098. p?: number;
  51099. q?: number;
  51100. updatable?: boolean;
  51101. sideOrientation?: number;
  51102. frontUVs?: Vector4;
  51103. backUVs?: Vector4;
  51104. }, scene: any): Mesh;
  51105. /**
  51106. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51107. * * 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
  51108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51109. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51110. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51111. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51112. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51113. * * 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
  51114. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51117. * @param name defines the name of the new line system
  51118. * @param options defines the options used to create the line system
  51119. * @param scene defines the hosting scene
  51120. * @returns a new line system mesh
  51121. */
  51122. static CreateLineSystem(name: string, options: {
  51123. lines: Vector3[][];
  51124. updatable?: boolean;
  51125. instance?: Nullable<LinesMesh>;
  51126. colors?: Nullable<Color4[][]>;
  51127. useVertexAlpha?: boolean;
  51128. }, scene: Nullable<Scene>): LinesMesh;
  51129. /**
  51130. * Creates a line mesh
  51131. * 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
  51132. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51133. * * The parameter `points` is an array successive Vector3
  51134. * * 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
  51135. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51136. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51137. * * When updating an instance, remember that only point positions can change, not the number of points
  51138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51140. * @param name defines the name of the new line system
  51141. * @param options defines the options used to create the line system
  51142. * @param scene defines the hosting scene
  51143. * @returns a new line mesh
  51144. */
  51145. static CreateLines(name: string, options: {
  51146. points: Vector3[];
  51147. updatable?: boolean;
  51148. instance?: Nullable<LinesMesh>;
  51149. colors?: Color4[];
  51150. useVertexAlpha?: boolean;
  51151. }, scene?: Nullable<Scene>): LinesMesh;
  51152. /**
  51153. * Creates a dashed line mesh
  51154. * * 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
  51155. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51156. * * The parameter `points` is an array successive Vector3
  51157. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51158. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51159. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51160. * * 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
  51161. * * When updating an instance, remember that only point positions can change, not the number of points
  51162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51163. * @param name defines the name of the mesh
  51164. * @param options defines the options used to create the mesh
  51165. * @param scene defines the hosting scene
  51166. * @returns the dashed line mesh
  51167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51168. */
  51169. static CreateDashedLines(name: string, options: {
  51170. points: Vector3[];
  51171. dashSize?: number;
  51172. gapSize?: number;
  51173. dashNb?: number;
  51174. updatable?: boolean;
  51175. instance?: LinesMesh;
  51176. }, scene?: Nullable<Scene>): LinesMesh;
  51177. /**
  51178. * 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.
  51179. * * 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.
  51180. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51181. * * 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.
  51182. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51183. * * 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
  51184. * * 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
  51185. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51190. * @param name defines the name of the mesh
  51191. * @param options defines the options used to create the mesh
  51192. * @param scene defines the hosting scene
  51193. * @returns the extruded shape mesh
  51194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51196. */
  51197. static ExtrudeShape(name: string, options: {
  51198. shape: Vector3[];
  51199. path: Vector3[];
  51200. scale?: number;
  51201. rotation?: number;
  51202. cap?: number;
  51203. updatable?: boolean;
  51204. sideOrientation?: number;
  51205. frontUVs?: Vector4;
  51206. backUVs?: Vector4;
  51207. instance?: Mesh;
  51208. invertUV?: boolean;
  51209. }, scene?: Nullable<Scene>): Mesh;
  51210. /**
  51211. * Creates an custom extruded shape mesh.
  51212. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51213. * * 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.
  51214. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51215. * * 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
  51216. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51217. * * 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
  51218. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51219. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51220. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51221. * * 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
  51222. * * 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
  51223. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51228. * @param name defines the name of the mesh
  51229. * @param options defines the options used to create the mesh
  51230. * @param scene defines the hosting scene
  51231. * @returns the custom extruded shape mesh
  51232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51235. */
  51236. static ExtrudeShapeCustom(name: string, options: {
  51237. shape: Vector3[];
  51238. path: Vector3[];
  51239. scaleFunction?: any;
  51240. rotationFunction?: any;
  51241. ribbonCloseArray?: boolean;
  51242. ribbonClosePath?: boolean;
  51243. cap?: number;
  51244. updatable?: boolean;
  51245. sideOrientation?: number;
  51246. frontUVs?: Vector4;
  51247. backUVs?: Vector4;
  51248. instance?: Mesh;
  51249. invertUV?: boolean;
  51250. }, scene: Scene): Mesh;
  51251. /**
  51252. * Creates lathe mesh.
  51253. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51254. * * 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
  51255. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51256. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51257. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51258. * * 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
  51259. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51260. * * 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
  51261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51263. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51265. * @param name defines the name of the mesh
  51266. * @param options defines the options used to create the mesh
  51267. * @param scene defines the hosting scene
  51268. * @returns the lathe mesh
  51269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51270. */
  51271. static CreateLathe(name: string, options: {
  51272. shape: Vector3[];
  51273. radius?: number;
  51274. tessellation?: number;
  51275. clip?: number;
  51276. arc?: number;
  51277. closed?: boolean;
  51278. updatable?: boolean;
  51279. sideOrientation?: number;
  51280. frontUVs?: Vector4;
  51281. backUVs?: Vector4;
  51282. cap?: number;
  51283. invertUV?: boolean;
  51284. }, scene: Scene): Mesh;
  51285. /**
  51286. * Creates a plane mesh
  51287. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51288. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51289. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51293. * @param name defines the name of the mesh
  51294. * @param options defines the options used to create the mesh
  51295. * @param scene defines the hosting scene
  51296. * @returns the plane mesh
  51297. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51298. */
  51299. static CreatePlane(name: string, options: {
  51300. size?: number;
  51301. width?: number;
  51302. height?: number;
  51303. sideOrientation?: number;
  51304. frontUVs?: Vector4;
  51305. backUVs?: Vector4;
  51306. updatable?: boolean;
  51307. sourcePlane?: Plane;
  51308. }, scene: Scene): Mesh;
  51309. /**
  51310. * Creates a ground mesh
  51311. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51312. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51314. * @param name defines the name of the mesh
  51315. * @param options defines the options used to create the mesh
  51316. * @param scene defines the hosting scene
  51317. * @returns the ground mesh
  51318. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51319. */
  51320. static CreateGround(name: string, options: {
  51321. width?: number;
  51322. height?: number;
  51323. subdivisions?: number;
  51324. subdivisionsX?: number;
  51325. subdivisionsY?: number;
  51326. updatable?: boolean;
  51327. }, scene: any): Mesh;
  51328. /**
  51329. * Creates a tiled ground mesh
  51330. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51331. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51332. * * 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
  51333. * * 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
  51334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51335. * @param name defines the name of the mesh
  51336. * @param options defines the options used to create the mesh
  51337. * @param scene defines the hosting scene
  51338. * @returns the tiled ground mesh
  51339. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51340. */
  51341. static CreateTiledGround(name: string, options: {
  51342. xmin: number;
  51343. zmin: number;
  51344. xmax: number;
  51345. zmax: number;
  51346. subdivisions?: {
  51347. w: number;
  51348. h: number;
  51349. };
  51350. precision?: {
  51351. w: number;
  51352. h: number;
  51353. };
  51354. updatable?: boolean;
  51355. }, scene: Scene): Mesh;
  51356. /**
  51357. * Creates a ground mesh from a height map
  51358. * * The parameter `url` sets the URL of the height map image resource.
  51359. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51360. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51361. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51362. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51363. * * 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.
  51364. * * 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).
  51365. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51367. * @param name defines the name of the mesh
  51368. * @param url defines the url to the height map
  51369. * @param options defines the options used to create the mesh
  51370. * @param scene defines the hosting scene
  51371. * @returns the ground mesh
  51372. * @see https://doc.babylonjs.com/babylon101/height_map
  51373. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51374. */
  51375. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51376. width?: number;
  51377. height?: number;
  51378. subdivisions?: number;
  51379. minHeight?: number;
  51380. maxHeight?: number;
  51381. colorFilter?: Color3;
  51382. alphaFilter?: number;
  51383. updatable?: boolean;
  51384. onReady?: (mesh: GroundMesh) => void;
  51385. }, scene: Scene): GroundMesh;
  51386. /**
  51387. * Creates a polygon mesh
  51388. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51389. * * 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
  51390. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51393. * * Remember you can only change the shape positions, not their number when updating a polygon
  51394. * @param name defines the name of the mesh
  51395. * @param options defines the options used to create the mesh
  51396. * @param scene defines the hosting scene
  51397. * @param earcutInjection can be used to inject your own earcut reference
  51398. * @returns the polygon mesh
  51399. */
  51400. static CreatePolygon(name: string, options: {
  51401. shape: Vector3[];
  51402. holes?: Vector3[][];
  51403. depth?: number;
  51404. faceUV?: Vector4[];
  51405. faceColors?: Color4[];
  51406. updatable?: boolean;
  51407. sideOrientation?: number;
  51408. frontUVs?: Vector4;
  51409. backUVs?: Vector4;
  51410. }, scene: Scene, earcutInjection?: any): Mesh;
  51411. /**
  51412. * Creates an extruded polygon mesh, with depth in the Y direction.
  51413. * * 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)
  51414. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51415. * @param name defines the name of the mesh
  51416. * @param options defines the options used to create the mesh
  51417. * @param scene defines the hosting scene
  51418. * @param earcutInjection can be used to inject your own earcut reference
  51419. * @returns the polygon mesh
  51420. */
  51421. static ExtrudePolygon(name: string, options: {
  51422. shape: Vector3[];
  51423. holes?: Vector3[][];
  51424. depth?: number;
  51425. faceUV?: Vector4[];
  51426. faceColors?: Color4[];
  51427. updatable?: boolean;
  51428. sideOrientation?: number;
  51429. frontUVs?: Vector4;
  51430. backUVs?: Vector4;
  51431. }, scene: Scene, earcutInjection?: any): Mesh;
  51432. /**
  51433. * Creates a tube mesh.
  51434. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51435. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51436. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51437. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51438. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51439. * * 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)
  51440. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51441. * * 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
  51442. * * 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
  51443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51445. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51447. * @param name defines the name of the mesh
  51448. * @param options defines the options used to create the mesh
  51449. * @param scene defines the hosting scene
  51450. * @returns the tube mesh
  51451. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51452. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51453. */
  51454. static CreateTube(name: string, options: {
  51455. path: Vector3[];
  51456. radius?: number;
  51457. tessellation?: number;
  51458. radiusFunction?: {
  51459. (i: number, distance: number): number;
  51460. };
  51461. cap?: number;
  51462. arc?: number;
  51463. updatable?: boolean;
  51464. sideOrientation?: number;
  51465. frontUVs?: Vector4;
  51466. backUVs?: Vector4;
  51467. instance?: Mesh;
  51468. invertUV?: boolean;
  51469. }, scene: Scene): Mesh;
  51470. /**
  51471. * Creates a polyhedron mesh
  51472. * * 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
  51473. * * The parameter `size` (positive float, default 1) sets the polygon size
  51474. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51475. * * 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`
  51476. * * 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
  51477. * * 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)`)
  51478. * * 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
  51479. * * 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
  51480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51483. * @param name defines the name of the mesh
  51484. * @param options defines the options used to create the mesh
  51485. * @param scene defines the hosting scene
  51486. * @returns the polyhedron mesh
  51487. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51488. */
  51489. static CreatePolyhedron(name: string, options: {
  51490. type?: number;
  51491. size?: number;
  51492. sizeX?: number;
  51493. sizeY?: number;
  51494. sizeZ?: number;
  51495. custom?: any;
  51496. faceUV?: Vector4[];
  51497. faceColors?: Color4[];
  51498. flat?: boolean;
  51499. updatable?: boolean;
  51500. sideOrientation?: number;
  51501. frontUVs?: Vector4;
  51502. backUVs?: Vector4;
  51503. }, scene: Scene): Mesh;
  51504. /**
  51505. * Creates a decal mesh.
  51506. * 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
  51507. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51508. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51509. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51510. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51511. * @param name defines the name of the mesh
  51512. * @param sourceMesh defines the mesh where the decal must be applied
  51513. * @param options defines the options used to create the mesh
  51514. * @param scene defines the hosting scene
  51515. * @returns the decal mesh
  51516. * @see https://doc.babylonjs.com/how_to/decals
  51517. */
  51518. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51519. position?: Vector3;
  51520. normal?: Vector3;
  51521. size?: Vector3;
  51522. angle?: number;
  51523. }): Mesh;
  51524. }
  51525. }
  51526. declare module "babylonjs/Meshes/meshSimplification" {
  51527. import { Mesh } from "babylonjs/Meshes/mesh";
  51528. /**
  51529. * A simplifier interface for future simplification implementations
  51530. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51531. */
  51532. export interface ISimplifier {
  51533. /**
  51534. * Simplification of a given mesh according to the given settings.
  51535. * Since this requires computation, it is assumed that the function runs async.
  51536. * @param settings The settings of the simplification, including quality and distance
  51537. * @param successCallback A callback that will be called after the mesh was simplified.
  51538. * @param errorCallback in case of an error, this callback will be called. optional.
  51539. */
  51540. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51541. }
  51542. /**
  51543. * Expected simplification settings.
  51544. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51545. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51546. */
  51547. export interface ISimplificationSettings {
  51548. /**
  51549. * Gets or sets the expected quality
  51550. */
  51551. quality: number;
  51552. /**
  51553. * Gets or sets the distance when this optimized version should be used
  51554. */
  51555. distance: number;
  51556. /**
  51557. * Gets an already optimized mesh
  51558. */
  51559. optimizeMesh?: boolean;
  51560. }
  51561. /**
  51562. * Class used to specify simplification options
  51563. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51564. */
  51565. export class SimplificationSettings implements ISimplificationSettings {
  51566. /** expected quality */
  51567. quality: number;
  51568. /** distance when this optimized version should be used */
  51569. distance: number;
  51570. /** already optimized mesh */
  51571. optimizeMesh?: boolean | undefined;
  51572. /**
  51573. * Creates a SimplificationSettings
  51574. * @param quality expected quality
  51575. * @param distance distance when this optimized version should be used
  51576. * @param optimizeMesh already optimized mesh
  51577. */
  51578. constructor(
  51579. /** expected quality */
  51580. quality: number,
  51581. /** distance when this optimized version should be used */
  51582. distance: number,
  51583. /** already optimized mesh */
  51584. optimizeMesh?: boolean | undefined);
  51585. }
  51586. /**
  51587. * Interface used to define a simplification task
  51588. */
  51589. export interface ISimplificationTask {
  51590. /**
  51591. * Array of settings
  51592. */
  51593. settings: Array<ISimplificationSettings>;
  51594. /**
  51595. * Simplification type
  51596. */
  51597. simplificationType: SimplificationType;
  51598. /**
  51599. * Mesh to simplify
  51600. */
  51601. mesh: Mesh;
  51602. /**
  51603. * Callback called on success
  51604. */
  51605. successCallback?: () => void;
  51606. /**
  51607. * Defines if parallel processing can be used
  51608. */
  51609. parallelProcessing: boolean;
  51610. }
  51611. /**
  51612. * Queue used to order the simplification tasks
  51613. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51614. */
  51615. export class SimplificationQueue {
  51616. private _simplificationArray;
  51617. /**
  51618. * Gets a boolean indicating that the process is still running
  51619. */
  51620. running: boolean;
  51621. /**
  51622. * Creates a new queue
  51623. */
  51624. constructor();
  51625. /**
  51626. * Adds a new simplification task
  51627. * @param task defines a task to add
  51628. */
  51629. addTask(task: ISimplificationTask): void;
  51630. /**
  51631. * Execute next task
  51632. */
  51633. executeNext(): void;
  51634. /**
  51635. * Execute a simplification task
  51636. * @param task defines the task to run
  51637. */
  51638. runSimplification(task: ISimplificationTask): void;
  51639. private getSimplifier;
  51640. }
  51641. /**
  51642. * The implemented types of simplification
  51643. * At the moment only Quadratic Error Decimation is implemented
  51644. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51645. */
  51646. export enum SimplificationType {
  51647. /** Quadratic error decimation */
  51648. QUADRATIC = 0
  51649. }
  51650. }
  51651. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51652. import { Scene } from "babylonjs/scene";
  51653. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51654. import { ISceneComponent } from "babylonjs/sceneComponent";
  51655. module "babylonjs/scene" {
  51656. interface Scene {
  51657. /** @hidden (Backing field) */
  51658. _simplificationQueue: SimplificationQueue;
  51659. /**
  51660. * Gets or sets the simplification queue attached to the scene
  51661. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51662. */
  51663. simplificationQueue: SimplificationQueue;
  51664. }
  51665. }
  51666. module "babylonjs/Meshes/mesh" {
  51667. interface Mesh {
  51668. /**
  51669. * Simplify the mesh according to the given array of settings.
  51670. * Function will return immediately and will simplify async
  51671. * @param settings a collection of simplification settings
  51672. * @param parallelProcessing should all levels calculate parallel or one after the other
  51673. * @param simplificationType the type of simplification to run
  51674. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51675. * @returns the current mesh
  51676. */
  51677. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51678. }
  51679. }
  51680. /**
  51681. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51682. * created in a scene
  51683. */
  51684. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51685. /**
  51686. * The component name helpfull to identify the component in the list of scene components.
  51687. */
  51688. readonly name: string;
  51689. /**
  51690. * The scene the component belongs to.
  51691. */
  51692. scene: Scene;
  51693. /**
  51694. * Creates a new instance of the component for the given scene
  51695. * @param scene Defines the scene to register the component in
  51696. */
  51697. constructor(scene: Scene);
  51698. /**
  51699. * Registers the component in a given scene
  51700. */
  51701. register(): void;
  51702. /**
  51703. * Rebuilds the elements related to this component in case of
  51704. * context lost for instance.
  51705. */
  51706. rebuild(): void;
  51707. /**
  51708. * Disposes the component and the associated ressources
  51709. */
  51710. dispose(): void;
  51711. private _beforeCameraUpdate;
  51712. }
  51713. }
  51714. declare module "babylonjs/Meshes/Builders/index" {
  51715. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51716. export * from "babylonjs/Meshes/Builders/discBuilder";
  51717. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51718. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51719. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51720. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51721. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51722. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51723. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51724. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51725. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51726. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51727. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51728. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51729. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51730. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51731. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51732. }
  51733. declare module "babylonjs/Meshes/index" {
  51734. export * from "babylonjs/Meshes/abstractMesh";
  51735. export * from "babylonjs/Meshes/buffer";
  51736. export * from "babylonjs/Meshes/Compression/index";
  51737. export * from "babylonjs/Meshes/csg";
  51738. export * from "babylonjs/Meshes/geometry";
  51739. export * from "babylonjs/Meshes/groundMesh";
  51740. export * from "babylonjs/Meshes/trailMesh";
  51741. export * from "babylonjs/Meshes/instancedMesh";
  51742. export * from "babylonjs/Meshes/linesMesh";
  51743. export * from "babylonjs/Meshes/mesh";
  51744. export * from "babylonjs/Meshes/mesh.vertexData";
  51745. export * from "babylonjs/Meshes/meshBuilder";
  51746. export * from "babylonjs/Meshes/meshSimplification";
  51747. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51748. export * from "babylonjs/Meshes/polygonMesh";
  51749. export * from "babylonjs/Meshes/subMesh";
  51750. export * from "babylonjs/Meshes/transformNode";
  51751. export * from "babylonjs/Meshes/Builders/index";
  51752. }
  51753. declare module "babylonjs/Morph/index" {
  51754. export * from "babylonjs/Morph/morphTarget";
  51755. export * from "babylonjs/Morph/morphTargetManager";
  51756. }
  51757. declare module "babylonjs/Offline/database" {
  51758. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51759. /**
  51760. * Class used to enable access to IndexedDB
  51761. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51762. */
  51763. export class Database implements IOfflineProvider {
  51764. private _callbackManifestChecked;
  51765. private _currentSceneUrl;
  51766. private _db;
  51767. private _enableSceneOffline;
  51768. private _enableTexturesOffline;
  51769. private _manifestVersionFound;
  51770. private _mustUpdateRessources;
  51771. private _hasReachedQuota;
  51772. private _isSupported;
  51773. private _idbFactory;
  51774. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51775. private static IsUASupportingBlobStorage;
  51776. /**
  51777. * Gets a boolean indicating if Database storate is enabled (off by default)
  51778. */
  51779. static IDBStorageEnabled: boolean;
  51780. /**
  51781. * Gets a boolean indicating if scene must be saved in the database
  51782. */
  51783. readonly enableSceneOffline: boolean;
  51784. /**
  51785. * Gets a boolean indicating if textures must be saved in the database
  51786. */
  51787. readonly enableTexturesOffline: boolean;
  51788. /**
  51789. * Creates a new Database
  51790. * @param urlToScene defines the url to load the scene
  51791. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51792. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51793. */
  51794. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51795. private static _ParseURL;
  51796. private static _ReturnFullUrlLocation;
  51797. private _checkManifestFile;
  51798. /**
  51799. * Open the database and make it available
  51800. * @param successCallback defines the callback to call on success
  51801. * @param errorCallback defines the callback to call on error
  51802. */
  51803. open(successCallback: () => void, errorCallback: () => void): void;
  51804. /**
  51805. * Loads an image from the database
  51806. * @param url defines the url to load from
  51807. * @param image defines the target DOM image
  51808. */
  51809. loadImage(url: string, image: HTMLImageElement): void;
  51810. private _loadImageFromDBAsync;
  51811. private _saveImageIntoDBAsync;
  51812. private _checkVersionFromDB;
  51813. private _loadVersionFromDBAsync;
  51814. private _saveVersionIntoDBAsync;
  51815. /**
  51816. * Loads a file from database
  51817. * @param url defines the URL to load from
  51818. * @param sceneLoaded defines a callback to call on success
  51819. * @param progressCallBack defines a callback to call when progress changed
  51820. * @param errorCallback defines a callback to call on error
  51821. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51822. */
  51823. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51824. private _loadFileAsync;
  51825. private _saveFileAsync;
  51826. /**
  51827. * Validates if xhr data is correct
  51828. * @param xhr defines the request to validate
  51829. * @param dataType defines the expected data type
  51830. * @returns true if data is correct
  51831. */
  51832. private static _ValidateXHRData;
  51833. }
  51834. }
  51835. declare module "babylonjs/Offline/index" {
  51836. export * from "babylonjs/Offline/database";
  51837. export * from "babylonjs/Offline/IOfflineProvider";
  51838. }
  51839. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51840. /** @hidden */
  51841. export var gpuUpdateParticlesPixelShader: {
  51842. name: string;
  51843. shader: string;
  51844. };
  51845. }
  51846. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51847. /** @hidden */
  51848. export var gpuUpdateParticlesVertexShader: {
  51849. name: string;
  51850. shader: string;
  51851. };
  51852. }
  51853. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51854. /** @hidden */
  51855. export var clipPlaneFragmentDeclaration2: {
  51856. name: string;
  51857. shader: string;
  51858. };
  51859. }
  51860. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51861. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51862. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51863. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51864. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51865. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51866. /** @hidden */
  51867. export var gpuRenderParticlesPixelShader: {
  51868. name: string;
  51869. shader: string;
  51870. };
  51871. }
  51872. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51873. /** @hidden */
  51874. export var clipPlaneVertexDeclaration2: {
  51875. name: string;
  51876. shader: string;
  51877. };
  51878. }
  51879. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51880. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51881. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51882. /** @hidden */
  51883. export var gpuRenderParticlesVertexShader: {
  51884. name: string;
  51885. shader: string;
  51886. };
  51887. }
  51888. declare module "babylonjs/Particles/gpuParticleSystem" {
  51889. import { Nullable } from "babylonjs/types";
  51890. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51891. import { Observable } from "babylonjs/Misc/observable";
  51892. import { Color4, Color3 } from "babylonjs/Maths/math";
  51893. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51894. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51895. import { Scene, IDisposable } from "babylonjs/scene";
  51896. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51897. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51898. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51899. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51900. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51901. /**
  51902. * This represents a GPU particle system in Babylon
  51903. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51904. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51905. */
  51906. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51907. /**
  51908. * The layer mask we are rendering the particles through.
  51909. */
  51910. layerMask: number;
  51911. private _capacity;
  51912. private _activeCount;
  51913. private _currentActiveCount;
  51914. private _accumulatedCount;
  51915. private _renderEffect;
  51916. private _updateEffect;
  51917. private _buffer0;
  51918. private _buffer1;
  51919. private _spriteBuffer;
  51920. private _updateVAO;
  51921. private _renderVAO;
  51922. private _targetIndex;
  51923. private _sourceBuffer;
  51924. private _targetBuffer;
  51925. private _engine;
  51926. private _currentRenderId;
  51927. private _started;
  51928. private _stopped;
  51929. private _timeDelta;
  51930. private _randomTexture;
  51931. private _randomTexture2;
  51932. private _attributesStrideSize;
  51933. private _updateEffectOptions;
  51934. private _randomTextureSize;
  51935. private _actualFrame;
  51936. private readonly _rawTextureWidth;
  51937. /**
  51938. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51939. */
  51940. static readonly IsSupported: boolean;
  51941. /**
  51942. * An event triggered when the system is disposed.
  51943. */
  51944. onDisposeObservable: Observable<GPUParticleSystem>;
  51945. /**
  51946. * Gets the maximum number of particles active at the same time.
  51947. * @returns The max number of active particles.
  51948. */
  51949. getCapacity(): number;
  51950. /**
  51951. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51952. * to override the particles.
  51953. */
  51954. forceDepthWrite: boolean;
  51955. /**
  51956. * Gets or set the number of active particles
  51957. */
  51958. activeParticleCount: number;
  51959. private _preWarmDone;
  51960. /**
  51961. * Is this system ready to be used/rendered
  51962. * @return true if the system is ready
  51963. */
  51964. isReady(): boolean;
  51965. /**
  51966. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51967. * @returns True if it has been started, otherwise false.
  51968. */
  51969. isStarted(): boolean;
  51970. /**
  51971. * Starts the particle system and begins to emit
  51972. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51973. */
  51974. start(delay?: number): void;
  51975. /**
  51976. * Stops the particle system.
  51977. */
  51978. stop(): void;
  51979. /**
  51980. * Remove all active particles
  51981. */
  51982. reset(): void;
  51983. /**
  51984. * Returns the string "GPUParticleSystem"
  51985. * @returns a string containing the class name
  51986. */
  51987. getClassName(): string;
  51988. private _colorGradientsTexture;
  51989. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51990. /**
  51991. * Adds a new color gradient
  51992. * @param gradient defines the gradient to use (between 0 and 1)
  51993. * @param color1 defines the color to affect to the specified gradient
  51994. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51995. * @returns the current particle system
  51996. */
  51997. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51998. /**
  51999. * Remove a specific color gradient
  52000. * @param gradient defines the gradient to remove
  52001. * @returns the current particle system
  52002. */
  52003. removeColorGradient(gradient: number): GPUParticleSystem;
  52004. private _angularSpeedGradientsTexture;
  52005. private _sizeGradientsTexture;
  52006. private _velocityGradientsTexture;
  52007. private _limitVelocityGradientsTexture;
  52008. private _dragGradientsTexture;
  52009. private _addFactorGradient;
  52010. /**
  52011. * Adds a new size gradient
  52012. * @param gradient defines the gradient to use (between 0 and 1)
  52013. * @param factor defines the size factor to affect to the specified gradient
  52014. * @returns the current particle system
  52015. */
  52016. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52017. /**
  52018. * Remove a specific size gradient
  52019. * @param gradient defines the gradient to remove
  52020. * @returns the current particle system
  52021. */
  52022. removeSizeGradient(gradient: number): GPUParticleSystem;
  52023. /**
  52024. * Adds a new angular speed gradient
  52025. * @param gradient defines the gradient to use (between 0 and 1)
  52026. * @param factor defines the angular speed to affect to the specified gradient
  52027. * @returns the current particle system
  52028. */
  52029. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52030. /**
  52031. * Remove a specific angular speed gradient
  52032. * @param gradient defines the gradient to remove
  52033. * @returns the current particle system
  52034. */
  52035. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52036. /**
  52037. * Adds a new velocity gradient
  52038. * @param gradient defines the gradient to use (between 0 and 1)
  52039. * @param factor defines the velocity to affect to the specified gradient
  52040. * @returns the current particle system
  52041. */
  52042. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52043. /**
  52044. * Remove a specific velocity gradient
  52045. * @param gradient defines the gradient to remove
  52046. * @returns the current particle system
  52047. */
  52048. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52049. /**
  52050. * Adds a new limit velocity gradient
  52051. * @param gradient defines the gradient to use (between 0 and 1)
  52052. * @param factor defines the limit velocity value to affect to the specified gradient
  52053. * @returns the current particle system
  52054. */
  52055. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52056. /**
  52057. * Remove a specific limit velocity gradient
  52058. * @param gradient defines the gradient to remove
  52059. * @returns the current particle system
  52060. */
  52061. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52062. /**
  52063. * Adds a new drag gradient
  52064. * @param gradient defines the gradient to use (between 0 and 1)
  52065. * @param factor defines the drag value to affect to the specified gradient
  52066. * @returns the current particle system
  52067. */
  52068. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52069. /**
  52070. * Remove a specific drag gradient
  52071. * @param gradient defines the gradient to remove
  52072. * @returns the current particle system
  52073. */
  52074. removeDragGradient(gradient: number): GPUParticleSystem;
  52075. /**
  52076. * Not supported by GPUParticleSystem
  52077. * @param gradient defines the gradient to use (between 0 and 1)
  52078. * @param factor defines the emit rate value to affect to the specified gradient
  52079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52080. * @returns the current particle system
  52081. */
  52082. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52083. /**
  52084. * Not supported by GPUParticleSystem
  52085. * @param gradient defines the gradient to remove
  52086. * @returns the current particle system
  52087. */
  52088. removeEmitRateGradient(gradient: number): IParticleSystem;
  52089. /**
  52090. * Not supported by GPUParticleSystem
  52091. * @param gradient defines the gradient to use (between 0 and 1)
  52092. * @param factor defines the start size value to affect to the specified gradient
  52093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52094. * @returns the current particle system
  52095. */
  52096. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52097. /**
  52098. * Not supported by GPUParticleSystem
  52099. * @param gradient defines the gradient to remove
  52100. * @returns the current particle system
  52101. */
  52102. removeStartSizeGradient(gradient: number): IParticleSystem;
  52103. /**
  52104. * Not supported by GPUParticleSystem
  52105. * @param gradient defines the gradient to use (between 0 and 1)
  52106. * @param min defines the color remap minimal range
  52107. * @param max defines the color remap maximal range
  52108. * @returns the current particle system
  52109. */
  52110. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52111. /**
  52112. * Not supported by GPUParticleSystem
  52113. * @param gradient defines the gradient to remove
  52114. * @returns the current particle system
  52115. */
  52116. removeColorRemapGradient(): IParticleSystem;
  52117. /**
  52118. * Not supported by GPUParticleSystem
  52119. * @param gradient defines the gradient to use (between 0 and 1)
  52120. * @param min defines the alpha remap minimal range
  52121. * @param max defines the alpha remap maximal range
  52122. * @returns the current particle system
  52123. */
  52124. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52125. /**
  52126. * Not supported by GPUParticleSystem
  52127. * @param gradient defines the gradient to remove
  52128. * @returns the current particle system
  52129. */
  52130. removeAlphaRemapGradient(): IParticleSystem;
  52131. /**
  52132. * Not supported by GPUParticleSystem
  52133. * @param gradient defines the gradient to use (between 0 and 1)
  52134. * @param color defines the color to affect to the specified gradient
  52135. * @returns the current particle system
  52136. */
  52137. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  52138. /**
  52139. * Not supported by GPUParticleSystem
  52140. * @param gradient defines the gradient to remove
  52141. * @returns the current particle system
  52142. */
  52143. removeRampGradient(): IParticleSystem;
  52144. /**
  52145. * Not supported by GPUParticleSystem
  52146. * @returns the list of ramp gradients
  52147. */
  52148. getRampGradients(): Nullable<Array<Color3Gradient>>;
  52149. /**
  52150. * Not supported by GPUParticleSystem
  52151. * Gets or sets a boolean indicating that ramp gradients must be used
  52152. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  52153. */
  52154. useRampGradients: boolean;
  52155. /**
  52156. * Not supported by GPUParticleSystem
  52157. * @param gradient defines the gradient to use (between 0 and 1)
  52158. * @param factor defines the life time factor to affect to the specified gradient
  52159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52160. * @returns the current particle system
  52161. */
  52162. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52163. /**
  52164. * Not supported by GPUParticleSystem
  52165. * @param gradient defines the gradient to remove
  52166. * @returns the current particle system
  52167. */
  52168. removeLifeTimeGradient(gradient: number): IParticleSystem;
  52169. /**
  52170. * Instantiates a GPU particle system.
  52171. * 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.
  52172. * @param name The name of the particle system
  52173. * @param options The options used to create the system
  52174. * @param scene The scene the particle system belongs to
  52175. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  52176. */
  52177. constructor(name: string, options: Partial<{
  52178. capacity: number;
  52179. randomTextureSize: number;
  52180. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  52181. protected _reset(): void;
  52182. private _createUpdateVAO;
  52183. private _createRenderVAO;
  52184. private _initialize;
  52185. /** @hidden */
  52186. _recreateUpdateEffect(): void;
  52187. /** @hidden */
  52188. _recreateRenderEffect(): void;
  52189. /**
  52190. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  52191. * @param preWarm defines if we are in the pre-warmimg phase
  52192. */
  52193. animate(preWarm?: boolean): void;
  52194. private _createFactorGradientTexture;
  52195. private _createSizeGradientTexture;
  52196. private _createAngularSpeedGradientTexture;
  52197. private _createVelocityGradientTexture;
  52198. private _createLimitVelocityGradientTexture;
  52199. private _createDragGradientTexture;
  52200. private _createColorGradientTexture;
  52201. /**
  52202. * Renders the particle system in its current state
  52203. * @param preWarm defines if the system should only update the particles but not render them
  52204. * @returns the current number of particles
  52205. */
  52206. render(preWarm?: boolean): number;
  52207. /**
  52208. * Rebuilds the particle system
  52209. */
  52210. rebuild(): void;
  52211. private _releaseBuffers;
  52212. private _releaseVAOs;
  52213. /**
  52214. * Disposes the particle system and free the associated resources
  52215. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  52216. */
  52217. dispose(disposeTexture?: boolean): void;
  52218. /**
  52219. * Clones the particle system.
  52220. * @param name The name of the cloned object
  52221. * @param newEmitter The new emitter to use
  52222. * @returns the cloned particle system
  52223. */
  52224. clone(name: string, newEmitter: any): GPUParticleSystem;
  52225. /**
  52226. * Serializes the particle system to a JSON object.
  52227. * @returns the JSON object
  52228. */
  52229. serialize(): any;
  52230. /**
  52231. * Parses a JSON object to create a GPU particle system.
  52232. * @param parsedParticleSystem The JSON object to parse
  52233. * @param scene The scene to create the particle system in
  52234. * @param rootUrl The root url to use to load external dependencies like texture
  52235. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  52236. * @returns the parsed GPU particle system
  52237. */
  52238. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  52239. }
  52240. }
  52241. declare module "babylonjs/Particles/particleSystemSet" {
  52242. import { Nullable } from "babylonjs/types";
  52243. import { Color3 } from "babylonjs/Maths/math";
  52244. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52246. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52247. import { Scene, IDisposable } from "babylonjs/scene";
  52248. /**
  52249. * Represents a set of particle systems working together to create a specific effect
  52250. */
  52251. export class ParticleSystemSet implements IDisposable {
  52252. private _emitterCreationOptions;
  52253. private _emitterNode;
  52254. /**
  52255. * Gets the particle system list
  52256. */
  52257. systems: IParticleSystem[];
  52258. /**
  52259. * Gets the emitter node used with this set
  52260. */
  52261. readonly emitterNode: Nullable<TransformNode>;
  52262. /**
  52263. * Creates a new emitter mesh as a sphere
  52264. * @param options defines the options used to create the sphere
  52265. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  52266. * @param scene defines the hosting scene
  52267. */
  52268. setEmitterAsSphere(options: {
  52269. diameter: number;
  52270. segments: number;
  52271. color: Color3;
  52272. }, renderingGroupId: number, scene: Scene): void;
  52273. /**
  52274. * Starts all particle systems of the set
  52275. * @param emitter defines an optional mesh to use as emitter for the particle systems
  52276. */
  52277. start(emitter?: AbstractMesh): void;
  52278. /**
  52279. * Release all associated resources
  52280. */
  52281. dispose(): void;
  52282. /**
  52283. * Serialize the set into a JSON compatible object
  52284. * @returns a JSON compatible representation of the set
  52285. */
  52286. serialize(): any;
  52287. /**
  52288. * Parse a new ParticleSystemSet from a serialized source
  52289. * @param data defines a JSON compatible representation of the set
  52290. * @param scene defines the hosting scene
  52291. * @param gpu defines if we want GPU particles or CPU particles
  52292. * @returns a new ParticleSystemSet
  52293. */
  52294. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52295. }
  52296. }
  52297. declare module "babylonjs/Particles/particleHelper" {
  52298. import { Nullable } from "babylonjs/types";
  52299. import { Scene } from "babylonjs/scene";
  52300. import { Vector3 } from "babylonjs/Maths/math";
  52301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52302. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52303. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  52304. /**
  52305. * This class is made for on one-liner static method to help creating particle system set.
  52306. */
  52307. export class ParticleHelper {
  52308. /**
  52309. * Gets or sets base Assets URL
  52310. */
  52311. static BaseAssetsUrl: string;
  52312. /**
  52313. * Create a default particle system that you can tweak
  52314. * @param emitter defines the emitter to use
  52315. * @param capacity defines the system capacity (default is 500 particles)
  52316. * @param scene defines the hosting scene
  52317. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52318. * @returns the new Particle system
  52319. */
  52320. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52321. /**
  52322. * This is the main static method (one-liner) of this helper to create different particle systems
  52323. * @param type This string represents the type to the particle system to create
  52324. * @param scene The scene where the particle system should live
  52325. * @param gpu If the system will use gpu
  52326. * @returns the ParticleSystemSet created
  52327. */
  52328. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52329. /**
  52330. * Static function used to export a particle system to a ParticleSystemSet variable.
  52331. * Please note that the emitter shape is not exported
  52332. * @param systems defines the particle systems to export
  52333. * @returns the created particle system set
  52334. */
  52335. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52336. }
  52337. }
  52338. declare module "babylonjs/Particles/particleSystemComponent" {
  52339. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52340. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  52341. import "babylonjs/Shaders/particles.vertex";
  52342. module "babylonjs/Engines/engine" {
  52343. interface Engine {
  52344. /**
  52345. * Create an effect to use with particle systems.
  52346. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52347. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52348. * @param uniformsNames defines a list of attribute names
  52349. * @param samplers defines an array of string used to represent textures
  52350. * @param defines defines the string containing the defines to use to compile the shaders
  52351. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52352. * @param onCompiled defines a function to call when the effect creation is successful
  52353. * @param onError defines a function to call when the effect creation has failed
  52354. * @returns the new Effect
  52355. */
  52356. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52357. }
  52358. }
  52359. module "babylonjs/Meshes/mesh" {
  52360. interface Mesh {
  52361. /**
  52362. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52363. * @returns an array of IParticleSystem
  52364. */
  52365. getEmittedParticleSystems(): IParticleSystem[];
  52366. /**
  52367. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52368. * @returns an array of IParticleSystem
  52369. */
  52370. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52371. }
  52372. }
  52373. /**
  52374. * @hidden
  52375. */
  52376. export var _IDoNeedToBeInTheBuild: number;
  52377. }
  52378. declare module "babylonjs/Particles/index" {
  52379. export * from "babylonjs/Particles/baseParticleSystem";
  52380. export * from "babylonjs/Particles/EmitterTypes/index";
  52381. export * from "babylonjs/Particles/gpuParticleSystem";
  52382. export * from "babylonjs/Particles/IParticleSystem";
  52383. export * from "babylonjs/Particles/particle";
  52384. export * from "babylonjs/Particles/particleHelper";
  52385. export * from "babylonjs/Particles/particleSystem";
  52386. export * from "babylonjs/Particles/particleSystemComponent";
  52387. export * from "babylonjs/Particles/particleSystemSet";
  52388. export * from "babylonjs/Particles/solidParticle";
  52389. export * from "babylonjs/Particles/solidParticleSystem";
  52390. export * from "babylonjs/Particles/subEmitter";
  52391. }
  52392. declare module "babylonjs/Physics/physicsEngineComponent" {
  52393. import { Nullable } from "babylonjs/types";
  52394. import { Observable, Observer } from "babylonjs/Misc/observable";
  52395. import { Vector3 } from "babylonjs/Maths/math";
  52396. import { Mesh } from "babylonjs/Meshes/mesh";
  52397. import { ISceneComponent } from "babylonjs/sceneComponent";
  52398. import { Scene } from "babylonjs/scene";
  52399. import { Node } from "babylonjs/node";
  52400. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52401. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52402. module "babylonjs/scene" {
  52403. interface Scene {
  52404. /** @hidden (Backing field) */
  52405. _physicsEngine: Nullable<IPhysicsEngine>;
  52406. /**
  52407. * Gets the current physics engine
  52408. * @returns a IPhysicsEngine or null if none attached
  52409. */
  52410. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52411. /**
  52412. * Enables physics to the current scene
  52413. * @param gravity defines the scene's gravity for the physics engine
  52414. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52415. * @return a boolean indicating if the physics engine was initialized
  52416. */
  52417. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52418. /**
  52419. * Disables and disposes the physics engine associated with the scene
  52420. */
  52421. disablePhysicsEngine(): void;
  52422. /**
  52423. * Gets a boolean indicating if there is an active physics engine
  52424. * @returns a boolean indicating if there is an active physics engine
  52425. */
  52426. isPhysicsEnabled(): boolean;
  52427. /**
  52428. * Deletes a physics compound impostor
  52429. * @param compound defines the compound to delete
  52430. */
  52431. deleteCompoundImpostor(compound: any): void;
  52432. /**
  52433. * An event triggered when physic simulation is about to be run
  52434. */
  52435. onBeforePhysicsObservable: Observable<Scene>;
  52436. /**
  52437. * An event triggered when physic simulation has been done
  52438. */
  52439. onAfterPhysicsObservable: Observable<Scene>;
  52440. }
  52441. }
  52442. module "babylonjs/Meshes/abstractMesh" {
  52443. interface AbstractMesh {
  52444. /** @hidden */
  52445. _physicsImpostor: Nullable<PhysicsImpostor>;
  52446. /**
  52447. * Gets or sets impostor used for physic simulation
  52448. * @see http://doc.babylonjs.com/features/physics_engine
  52449. */
  52450. physicsImpostor: Nullable<PhysicsImpostor>;
  52451. /**
  52452. * Gets the current physics impostor
  52453. * @see http://doc.babylonjs.com/features/physics_engine
  52454. * @returns a physics impostor or null
  52455. */
  52456. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52457. /** Apply a physic impulse to the mesh
  52458. * @param force defines the force to apply
  52459. * @param contactPoint defines where to apply the force
  52460. * @returns the current mesh
  52461. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52462. */
  52463. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52464. /**
  52465. * Creates a physic joint between two meshes
  52466. * @param otherMesh defines the other mesh to use
  52467. * @param pivot1 defines the pivot to use on this mesh
  52468. * @param pivot2 defines the pivot to use on the other mesh
  52469. * @param options defines additional options (can be plugin dependent)
  52470. * @returns the current mesh
  52471. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52472. */
  52473. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52474. /** @hidden */
  52475. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52476. }
  52477. }
  52478. /**
  52479. * Defines the physics engine scene component responsible to manage a physics engine
  52480. */
  52481. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52482. /**
  52483. * The component name helpful to identify the component in the list of scene components.
  52484. */
  52485. readonly name: string;
  52486. /**
  52487. * The scene the component belongs to.
  52488. */
  52489. scene: Scene;
  52490. /**
  52491. * Creates a new instance of the component for the given scene
  52492. * @param scene Defines the scene to register the component in
  52493. */
  52494. constructor(scene: Scene);
  52495. /**
  52496. * Registers the component in a given scene
  52497. */
  52498. register(): void;
  52499. /**
  52500. * Rebuilds the elements related to this component in case of
  52501. * context lost for instance.
  52502. */
  52503. rebuild(): void;
  52504. /**
  52505. * Disposes the component and the associated ressources
  52506. */
  52507. dispose(): void;
  52508. }
  52509. }
  52510. declare module "babylonjs/Physics/physicsHelper" {
  52511. import { Nullable } from "babylonjs/types";
  52512. import { Vector3 } from "babylonjs/Maths/math";
  52513. import { Mesh } from "babylonjs/Meshes/mesh";
  52514. import { Scene } from "babylonjs/scene";
  52515. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52516. /**
  52517. * A helper for physics simulations
  52518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52519. */
  52520. export class PhysicsHelper {
  52521. private _scene;
  52522. private _physicsEngine;
  52523. /**
  52524. * Initializes the Physics helper
  52525. * @param scene Babylon.js scene
  52526. */
  52527. constructor(scene: Scene);
  52528. /**
  52529. * Applies a radial explosion impulse
  52530. * @param origin the origin of the explosion
  52531. * @param radiusOrEventOptions the radius or the options of radial explosion
  52532. * @param strength the explosion strength
  52533. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52534. * @returns A physics radial explosion event, or null
  52535. */
  52536. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52537. /**
  52538. * Applies a radial explosion force
  52539. * @param origin the origin of the explosion
  52540. * @param radiusOrEventOptions the radius or the options of radial explosion
  52541. * @param strength the explosion strength
  52542. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52543. * @returns A physics radial explosion event, or null
  52544. */
  52545. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52546. /**
  52547. * Creates a gravitational field
  52548. * @param origin the origin of the explosion
  52549. * @param radiusOrEventOptions the radius or the options of radial explosion
  52550. * @param strength the explosion strength
  52551. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52552. * @returns A physics gravitational field event, or null
  52553. */
  52554. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52555. /**
  52556. * Creates a physics updraft event
  52557. * @param origin the origin of the updraft
  52558. * @param radiusOrEventOptions the radius or the options of the updraft
  52559. * @param strength the strength of the updraft
  52560. * @param height the height of the updraft
  52561. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52562. * @returns A physics updraft event, or null
  52563. */
  52564. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52565. /**
  52566. * Creates a physics vortex event
  52567. * @param origin the of the vortex
  52568. * @param radiusOrEventOptions the radius or the options of the vortex
  52569. * @param strength the strength of the vortex
  52570. * @param height the height of the vortex
  52571. * @returns a Physics vortex event, or null
  52572. * A physics vortex event or null
  52573. */
  52574. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52575. }
  52576. /**
  52577. * Represents a physics radial explosion event
  52578. */
  52579. class PhysicsRadialExplosionEvent {
  52580. private _scene;
  52581. private _options;
  52582. private _sphere;
  52583. private _dataFetched;
  52584. /**
  52585. * Initializes a radial explosioin event
  52586. * @param _scene BabylonJS scene
  52587. * @param _options The options for the vortex event
  52588. */
  52589. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52590. /**
  52591. * Returns the data related to the radial explosion event (sphere).
  52592. * @returns The radial explosion event data
  52593. */
  52594. getData(): PhysicsRadialExplosionEventData;
  52595. /**
  52596. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52597. * @param impostor A physics imposter
  52598. * @param origin the origin of the explosion
  52599. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52600. */
  52601. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  52602. /**
  52603. * Disposes the sphere.
  52604. * @param force Specifies if the sphere should be disposed by force
  52605. */
  52606. dispose(force?: boolean): void;
  52607. /*** Helpers ***/
  52608. private _prepareSphere;
  52609. private _intersectsWithSphere;
  52610. }
  52611. /**
  52612. * Represents a gravitational field event
  52613. */
  52614. class PhysicsGravitationalFieldEvent {
  52615. private _physicsHelper;
  52616. private _scene;
  52617. private _origin;
  52618. private _options;
  52619. private _tickCallback;
  52620. private _sphere;
  52621. private _dataFetched;
  52622. /**
  52623. * Initializes the physics gravitational field event
  52624. * @param _physicsHelper A physics helper
  52625. * @param _scene BabylonJS scene
  52626. * @param _origin The origin position of the gravitational field event
  52627. * @param _options The options for the vortex event
  52628. */
  52629. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52630. /**
  52631. * Returns the data related to the gravitational field event (sphere).
  52632. * @returns A gravitational field event
  52633. */
  52634. getData(): PhysicsGravitationalFieldEventData;
  52635. /**
  52636. * Enables the gravitational field.
  52637. */
  52638. enable(): void;
  52639. /**
  52640. * Disables the gravitational field.
  52641. */
  52642. disable(): void;
  52643. /**
  52644. * Disposes the sphere.
  52645. * @param force The force to dispose from the gravitational field event
  52646. */
  52647. dispose(force?: boolean): void;
  52648. private _tick;
  52649. }
  52650. /**
  52651. * Represents a physics updraft event
  52652. */
  52653. class PhysicsUpdraftEvent {
  52654. private _scene;
  52655. private _origin;
  52656. private _options;
  52657. private _physicsEngine;
  52658. private _originTop;
  52659. private _originDirection;
  52660. private _tickCallback;
  52661. private _cylinder;
  52662. private _cylinderPosition;
  52663. private _dataFetched;
  52664. /**
  52665. * Initializes the physics updraft event
  52666. * @param _scene BabylonJS scene
  52667. * @param _origin The origin position of the updraft
  52668. * @param _options The options for the updraft event
  52669. */
  52670. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52671. /**
  52672. * Returns the data related to the updraft event (cylinder).
  52673. * @returns A physics updraft event
  52674. */
  52675. getData(): PhysicsUpdraftEventData;
  52676. /**
  52677. * Enables the updraft.
  52678. */
  52679. enable(): void;
  52680. /**
  52681. * Disables the updraft.
  52682. */
  52683. disable(): void;
  52684. /**
  52685. * Disposes the cylinder.
  52686. * @param force Specifies if the updraft should be disposed by force
  52687. */
  52688. dispose(force?: boolean): void;
  52689. private getImpostorForceAndContactPoint;
  52690. private _tick;
  52691. /*** Helpers ***/
  52692. private _prepareCylinder;
  52693. private _intersectsWithCylinder;
  52694. }
  52695. /**
  52696. * Represents a physics vortex event
  52697. */
  52698. class PhysicsVortexEvent {
  52699. private _scene;
  52700. private _origin;
  52701. private _options;
  52702. private _physicsEngine;
  52703. private _originTop;
  52704. private _tickCallback;
  52705. private _cylinder;
  52706. private _cylinderPosition;
  52707. private _dataFetched;
  52708. /**
  52709. * Initializes the physics vortex event
  52710. * @param _scene The BabylonJS scene
  52711. * @param _origin The origin position of the vortex
  52712. * @param _options The options for the vortex event
  52713. */
  52714. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52715. /**
  52716. * Returns the data related to the vortex event (cylinder).
  52717. * @returns The physics vortex event data
  52718. */
  52719. getData(): PhysicsVortexEventData;
  52720. /**
  52721. * Enables the vortex.
  52722. */
  52723. enable(): void;
  52724. /**
  52725. * Disables the cortex.
  52726. */
  52727. disable(): void;
  52728. /**
  52729. * Disposes the sphere.
  52730. * @param force
  52731. */
  52732. dispose(force?: boolean): void;
  52733. private getImpostorForceAndContactPoint;
  52734. private _tick;
  52735. /*** Helpers ***/
  52736. private _prepareCylinder;
  52737. private _intersectsWithCylinder;
  52738. }
  52739. /**
  52740. * Options fot the radial explosion event
  52741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52742. */
  52743. export class PhysicsRadialExplosionEventOptions {
  52744. /**
  52745. * The radius of the sphere for the radial explosion.
  52746. */
  52747. radius: number;
  52748. /**
  52749. * The strenth of the explosion.
  52750. */
  52751. strength: number;
  52752. /**
  52753. * The strenght of the force in correspondence to the distance of the affected object
  52754. */
  52755. falloff: PhysicsRadialImpulseFalloff;
  52756. /**
  52757. * Sphere options for the radial explosion.
  52758. */
  52759. sphere: {
  52760. segments: number;
  52761. diameter: number;
  52762. };
  52763. }
  52764. /**
  52765. * Options fot the updraft event
  52766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52767. */
  52768. export class PhysicsUpdraftEventOptions {
  52769. /**
  52770. * The radius of the cylinder for the vortex
  52771. */
  52772. radius: number;
  52773. /**
  52774. * The strenth of the updraft.
  52775. */
  52776. strength: number;
  52777. /**
  52778. * The height of the cylinder for the updraft.
  52779. */
  52780. height: number;
  52781. /**
  52782. * The mode for the the updraft.
  52783. */
  52784. updraftMode: PhysicsUpdraftMode;
  52785. }
  52786. /**
  52787. * Options fot the vortex event
  52788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52789. */
  52790. export class PhysicsVortexEventOptions {
  52791. /**
  52792. * The radius of the cylinder for the vortex
  52793. */
  52794. radius: number;
  52795. /**
  52796. * The strenth of the vortex.
  52797. */
  52798. strength: number;
  52799. /**
  52800. * The height of the cylinder for the vortex.
  52801. */
  52802. height: number;
  52803. /**
  52804. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52805. */
  52806. centripetalForceThreshold: number;
  52807. /**
  52808. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52809. */
  52810. centripetalForceMultiplier: number;
  52811. /**
  52812. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52813. */
  52814. centrifugalForceMultiplier: number;
  52815. /**
  52816. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52817. */
  52818. updraftForceMultiplier: number;
  52819. }
  52820. /**
  52821. * The strenght of the force in correspondence to the distance of the affected object
  52822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52823. */
  52824. export enum PhysicsRadialImpulseFalloff {
  52825. /** Defines that impulse is constant in strength across it's whole radius */
  52826. Constant = 0,
  52827. /** Defines that impulse gets weaker if it's further from the origin */
  52828. Linear = 1
  52829. }
  52830. /**
  52831. * The strength of the force in correspondence to the distance of the affected object
  52832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52833. */
  52834. export enum PhysicsUpdraftMode {
  52835. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52836. Center = 0,
  52837. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52838. Perpendicular = 1
  52839. }
  52840. /**
  52841. * Interface for a physics force and contact point
  52842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52843. */
  52844. export interface PhysicsForceAndContactPoint {
  52845. /**
  52846. * The force applied at the contact point
  52847. */
  52848. force: Vector3;
  52849. /**
  52850. * The contact point
  52851. */
  52852. contactPoint: Vector3;
  52853. }
  52854. /**
  52855. * Interface for radial explosion event data
  52856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52857. */
  52858. export interface PhysicsRadialExplosionEventData {
  52859. /**
  52860. * A sphere used for the radial explosion event
  52861. */
  52862. sphere: Mesh;
  52863. }
  52864. /**
  52865. * Interface for gravitational field event data
  52866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52867. */
  52868. export interface PhysicsGravitationalFieldEventData {
  52869. /**
  52870. * A sphere mesh used for the gravitational field event
  52871. */
  52872. sphere: Mesh;
  52873. }
  52874. /**
  52875. * Interface for updraft event data
  52876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52877. */
  52878. export interface PhysicsUpdraftEventData {
  52879. /**
  52880. * A cylinder used for the updraft event
  52881. */
  52882. cylinder: Mesh;
  52883. }
  52884. /**
  52885. * Interface for vortex event data
  52886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52887. */
  52888. export interface PhysicsVortexEventData {
  52889. /**
  52890. * A cylinder used for the vortex event
  52891. */
  52892. cylinder: Mesh;
  52893. }
  52894. }
  52895. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52896. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52897. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52898. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52899. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52900. import { Nullable } from "babylonjs/types";
  52901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52902. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52903. /**
  52904. * AmmoJS Physics plugin
  52905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52906. * @see https://github.com/kripken/ammo.js/
  52907. */
  52908. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52909. private _useDeltaForWorldStep;
  52910. /**
  52911. * Reference to the Ammo library
  52912. */
  52913. bjsAMMO: any;
  52914. /**
  52915. * Created ammoJS world which physics bodies are added to
  52916. */
  52917. world: any;
  52918. /**
  52919. * Name of the plugin
  52920. */
  52921. name: string;
  52922. private _timeStep;
  52923. private _fixedTimeStep;
  52924. private _maxSteps;
  52925. private _tmpQuaternion;
  52926. private _tmpAmmoTransform;
  52927. private _tmpAmmoQuaternion;
  52928. private _tmpAmmoConcreteContactResultCallback;
  52929. private _collisionConfiguration;
  52930. private _dispatcher;
  52931. private _overlappingPairCache;
  52932. private _solver;
  52933. private _softBodySolver;
  52934. private _tmpAmmoVectorA;
  52935. private _tmpAmmoVectorB;
  52936. private _tmpAmmoVectorC;
  52937. private _tmpAmmoVectorD;
  52938. private _tmpContactCallbackResult;
  52939. private _tmpAmmoVectorRCA;
  52940. private _tmpAmmoVectorRCB;
  52941. private _raycastResult;
  52942. private static readonly DISABLE_COLLISION_FLAG;
  52943. private static readonly KINEMATIC_FLAG;
  52944. private static readonly DISABLE_DEACTIVATION_FLAG;
  52945. /**
  52946. * Initializes the ammoJS plugin
  52947. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52948. * @param ammoInjection can be used to inject your own ammo reference
  52949. */
  52950. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52951. /**
  52952. * Sets the gravity of the physics world (m/(s^2))
  52953. * @param gravity Gravity to set
  52954. */
  52955. setGravity(gravity: Vector3): void;
  52956. /**
  52957. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52958. * @param timeStep timestep to use in seconds
  52959. */
  52960. setTimeStep(timeStep: number): void;
  52961. /**
  52962. * 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)
  52963. * @param fixedTimeStep fixedTimeStep to use in seconds
  52964. */
  52965. setFixedTimeStep(fixedTimeStep: number): void;
  52966. /**
  52967. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52968. * @param maxSteps the maximum number of steps by the physics engine per frame
  52969. */
  52970. setMaxSteps(maxSteps: number): void;
  52971. /**
  52972. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52973. * @returns the current timestep in seconds
  52974. */
  52975. getTimeStep(): number;
  52976. private _isImpostorInContact;
  52977. private _isImpostorPairInContact;
  52978. private _stepSimulation;
  52979. /**
  52980. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52981. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52982. * After the step the babylon meshes are set to the position of the physics imposters
  52983. * @param delta amount of time to step forward
  52984. * @param impostors array of imposters to update before/after the step
  52985. */
  52986. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52987. /**
  52988. * Update babylon mesh vertices vertices to match physics world object
  52989. * @param impostor imposter to match
  52990. */
  52991. afterSoftStep(impostor: PhysicsImpostor): void;
  52992. private _tmpVector;
  52993. private _tmpMatrix;
  52994. /**
  52995. * Applies an impulse on the imposter
  52996. * @param impostor imposter to apply impulse to
  52997. * @param force amount of force to be applied to the imposter
  52998. * @param contactPoint the location to apply the impulse on the imposter
  52999. */
  53000. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53001. /**
  53002. * Applies a force on the imposter
  53003. * @param impostor imposter to apply force
  53004. * @param force amount of force to be applied to the imposter
  53005. * @param contactPoint the location to apply the force on the imposter
  53006. */
  53007. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53008. /**
  53009. * Creates a physics body using the plugin
  53010. * @param impostor the imposter to create the physics body on
  53011. */
  53012. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53013. /**
  53014. * Removes the physics body from the imposter and disposes of the body's memory
  53015. * @param impostor imposter to remove the physics body from
  53016. */
  53017. removePhysicsBody(impostor: PhysicsImpostor): void;
  53018. /**
  53019. * Generates a joint
  53020. * @param impostorJoint the imposter joint to create the joint with
  53021. */
  53022. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53023. /**
  53024. * Removes a joint
  53025. * @param impostorJoint the imposter joint to remove the joint from
  53026. */
  53027. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53028. private _addMeshVerts;
  53029. /**
  53030. * Initialise the soft body vertices to match its object's (mesh) vertices
  53031. * Softbody vertices (nodes) are in world space and to match this
  53032. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53033. * @param impostor to create the softbody for
  53034. */
  53035. private _softVertexData;
  53036. /**
  53037. * Create an impostor's soft body
  53038. * @param impostor to create the softbody for
  53039. */
  53040. private _createSoftbody;
  53041. /**
  53042. * Create cloth for an impostor
  53043. * @param impostor to create the softbody for
  53044. */
  53045. private _createCloth;
  53046. private _addHullVerts;
  53047. private _createShape;
  53048. /**
  53049. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53050. * @param impostor imposter containing the physics body and babylon object
  53051. */
  53052. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53053. /**
  53054. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53055. * @param impostor imposter containing the physics body and babylon object
  53056. * @param newPosition new position
  53057. * @param newRotation new rotation
  53058. */
  53059. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53060. /**
  53061. * If this plugin is supported
  53062. * @returns true if its supported
  53063. */
  53064. isSupported(): boolean;
  53065. /**
  53066. * Sets the linear velocity of the physics body
  53067. * @param impostor imposter to set the velocity on
  53068. * @param velocity velocity to set
  53069. */
  53070. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53071. /**
  53072. * Sets the angular velocity of the physics body
  53073. * @param impostor imposter to set the velocity on
  53074. * @param velocity velocity to set
  53075. */
  53076. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53077. /**
  53078. * gets the linear velocity
  53079. * @param impostor imposter to get linear velocity from
  53080. * @returns linear velocity
  53081. */
  53082. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53083. /**
  53084. * gets the angular velocity
  53085. * @param impostor imposter to get angular velocity from
  53086. * @returns angular velocity
  53087. */
  53088. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53089. /**
  53090. * Sets the mass of physics body
  53091. * @param impostor imposter to set the mass on
  53092. * @param mass mass to set
  53093. */
  53094. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53095. /**
  53096. * Gets the mass of the physics body
  53097. * @param impostor imposter to get the mass from
  53098. * @returns mass
  53099. */
  53100. getBodyMass(impostor: PhysicsImpostor): number;
  53101. /**
  53102. * Gets friction of the impostor
  53103. * @param impostor impostor to get friction from
  53104. * @returns friction value
  53105. */
  53106. getBodyFriction(impostor: PhysicsImpostor): number;
  53107. /**
  53108. * Sets friction of the impostor
  53109. * @param impostor impostor to set friction on
  53110. * @param friction friction value
  53111. */
  53112. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53113. /**
  53114. * Gets restitution of the impostor
  53115. * @param impostor impostor to get restitution from
  53116. * @returns restitution value
  53117. */
  53118. getBodyRestitution(impostor: PhysicsImpostor): number;
  53119. /**
  53120. * Sets resitution of the impostor
  53121. * @param impostor impostor to set resitution on
  53122. * @param restitution resitution value
  53123. */
  53124. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53125. /**
  53126. * Gets pressure inside the impostor
  53127. * @param impostor impostor to get pressure from
  53128. * @returns pressure value
  53129. */
  53130. getBodyPressure(impostor: PhysicsImpostor): number;
  53131. /**
  53132. * Sets pressure inside a soft body impostor
  53133. * Cloth and rope must remain 0 pressure
  53134. * @param impostor impostor to set pressure on
  53135. * @param pressure pressure value
  53136. */
  53137. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53138. /**
  53139. * Gets stiffness of the impostor
  53140. * @param impostor impostor to get stiffness from
  53141. * @returns pressure value
  53142. */
  53143. getBodyStiffness(impostor: PhysicsImpostor): number;
  53144. /**
  53145. * Sets stiffness of the impostor
  53146. * @param impostor impostor to set stiffness on
  53147. * @param stiffness stiffness value from 0 to 1
  53148. */
  53149. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53150. /**
  53151. * Gets velocityIterations of the impostor
  53152. * @param impostor impostor to get velocity iterations from
  53153. * @returns velocityIterations value
  53154. */
  53155. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53156. /**
  53157. * Sets velocityIterations of the impostor
  53158. * @param impostor impostor to set velocity iterations on
  53159. * @param velocityIterations velocityIterations value
  53160. */
  53161. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53162. /**
  53163. * Gets positionIterations of the impostor
  53164. * @param impostor impostor to get position iterations from
  53165. * @returns positionIterations value
  53166. */
  53167. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53168. /**
  53169. * Sets positionIterations of the impostor
  53170. * @param impostor impostor to set position on
  53171. * @param positionIterations positionIterations value
  53172. */
  53173. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53174. /**
  53175. * Append an anchor to a soft object
  53176. * @param impostor soft impostor to add anchor to
  53177. * @param otherImpostor rigid impostor as the anchor
  53178. * @param width ratio across width from 0 to 1
  53179. * @param height ratio up height from 0 to 1
  53180. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, no strech
  53181. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53182. */
  53183. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53184. /**
  53185. * Sleeps the physics body and stops it from being active
  53186. * @param impostor impostor to sleep
  53187. */
  53188. sleepBody(impostor: PhysicsImpostor): void;
  53189. /**
  53190. * Activates the physics body
  53191. * @param impostor impostor to activate
  53192. */
  53193. wakeUpBody(impostor: PhysicsImpostor): void;
  53194. /**
  53195. * Updates the distance parameters of the joint
  53196. * @param joint joint to update
  53197. * @param maxDistance maximum distance of the joint
  53198. * @param minDistance minimum distance of the joint
  53199. */
  53200. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53201. /**
  53202. * Sets a motor on the joint
  53203. * @param joint joint to set motor on
  53204. * @param speed speed of the motor
  53205. * @param maxForce maximum force of the motor
  53206. * @param motorIndex index of the motor
  53207. */
  53208. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53209. /**
  53210. * Sets the motors limit
  53211. * @param joint joint to set limit on
  53212. * @param upperLimit upper limit
  53213. * @param lowerLimit lower limit
  53214. */
  53215. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53216. /**
  53217. * Syncs the position and rotation of a mesh with the impostor
  53218. * @param mesh mesh to sync
  53219. * @param impostor impostor to update the mesh with
  53220. */
  53221. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53222. /**
  53223. * Gets the radius of the impostor
  53224. * @param impostor impostor to get radius from
  53225. * @returns the radius
  53226. */
  53227. getRadius(impostor: PhysicsImpostor): number;
  53228. /**
  53229. * Gets the box size of the impostor
  53230. * @param impostor impostor to get box size from
  53231. * @param result the resulting box size
  53232. */
  53233. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53234. /**
  53235. * Disposes of the impostor
  53236. */
  53237. dispose(): void;
  53238. /**
  53239. * Does a raycast in the physics world
  53240. * @param from when should the ray start?
  53241. * @param to when should the ray end?
  53242. * @returns PhysicsRaycastResult
  53243. */
  53244. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53245. }
  53246. }
  53247. declare module "babylonjs/Physics/Plugins/index" {
  53248. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53249. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53250. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53251. }
  53252. declare module "babylonjs/Physics/index" {
  53253. export * from "babylonjs/Physics/IPhysicsEngine";
  53254. export * from "babylonjs/Physics/physicsEngine";
  53255. export * from "babylonjs/Physics/physicsEngineComponent";
  53256. export * from "babylonjs/Physics/physicsHelper";
  53257. export * from "babylonjs/Physics/physicsImpostor";
  53258. export * from "babylonjs/Physics/physicsJoint";
  53259. export * from "babylonjs/Physics/Plugins/index";
  53260. }
  53261. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53262. /** @hidden */
  53263. export var blackAndWhitePixelShader: {
  53264. name: string;
  53265. shader: string;
  53266. };
  53267. }
  53268. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53269. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53270. import { Camera } from "babylonjs/Cameras/camera";
  53271. import { Engine } from "babylonjs/Engines/engine";
  53272. import "babylonjs/Shaders/blackAndWhite.fragment";
  53273. /**
  53274. * Post process used to render in black and white
  53275. */
  53276. export class BlackAndWhitePostProcess extends PostProcess {
  53277. /**
  53278. * Linear about to convert he result to black and white (default: 1)
  53279. */
  53280. degree: number;
  53281. /**
  53282. * Creates a black and white post process
  53283. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53284. * @param name The name of the effect.
  53285. * @param options The required width/height ratio to downsize to before computing the render pass.
  53286. * @param camera The camera to apply the render pass to.
  53287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53288. * @param engine The engine which the post process will be applied. (default: current engine)
  53289. * @param reusable If the post process can be reused on the same frame. (default: false)
  53290. */
  53291. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53292. }
  53293. }
  53294. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53295. import { Nullable } from "babylonjs/types";
  53296. import { Camera } from "babylonjs/Cameras/camera";
  53297. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53298. import { Engine } from "babylonjs/Engines/engine";
  53299. /**
  53300. * This represents a set of one or more post processes in Babylon.
  53301. * A post process can be used to apply a shader to a texture after it is rendered.
  53302. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53303. */
  53304. export class PostProcessRenderEffect {
  53305. private _postProcesses;
  53306. private _getPostProcesses;
  53307. private _singleInstance;
  53308. private _cameras;
  53309. private _indicesForCamera;
  53310. /**
  53311. * Name of the effect
  53312. * @hidden
  53313. */
  53314. _name: string;
  53315. /**
  53316. * Instantiates a post process render effect.
  53317. * A post process can be used to apply a shader to a texture after it is rendered.
  53318. * @param engine The engine the effect is tied to
  53319. * @param name The name of the effect
  53320. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53321. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53322. */
  53323. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53324. /**
  53325. * Checks if all the post processes in the effect are supported.
  53326. */
  53327. readonly isSupported: boolean;
  53328. /**
  53329. * Updates the current state of the effect
  53330. * @hidden
  53331. */
  53332. _update(): void;
  53333. /**
  53334. * Attaches the effect on cameras
  53335. * @param cameras The camera to attach to.
  53336. * @hidden
  53337. */
  53338. _attachCameras(cameras: Camera): void;
  53339. /**
  53340. * Attaches the effect on cameras
  53341. * @param cameras The camera to attach to.
  53342. * @hidden
  53343. */
  53344. _attachCameras(cameras: Camera[]): void;
  53345. /**
  53346. * Detatches the effect on cameras
  53347. * @param cameras The camera to detatch from.
  53348. * @hidden
  53349. */
  53350. _detachCameras(cameras: Camera): void;
  53351. /**
  53352. * Detatches the effect on cameras
  53353. * @param cameras The camera to detatch from.
  53354. * @hidden
  53355. */
  53356. _detachCameras(cameras: Camera[]): void;
  53357. /**
  53358. * Enables the effect on given cameras
  53359. * @param cameras The camera to enable.
  53360. * @hidden
  53361. */
  53362. _enable(cameras: Camera): void;
  53363. /**
  53364. * Enables the effect on given cameras
  53365. * @param cameras The camera to enable.
  53366. * @hidden
  53367. */
  53368. _enable(cameras: Nullable<Camera[]>): void;
  53369. /**
  53370. * Disables the effect on the given cameras
  53371. * @param cameras The camera to disable.
  53372. * @hidden
  53373. */
  53374. _disable(cameras: Camera): void;
  53375. /**
  53376. * Disables the effect on the given cameras
  53377. * @param cameras The camera to disable.
  53378. * @hidden
  53379. */
  53380. _disable(cameras: Nullable<Camera[]>): void;
  53381. /**
  53382. * Gets a list of the post processes contained in the effect.
  53383. * @param camera The camera to get the post processes on.
  53384. * @returns The list of the post processes in the effect.
  53385. */
  53386. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53387. }
  53388. }
  53389. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53390. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53391. /** @hidden */
  53392. export var extractHighlightsPixelShader: {
  53393. name: string;
  53394. shader: string;
  53395. };
  53396. }
  53397. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53398. import { Nullable } from "babylonjs/types";
  53399. import { Camera } from "babylonjs/Cameras/camera";
  53400. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53401. import { Engine } from "babylonjs/Engines/engine";
  53402. import "babylonjs/Shaders/extractHighlights.fragment";
  53403. /**
  53404. * 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.
  53405. */
  53406. export class ExtractHighlightsPostProcess extends PostProcess {
  53407. /**
  53408. * The luminance threshold, pixels below this value will be set to black.
  53409. */
  53410. threshold: number;
  53411. /** @hidden */
  53412. _exposure: number;
  53413. /**
  53414. * Post process which has the input texture to be used when performing highlight extraction
  53415. * @hidden
  53416. */
  53417. _inputPostProcess: Nullable<PostProcess>;
  53418. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53419. }
  53420. }
  53421. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53422. /** @hidden */
  53423. export var bloomMergePixelShader: {
  53424. name: string;
  53425. shader: string;
  53426. };
  53427. }
  53428. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  53429. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53430. import { Nullable } from "babylonjs/types";
  53431. import { Engine } from "babylonjs/Engines/engine";
  53432. import { Camera } from "babylonjs/Cameras/camera";
  53433. import "babylonjs/Shaders/bloomMerge.fragment";
  53434. /**
  53435. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53436. */
  53437. export class BloomMergePostProcess extends PostProcess {
  53438. /** Weight of the bloom to be added to the original input. */
  53439. weight: number;
  53440. /**
  53441. * Creates a new instance of @see BloomMergePostProcess
  53442. * @param name The name of the effect.
  53443. * @param originalFromInput Post process which's input will be used for the merge.
  53444. * @param blurred Blurred highlights post process which's output will be used.
  53445. * @param weight Weight of the bloom to be added to the original input.
  53446. * @param options The required width/height ratio to downsize to before computing the render pass.
  53447. * @param camera The camera to apply the render pass to.
  53448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53449. * @param engine The engine which the post process will be applied. (default: current engine)
  53450. * @param reusable If the post process can be reused on the same frame. (default: false)
  53451. * @param textureType Type of textures used when performing the post process. (default: 0)
  53452. * @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)
  53453. */
  53454. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  53455. /** Weight of the bloom to be added to the original input. */
  53456. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53457. }
  53458. }
  53459. declare module "babylonjs/PostProcesses/bloomEffect" {
  53460. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53461. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53462. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53463. import { Camera } from "babylonjs/Cameras/camera";
  53464. import { Scene } from "babylonjs/scene";
  53465. /**
  53466. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  53467. */
  53468. export class BloomEffect extends PostProcessRenderEffect {
  53469. private bloomScale;
  53470. /**
  53471. * @hidden Internal
  53472. */
  53473. _effects: Array<PostProcess>;
  53474. /**
  53475. * @hidden Internal
  53476. */
  53477. _downscale: ExtractHighlightsPostProcess;
  53478. private _blurX;
  53479. private _blurY;
  53480. private _merge;
  53481. /**
  53482. * The luminance threshold to find bright areas of the image to bloom.
  53483. */
  53484. threshold: number;
  53485. /**
  53486. * The strength of the bloom.
  53487. */
  53488. weight: number;
  53489. /**
  53490. * Specifies the size of the bloom blur kernel, relative to the final output size
  53491. */
  53492. kernel: number;
  53493. /**
  53494. * Creates a new instance of @see BloomEffect
  53495. * @param scene The scene the effect belongs to.
  53496. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  53497. * @param bloomKernel The size of the kernel to be used when applying the blur.
  53498. * @param bloomWeight The the strength of bloom.
  53499. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  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(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53503. /**
  53504. * Disposes each of the internal effects for a given camera.
  53505. * @param camera The camera to dispose the effect on.
  53506. */
  53507. disposeEffects(camera: Camera): void;
  53508. /**
  53509. * @hidden Internal
  53510. */
  53511. _updateEffects(): void;
  53512. /**
  53513. * Internal
  53514. * @returns if all the contained post processes are ready.
  53515. * @hidden
  53516. */
  53517. _isReady(): boolean;
  53518. }
  53519. }
  53520. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  53521. /** @hidden */
  53522. export var chromaticAberrationPixelShader: {
  53523. name: string;
  53524. shader: string;
  53525. };
  53526. }
  53527. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  53528. import { Vector2 } from "babylonjs/Maths/math";
  53529. import { Nullable } from "babylonjs/types";
  53530. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53531. import { Camera } from "babylonjs/Cameras/camera";
  53532. import { Engine } from "babylonjs/Engines/engine";
  53533. import "babylonjs/Shaders/chromaticAberration.fragment";
  53534. /**
  53535. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53536. */
  53537. export class ChromaticAberrationPostProcess extends PostProcess {
  53538. /**
  53539. * The amount of seperation of rgb channels (default: 30)
  53540. */
  53541. aberrationAmount: number;
  53542. /**
  53543. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53544. */
  53545. radialIntensity: number;
  53546. /**
  53547. * 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))
  53548. */
  53549. direction: Vector2;
  53550. /**
  53551. * 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))
  53552. */
  53553. centerPosition: Vector2;
  53554. /**
  53555. * Creates a new instance ChromaticAberrationPostProcess
  53556. * @param name The name of the effect.
  53557. * @param screenWidth The width of the screen to apply the effect on.
  53558. * @param screenHeight The height of the screen to apply the effect on.
  53559. * @param options The required width/height ratio to downsize to before computing the render pass.
  53560. * @param camera The camera to apply the render pass to.
  53561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53562. * @param engine The engine which the post process will be applied. (default: current engine)
  53563. * @param reusable If the post process can be reused on the same frame. (default: false)
  53564. * @param textureType Type of textures used when performing the post process. (default: 0)
  53565. * @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)
  53566. */
  53567. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53568. }
  53569. }
  53570. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53571. /** @hidden */
  53572. export var circleOfConfusionPixelShader: {
  53573. name: string;
  53574. shader: string;
  53575. };
  53576. }
  53577. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53578. import { Nullable } from "babylonjs/types";
  53579. import { Engine } from "babylonjs/Engines/engine";
  53580. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53581. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53582. import { Camera } from "babylonjs/Cameras/camera";
  53583. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53584. /**
  53585. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53586. */
  53587. export class CircleOfConfusionPostProcess extends PostProcess {
  53588. /**
  53589. * 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.
  53590. */
  53591. lensSize: number;
  53592. /**
  53593. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53594. */
  53595. fStop: number;
  53596. /**
  53597. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53598. */
  53599. focusDistance: number;
  53600. /**
  53601. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53602. */
  53603. focalLength: number;
  53604. private _depthTexture;
  53605. /**
  53606. * Creates a new instance CircleOfConfusionPostProcess
  53607. * @param name The name of the effect.
  53608. * @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.
  53609. * @param options The required width/height ratio to downsize to before computing the render pass.
  53610. * @param camera The camera to apply the render pass to.
  53611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53612. * @param engine The engine which the post process will be applied. (default: current engine)
  53613. * @param reusable If the post process can be reused on the same frame. (default: false)
  53614. * @param textureType Type of textures used when performing the post process. (default: 0)
  53615. * @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)
  53616. */
  53617. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53618. /**
  53619. * 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.
  53620. */
  53621. depthTexture: RenderTargetTexture;
  53622. }
  53623. }
  53624. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53625. /** @hidden */
  53626. export var colorCorrectionPixelShader: {
  53627. name: string;
  53628. shader: string;
  53629. };
  53630. }
  53631. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53633. import { Engine } from "babylonjs/Engines/engine";
  53634. import { Camera } from "babylonjs/Cameras/camera";
  53635. import "babylonjs/Shaders/colorCorrection.fragment";
  53636. /**
  53637. *
  53638. * This post-process allows the modification of rendered colors by using
  53639. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53640. *
  53641. * The object needs to be provided an url to a texture containing the color
  53642. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53643. * Use an image editing software to tweak the LUT to match your needs.
  53644. *
  53645. * For an example of a color LUT, see here:
  53646. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53647. * For explanations on color grading, see here:
  53648. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53649. *
  53650. */
  53651. export class ColorCorrectionPostProcess extends PostProcess {
  53652. private _colorTableTexture;
  53653. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53654. }
  53655. }
  53656. declare module "babylonjs/Shaders/convolution.fragment" {
  53657. /** @hidden */
  53658. export var convolutionPixelShader: {
  53659. name: string;
  53660. shader: string;
  53661. };
  53662. }
  53663. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53664. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53665. import { Nullable } from "babylonjs/types";
  53666. import { Camera } from "babylonjs/Cameras/camera";
  53667. import { Engine } from "babylonjs/Engines/engine";
  53668. import "babylonjs/Shaders/convolution.fragment";
  53669. /**
  53670. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53671. * input texture to perform effects such as edge detection or sharpening
  53672. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53673. */
  53674. export class ConvolutionPostProcess extends PostProcess {
  53675. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53676. kernel: number[];
  53677. /**
  53678. * Creates a new instance ConvolutionPostProcess
  53679. * @param name The name of the effect.
  53680. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53681. * @param options The required width/height ratio to downsize to before computing the render pass.
  53682. * @param camera The camera to apply the render pass to.
  53683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53684. * @param engine The engine which the post process will be applied. (default: current engine)
  53685. * @param reusable If the post process can be reused on the same frame. (default: false)
  53686. * @param textureType Type of textures used when performing the post process. (default: 0)
  53687. */
  53688. constructor(name: string,
  53689. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53690. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53691. /**
  53692. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53693. */
  53694. static EdgeDetect0Kernel: number[];
  53695. /**
  53696. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53697. */
  53698. static EdgeDetect1Kernel: number[];
  53699. /**
  53700. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53701. */
  53702. static EdgeDetect2Kernel: number[];
  53703. /**
  53704. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53705. */
  53706. static SharpenKernel: number[];
  53707. /**
  53708. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53709. */
  53710. static EmbossKernel: number[];
  53711. /**
  53712. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53713. */
  53714. static GaussianKernel: number[];
  53715. }
  53716. }
  53717. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53718. import { Nullable } from "babylonjs/types";
  53719. import { Vector2 } from "babylonjs/Maths/math";
  53720. import { Camera } from "babylonjs/Cameras/camera";
  53721. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53722. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53723. import { Engine } from "babylonjs/Engines/engine";
  53724. import { Scene } from "babylonjs/scene";
  53725. /**
  53726. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53727. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53728. * based on samples that have a large difference in distance than the center pixel.
  53729. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53730. */
  53731. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53732. direction: Vector2;
  53733. /**
  53734. * Creates a new instance CircleOfConfusionPostProcess
  53735. * @param name The name of the effect.
  53736. * @param scene The scene the effect belongs to.
  53737. * @param direction The direction the blur should be applied.
  53738. * @param kernel The size of the kernel used to blur.
  53739. * @param options The required width/height ratio to downsize to before computing the render pass.
  53740. * @param camera The camera to apply the render pass to.
  53741. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53742. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53744. * @param engine The engine which the post process will be applied. (default: current engine)
  53745. * @param reusable If the post process can be reused on the same frame. (default: false)
  53746. * @param textureType Type of textures used when performing the post process. (default: 0)
  53747. * @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)
  53748. */
  53749. 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);
  53750. }
  53751. }
  53752. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53753. /** @hidden */
  53754. export var depthOfFieldMergePixelShader: {
  53755. name: string;
  53756. shader: string;
  53757. };
  53758. }
  53759. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53760. import { Nullable } from "babylonjs/types";
  53761. import { Camera } from "babylonjs/Cameras/camera";
  53762. import { Effect } from "babylonjs/Materials/effect";
  53763. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53764. import { Engine } from "babylonjs/Engines/engine";
  53765. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53766. /**
  53767. * Options to be set when merging outputs from the default pipeline.
  53768. */
  53769. export class DepthOfFieldMergePostProcessOptions {
  53770. /**
  53771. * The original image to merge on top of
  53772. */
  53773. originalFromInput: PostProcess;
  53774. /**
  53775. * Parameters to perform the merge of the depth of field effect
  53776. */
  53777. depthOfField?: {
  53778. circleOfConfusion: PostProcess;
  53779. blurSteps: Array<PostProcess>;
  53780. };
  53781. /**
  53782. * Parameters to perform the merge of bloom effect
  53783. */
  53784. bloom?: {
  53785. blurred: PostProcess;
  53786. weight: number;
  53787. };
  53788. }
  53789. /**
  53790. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53791. */
  53792. export class DepthOfFieldMergePostProcess extends PostProcess {
  53793. private blurSteps;
  53794. /**
  53795. * Creates a new instance of DepthOfFieldMergePostProcess
  53796. * @param name The name of the effect.
  53797. * @param originalFromInput Post process which's input will be used for the merge.
  53798. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53799. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53800. * @param options The required width/height ratio to downsize to before computing the render pass.
  53801. * @param camera The camera to apply the render pass to.
  53802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53803. * @param engine The engine which the post process will be applied. (default: current engine)
  53804. * @param reusable If the post process can be reused on the same frame. (default: false)
  53805. * @param textureType Type of textures used when performing the post process. (default: 0)
  53806. * @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)
  53807. */
  53808. 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);
  53809. /**
  53810. * Updates the effect with the current post process compile time values and recompiles the shader.
  53811. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53812. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53813. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53814. * @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
  53815. * @param onCompiled Called when the shader has been compiled.
  53816. * @param onError Called if there is an error when compiling a shader.
  53817. */
  53818. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53819. }
  53820. }
  53821. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53822. import { Nullable } from "babylonjs/types";
  53823. import { Camera } from "babylonjs/Cameras/camera";
  53824. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53825. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53826. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53827. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53828. import { Scene } from "babylonjs/scene";
  53829. /**
  53830. * Specifies the level of max blur that should be applied when using the depth of field effect
  53831. */
  53832. export enum DepthOfFieldEffectBlurLevel {
  53833. /**
  53834. * Subtle blur
  53835. */
  53836. Low = 0,
  53837. /**
  53838. * Medium blur
  53839. */
  53840. Medium = 1,
  53841. /**
  53842. * Large blur
  53843. */
  53844. High = 2
  53845. }
  53846. /**
  53847. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53848. */
  53849. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53850. private _circleOfConfusion;
  53851. /**
  53852. * @hidden Internal, blurs from high to low
  53853. */
  53854. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53855. private _depthOfFieldBlurY;
  53856. private _dofMerge;
  53857. /**
  53858. * @hidden Internal post processes in depth of field effect
  53859. */
  53860. _effects: Array<PostProcess>;
  53861. /**
  53862. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53863. */
  53864. focalLength: number;
  53865. /**
  53866. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53867. */
  53868. fStop: number;
  53869. /**
  53870. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53871. */
  53872. focusDistance: number;
  53873. /**
  53874. * 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.
  53875. */
  53876. lensSize: number;
  53877. /**
  53878. * Creates a new instance DepthOfFieldEffect
  53879. * @param scene The scene the effect belongs to.
  53880. * @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.
  53881. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53882. * @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)
  53883. */
  53884. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53885. /**
  53886. * 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.
  53887. */
  53888. depthTexture: RenderTargetTexture;
  53889. /**
  53890. * Disposes each of the internal effects for a given camera.
  53891. * @param camera The camera to dispose the effect on.
  53892. */
  53893. disposeEffects(camera: Camera): void;
  53894. /**
  53895. * @hidden Internal
  53896. */
  53897. _updateEffects(): void;
  53898. /**
  53899. * Internal
  53900. * @returns if all the contained post processes are ready.
  53901. * @hidden
  53902. */
  53903. _isReady(): boolean;
  53904. }
  53905. }
  53906. declare module "babylonjs/Shaders/displayPass.fragment" {
  53907. /** @hidden */
  53908. export var displayPassPixelShader: {
  53909. name: string;
  53910. shader: string;
  53911. };
  53912. }
  53913. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53914. import { Nullable } from "babylonjs/types";
  53915. import { Camera } from "babylonjs/Cameras/camera";
  53916. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53917. import { Engine } from "babylonjs/Engines/engine";
  53918. import "babylonjs/Shaders/displayPass.fragment";
  53919. /**
  53920. * DisplayPassPostProcess which produces an output the same as it's input
  53921. */
  53922. export class DisplayPassPostProcess extends PostProcess {
  53923. /**
  53924. * Creates the DisplayPassPostProcess
  53925. * @param name The name of the effect.
  53926. * @param options The required width/height ratio to downsize to before computing the render pass.
  53927. * @param camera The camera to apply the render pass to.
  53928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53929. * @param engine The engine which the post process will be applied. (default: current engine)
  53930. * @param reusable If the post process can be reused on the same frame. (default: false)
  53931. */
  53932. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53933. }
  53934. }
  53935. declare module "babylonjs/Shaders/filter.fragment" {
  53936. /** @hidden */
  53937. export var filterPixelShader: {
  53938. name: string;
  53939. shader: string;
  53940. };
  53941. }
  53942. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53943. import { Nullable } from "babylonjs/types";
  53944. import { Matrix } from "babylonjs/Maths/math";
  53945. import { Camera } from "babylonjs/Cameras/camera";
  53946. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53947. import { Engine } from "babylonjs/Engines/engine";
  53948. import "babylonjs/Shaders/filter.fragment";
  53949. /**
  53950. * Applies a kernel filter to the image
  53951. */
  53952. export class FilterPostProcess extends PostProcess {
  53953. /** The matrix to be applied to the image */
  53954. kernelMatrix: Matrix;
  53955. /**
  53956. *
  53957. * @param name The name of the effect.
  53958. * @param kernelMatrix The matrix to be applied to the image
  53959. * @param options The required width/height ratio to downsize to before computing the render pass.
  53960. * @param camera The camera to apply the render pass to.
  53961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53962. * @param engine The engine which the post process will be applied. (default: current engine)
  53963. * @param reusable If the post process can be reused on the same frame. (default: false)
  53964. */
  53965. constructor(name: string,
  53966. /** The matrix to be applied to the image */
  53967. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53968. }
  53969. }
  53970. declare module "babylonjs/Shaders/fxaa.fragment" {
  53971. /** @hidden */
  53972. export var fxaaPixelShader: {
  53973. name: string;
  53974. shader: string;
  53975. };
  53976. }
  53977. declare module "babylonjs/Shaders/fxaa.vertex" {
  53978. /** @hidden */
  53979. export var fxaaVertexShader: {
  53980. name: string;
  53981. shader: string;
  53982. };
  53983. }
  53984. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53985. import { Nullable } from "babylonjs/types";
  53986. import { Camera } from "babylonjs/Cameras/camera";
  53987. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53988. import { Engine } from "babylonjs/Engines/engine";
  53989. import "babylonjs/Shaders/fxaa.fragment";
  53990. import "babylonjs/Shaders/fxaa.vertex";
  53991. /**
  53992. * Fxaa post process
  53993. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53994. */
  53995. export class FxaaPostProcess extends PostProcess {
  53996. /** @hidden */
  53997. texelWidth: number;
  53998. /** @hidden */
  53999. texelHeight: number;
  54000. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54001. private _getDefines;
  54002. }
  54003. }
  54004. declare module "babylonjs/Shaders/grain.fragment" {
  54005. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54006. /** @hidden */
  54007. export var grainPixelShader: {
  54008. name: string;
  54009. shader: string;
  54010. };
  54011. }
  54012. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54013. import { Nullable } from "babylonjs/types";
  54014. import { Camera } from "babylonjs/Cameras/camera";
  54015. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54016. import { Engine } from "babylonjs/Engines/engine";
  54017. import "babylonjs/Shaders/grain.fragment";
  54018. /**
  54019. * The GrainPostProcess adds noise to the image at mid luminance levels
  54020. */
  54021. export class GrainPostProcess extends PostProcess {
  54022. /**
  54023. * The intensity of the grain added (default: 30)
  54024. */
  54025. intensity: number;
  54026. /**
  54027. * If the grain should be randomized on every frame
  54028. */
  54029. animated: boolean;
  54030. /**
  54031. * Creates a new instance of @see GrainPostProcess
  54032. * @param name The name of the effect.
  54033. * @param options The required width/height ratio to downsize to before computing the render pass.
  54034. * @param camera The camera to apply the render pass to.
  54035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54036. * @param engine The engine which the post process will be applied. (default: current engine)
  54037. * @param reusable If the post process can be reused on the same frame. (default: false)
  54038. * @param textureType Type of textures used when performing the post process. (default: 0)
  54039. * @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)
  54040. */
  54041. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54042. }
  54043. }
  54044. declare module "babylonjs/Shaders/highlights.fragment" {
  54045. /** @hidden */
  54046. export var highlightsPixelShader: {
  54047. name: string;
  54048. shader: string;
  54049. };
  54050. }
  54051. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54052. import { Nullable } from "babylonjs/types";
  54053. import { Camera } from "babylonjs/Cameras/camera";
  54054. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54055. import { Engine } from "babylonjs/Engines/engine";
  54056. import "babylonjs/Shaders/highlights.fragment";
  54057. /**
  54058. * Extracts highlights from the image
  54059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54060. */
  54061. export class HighlightsPostProcess extends PostProcess {
  54062. /**
  54063. * Extracts highlights from the image
  54064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54065. * @param name The name of the effect.
  54066. * @param options The required width/height ratio to downsize to before computing the render pass.
  54067. * @param camera The camera to apply the render pass to.
  54068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54069. * @param engine The engine which the post process will be applied. (default: current engine)
  54070. * @param reusable If the post process can be reused on the same frame. (default: false)
  54071. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54072. */
  54073. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54074. }
  54075. }
  54076. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54077. /** @hidden */
  54078. export var mrtFragmentDeclaration: {
  54079. name: string;
  54080. shader: string;
  54081. };
  54082. }
  54083. declare module "babylonjs/Shaders/geometry.fragment" {
  54084. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54085. /** @hidden */
  54086. export var geometryPixelShader: {
  54087. name: string;
  54088. shader: string;
  54089. };
  54090. }
  54091. declare module "babylonjs/Shaders/geometry.vertex" {
  54092. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54093. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54094. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54095. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54096. /** @hidden */
  54097. export var geometryVertexShader: {
  54098. name: string;
  54099. shader: string;
  54100. };
  54101. }
  54102. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54103. import { Matrix } from "babylonjs/Maths/math";
  54104. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54105. import { Mesh } from "babylonjs/Meshes/mesh";
  54106. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54107. import { Effect } from "babylonjs/Materials/effect";
  54108. import { Scene } from "babylonjs/scene";
  54109. import "babylonjs/Shaders/geometry.fragment";
  54110. import "babylonjs/Shaders/geometry.vertex";
  54111. /**
  54112. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54113. */
  54114. export class GeometryBufferRenderer {
  54115. /**
  54116. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54117. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54118. */
  54119. static readonly POSITION_TEXTURE_TYPE: number;
  54120. /**
  54121. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54122. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54123. */
  54124. static readonly VELOCITY_TEXTURE_TYPE: number;
  54125. /**
  54126. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54127. * in order to compute objects velocities when enableVelocity is set to "true"
  54128. * @hidden
  54129. */
  54130. _previousTransformationMatrices: {
  54131. [index: number]: Matrix;
  54132. };
  54133. private _scene;
  54134. private _multiRenderTarget;
  54135. private _ratio;
  54136. private _enablePosition;
  54137. private _enableVelocity;
  54138. private _positionIndex;
  54139. private _velocityIndex;
  54140. protected _effect: Effect;
  54141. protected _cachedDefines: string;
  54142. /**
  54143. * Set the render list (meshes to be rendered) used in the G buffer.
  54144. */
  54145. renderList: Mesh[];
  54146. /**
  54147. * Gets wether or not G buffer are supported by the running hardware.
  54148. * This requires draw buffer supports
  54149. */
  54150. readonly isSupported: boolean;
  54151. /**
  54152. * Returns the index of the given texture type in the G-Buffer textures array
  54153. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54154. * @returns the index of the given texture type in the G-Buffer textures array
  54155. */
  54156. getTextureIndex(textureType: number): number;
  54157. /**
  54158. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54159. */
  54160. /**
  54161. * Sets whether or not objects positions are enabled for the G buffer.
  54162. */
  54163. enablePosition: boolean;
  54164. /**
  54165. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54166. */
  54167. /**
  54168. * Sets wether or not objects velocities are enabled for the G buffer.
  54169. */
  54170. enableVelocity: boolean;
  54171. /**
  54172. * Gets the scene associated with the buffer.
  54173. */
  54174. readonly scene: Scene;
  54175. /**
  54176. * Gets the ratio used by the buffer during its creation.
  54177. * How big is the buffer related to the main canvas.
  54178. */
  54179. readonly ratio: number;
  54180. /** @hidden */
  54181. static _SceneComponentInitialization: (scene: Scene) => void;
  54182. /**
  54183. * Creates a new G Buffer for the scene
  54184. * @param scene The scene the buffer belongs to
  54185. * @param ratio How big is the buffer related to the main canvas.
  54186. */
  54187. constructor(scene: Scene, ratio?: number);
  54188. /**
  54189. * Checks wether everything is ready to render a submesh to the G buffer.
  54190. * @param subMesh the submesh to check readiness for
  54191. * @param useInstances is the mesh drawn using instance or not
  54192. * @returns true if ready otherwise false
  54193. */
  54194. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54195. /**
  54196. * Gets the current underlying G Buffer.
  54197. * @returns the buffer
  54198. */
  54199. getGBuffer(): MultiRenderTarget;
  54200. /**
  54201. * Gets the number of samples used to render the buffer (anti aliasing).
  54202. */
  54203. /**
  54204. * Sets the number of samples used to render the buffer (anti aliasing).
  54205. */
  54206. samples: number;
  54207. /**
  54208. * Disposes the renderer and frees up associated resources.
  54209. */
  54210. dispose(): void;
  54211. protected _createRenderTargets(): void;
  54212. }
  54213. }
  54214. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54215. import { Nullable } from "babylonjs/types";
  54216. import { Scene } from "babylonjs/scene";
  54217. import { ISceneComponent } from "babylonjs/sceneComponent";
  54218. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54219. module "babylonjs/scene" {
  54220. interface Scene {
  54221. /** @hidden (Backing field) */
  54222. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54223. /**
  54224. * Gets or Sets the current geometry buffer associated to the scene.
  54225. */
  54226. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54227. /**
  54228. * Enables a GeometryBufferRender and associates it with the scene
  54229. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54230. * @returns the GeometryBufferRenderer
  54231. */
  54232. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54233. /**
  54234. * Disables the GeometryBufferRender associated with the scene
  54235. */
  54236. disableGeometryBufferRenderer(): void;
  54237. }
  54238. }
  54239. /**
  54240. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54241. * in several rendering techniques.
  54242. */
  54243. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54244. /**
  54245. * The component name helpful to identify the component in the list of scene components.
  54246. */
  54247. readonly name: string;
  54248. /**
  54249. * The scene the component belongs to.
  54250. */
  54251. scene: Scene;
  54252. /**
  54253. * Creates a new instance of the component for the given scene
  54254. * @param scene Defines the scene to register the component in
  54255. */
  54256. constructor(scene: Scene);
  54257. /**
  54258. * Registers the component in a given scene
  54259. */
  54260. register(): void;
  54261. /**
  54262. * Rebuilds the elements related to this component in case of
  54263. * context lost for instance.
  54264. */
  54265. rebuild(): void;
  54266. /**
  54267. * Disposes the component and the associated ressources
  54268. */
  54269. dispose(): void;
  54270. private _gatherRenderTargets;
  54271. }
  54272. }
  54273. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54274. /** @hidden */
  54275. export var motionBlurPixelShader: {
  54276. name: string;
  54277. shader: string;
  54278. };
  54279. }
  54280. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54281. import { Nullable } from "babylonjs/types";
  54282. import { Camera } from "babylonjs/Cameras/camera";
  54283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54284. import { Scene } from "babylonjs/scene";
  54285. import "babylonjs/Animations/animatable";
  54286. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54287. import "babylonjs/Shaders/motionBlur.fragment";
  54288. import { Engine } from "babylonjs/Engines/engine";
  54289. /**
  54290. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54291. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54292. * As an example, all you have to do is to create the post-process:
  54293. * var mb = new BABYLON.MotionBlurPostProcess(
  54294. * 'mb', // The name of the effect.
  54295. * scene, // The scene containing the objects to blur according to their velocity.
  54296. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54297. * camera // The camera to apply the render pass to.
  54298. * );
  54299. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54300. */
  54301. export class MotionBlurPostProcess extends PostProcess {
  54302. /**
  54303. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54304. */
  54305. motionStrength: number;
  54306. /**
  54307. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54308. */
  54309. /**
  54310. * Sets the number of iterations to be used for motion blur quality
  54311. */
  54312. motionBlurSamples: number;
  54313. private _motionBlurSamples;
  54314. private _geometryBufferRenderer;
  54315. /**
  54316. * Creates a new instance MotionBlurPostProcess
  54317. * @param name The name of the effect.
  54318. * @param scene The scene containing the objects to blur according to their velocity.
  54319. * @param options The required width/height ratio to downsize to before computing the render pass.
  54320. * @param camera The camera to apply the render pass to.
  54321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54322. * @param engine The engine which the post process will be applied. (default: current engine)
  54323. * @param reusable If the post process can be reused on the same frame. (default: false)
  54324. * @param textureType Type of textures used when performing the post process. (default: 0)
  54325. * @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)
  54326. */
  54327. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54328. /**
  54329. * Disposes the post process.
  54330. * @param camera The camera to dispose the post process on.
  54331. */
  54332. dispose(camera?: Camera): void;
  54333. }
  54334. }
  54335. declare module "babylonjs/Shaders/refraction.fragment" {
  54336. /** @hidden */
  54337. export var refractionPixelShader: {
  54338. name: string;
  54339. shader: string;
  54340. };
  54341. }
  54342. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54343. import { Color3 } from "babylonjs/Maths/math";
  54344. import { Camera } from "babylonjs/Cameras/camera";
  54345. import { Texture } from "babylonjs/Materials/Textures/texture";
  54346. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54347. import { Engine } from "babylonjs/Engines/engine";
  54348. import "babylonjs/Shaders/refraction.fragment";
  54349. /**
  54350. * Post process which applies a refractin texture
  54351. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54352. */
  54353. export class RefractionPostProcess extends PostProcess {
  54354. /** the base color of the refraction (used to taint the rendering) */
  54355. color: Color3;
  54356. /** simulated refraction depth */
  54357. depth: number;
  54358. /** the coefficient of the base color (0 to remove base color tainting) */
  54359. colorLevel: number;
  54360. private _refTexture;
  54361. private _ownRefractionTexture;
  54362. /**
  54363. * Gets or sets the refraction texture
  54364. * Please note that you are responsible for disposing the texture if you set it manually
  54365. */
  54366. refractionTexture: Texture;
  54367. /**
  54368. * Initializes the RefractionPostProcess
  54369. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54370. * @param name The name of the effect.
  54371. * @param refractionTextureUrl Url of the refraction texture to use
  54372. * @param color the base color of the refraction (used to taint the rendering)
  54373. * @param depth simulated refraction depth
  54374. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54375. * @param camera The camera to apply the render pass to.
  54376. * @param options The required width/height ratio to downsize to before computing the render pass.
  54377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54378. * @param engine The engine which the post process will be applied. (default: current engine)
  54379. * @param reusable If the post process can be reused on the same frame. (default: false)
  54380. */
  54381. constructor(name: string, refractionTextureUrl: string,
  54382. /** the base color of the refraction (used to taint the rendering) */
  54383. color: Color3,
  54384. /** simulated refraction depth */
  54385. depth: number,
  54386. /** the coefficient of the base color (0 to remove base color tainting) */
  54387. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54388. /**
  54389. * Disposes of the post process
  54390. * @param camera Camera to dispose post process on
  54391. */
  54392. dispose(camera: Camera): void;
  54393. }
  54394. }
  54395. declare module "babylonjs/Shaders/sharpen.fragment" {
  54396. /** @hidden */
  54397. export var sharpenPixelShader: {
  54398. name: string;
  54399. shader: string;
  54400. };
  54401. }
  54402. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54403. import { Nullable } from "babylonjs/types";
  54404. import { Camera } from "babylonjs/Cameras/camera";
  54405. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54406. import "babylonjs/Shaders/sharpen.fragment";
  54407. import { Engine } from "babylonjs/Engines/engine";
  54408. /**
  54409. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54410. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54411. */
  54412. export class SharpenPostProcess extends PostProcess {
  54413. /**
  54414. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54415. */
  54416. colorAmount: number;
  54417. /**
  54418. * How much sharpness should be applied (default: 0.3)
  54419. */
  54420. edgeAmount: number;
  54421. /**
  54422. * Creates a new instance ConvolutionPostProcess
  54423. * @param name The name of the effect.
  54424. * @param options The required width/height ratio to downsize to before computing the render pass.
  54425. * @param camera The camera to apply the render pass to.
  54426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54427. * @param engine The engine which the post process will be applied. (default: current engine)
  54428. * @param reusable If the post process can be reused on the same frame. (default: false)
  54429. * @param textureType Type of textures used when performing the post process. (default: 0)
  54430. * @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)
  54431. */
  54432. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54433. }
  54434. }
  54435. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  54436. import { Nullable } from "babylonjs/types";
  54437. import { Camera } from "babylonjs/Cameras/camera";
  54438. import { Engine } from "babylonjs/Engines/engine";
  54439. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54440. import { IInspectable } from "babylonjs/Misc/iInspectable";
  54441. /**
  54442. * PostProcessRenderPipeline
  54443. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54444. */
  54445. export class PostProcessRenderPipeline {
  54446. private engine;
  54447. private _renderEffects;
  54448. private _renderEffectsForIsolatedPass;
  54449. /**
  54450. * List of inspectable custom properties (used by the Inspector)
  54451. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  54452. */
  54453. inspectableCustomProperties: IInspectable[];
  54454. /**
  54455. * @hidden
  54456. */
  54457. protected _cameras: Camera[];
  54458. /** @hidden */
  54459. _name: string;
  54460. /**
  54461. * Gets pipeline name
  54462. */
  54463. readonly name: string;
  54464. /**
  54465. * Initializes a PostProcessRenderPipeline
  54466. * @param engine engine to add the pipeline to
  54467. * @param name name of the pipeline
  54468. */
  54469. constructor(engine: Engine, name: string);
  54470. /**
  54471. * Gets the class name
  54472. * @returns "PostProcessRenderPipeline"
  54473. */
  54474. getClassName(): string;
  54475. /**
  54476. * If all the render effects in the pipeline are supported
  54477. */
  54478. readonly isSupported: boolean;
  54479. /**
  54480. * Adds an effect to the pipeline
  54481. * @param renderEffect the effect to add
  54482. */
  54483. addEffect(renderEffect: PostProcessRenderEffect): void;
  54484. /** @hidden */
  54485. _rebuild(): void;
  54486. /** @hidden */
  54487. _enableEffect(renderEffectName: string, cameras: Camera): void;
  54488. /** @hidden */
  54489. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  54490. /** @hidden */
  54491. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54492. /** @hidden */
  54493. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54494. /** @hidden */
  54495. _attachCameras(cameras: Camera, unique: boolean): void;
  54496. /** @hidden */
  54497. _attachCameras(cameras: Camera[], unique: boolean): void;
  54498. /** @hidden */
  54499. _detachCameras(cameras: Camera): void;
  54500. /** @hidden */
  54501. _detachCameras(cameras: Nullable<Camera[]>): void;
  54502. /** @hidden */
  54503. _update(): void;
  54504. /** @hidden */
  54505. _reset(): void;
  54506. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  54507. /**
  54508. * Disposes of the pipeline
  54509. */
  54510. dispose(): void;
  54511. }
  54512. }
  54513. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54514. import { Camera } from "babylonjs/Cameras/camera";
  54515. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54516. /**
  54517. * PostProcessRenderPipelineManager class
  54518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54519. */
  54520. export class PostProcessRenderPipelineManager {
  54521. private _renderPipelines;
  54522. /**
  54523. * Initializes a PostProcessRenderPipelineManager
  54524. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54525. */
  54526. constructor();
  54527. /**
  54528. * Gets the list of supported render pipelines
  54529. */
  54530. readonly supportedPipelines: PostProcessRenderPipeline[];
  54531. /**
  54532. * Adds a pipeline to the manager
  54533. * @param renderPipeline The pipeline to add
  54534. */
  54535. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54536. /**
  54537. * Attaches a camera to the pipeline
  54538. * @param renderPipelineName The name of the pipeline to attach to
  54539. * @param cameras the camera to attach
  54540. * @param unique if the camera can be attached multiple times to the pipeline
  54541. */
  54542. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54543. /**
  54544. * Detaches a camera from the pipeline
  54545. * @param renderPipelineName The name of the pipeline to detach from
  54546. * @param cameras the camera to detach
  54547. */
  54548. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54549. /**
  54550. * Enables an effect by name on a pipeline
  54551. * @param renderPipelineName the name of the pipeline to enable the effect in
  54552. * @param renderEffectName the name of the effect to enable
  54553. * @param cameras the cameras that the effect should be enabled on
  54554. */
  54555. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54556. /**
  54557. * Disables an effect by name on a pipeline
  54558. * @param renderPipelineName the name of the pipeline to disable the effect in
  54559. * @param renderEffectName the name of the effect to disable
  54560. * @param cameras the cameras that the effect should be disabled on
  54561. */
  54562. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54563. /**
  54564. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54565. */
  54566. update(): void;
  54567. /** @hidden */
  54568. _rebuild(): void;
  54569. /**
  54570. * Disposes of the manager and pipelines
  54571. */
  54572. dispose(): void;
  54573. }
  54574. }
  54575. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54576. import { ISceneComponent } from "babylonjs/sceneComponent";
  54577. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54578. import { Scene } from "babylonjs/scene";
  54579. module "babylonjs/scene" {
  54580. interface Scene {
  54581. /** @hidden (Backing field) */
  54582. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54583. /**
  54584. * Gets the postprocess render pipeline manager
  54585. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54586. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54587. */
  54588. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54589. }
  54590. }
  54591. /**
  54592. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54593. */
  54594. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54595. /**
  54596. * The component name helpfull to identify the component in the list of scene components.
  54597. */
  54598. readonly name: string;
  54599. /**
  54600. * The scene the component belongs to.
  54601. */
  54602. scene: Scene;
  54603. /**
  54604. * Creates a new instance of the component for the given scene
  54605. * @param scene Defines the scene to register the component in
  54606. */
  54607. constructor(scene: Scene);
  54608. /**
  54609. * Registers the component in a given scene
  54610. */
  54611. register(): void;
  54612. /**
  54613. * Rebuilds the elements related to this component in case of
  54614. * context lost for instance.
  54615. */
  54616. rebuild(): void;
  54617. /**
  54618. * Disposes the component and the associated ressources
  54619. */
  54620. dispose(): void;
  54621. private _gatherRenderTargets;
  54622. }
  54623. }
  54624. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54625. import { IAnimatable } from "babylonjs/Misc/tools";
  54626. import { Camera } from "babylonjs/Cameras/camera";
  54627. import { IDisposable } from "babylonjs/scene";
  54628. import { Scene } from "babylonjs/scene";
  54629. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54630. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54631. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54632. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54633. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54634. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54635. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54636. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54637. import { Animation } from "babylonjs/Animations/animation";
  54638. /**
  54639. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54640. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54641. */
  54642. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54643. private _scene;
  54644. private _camerasToBeAttached;
  54645. /**
  54646. * ID of the sharpen post process,
  54647. */
  54648. private readonly SharpenPostProcessId;
  54649. /**
  54650. * @ignore
  54651. * ID of the image processing post process;
  54652. */
  54653. readonly ImageProcessingPostProcessId: string;
  54654. /**
  54655. * @ignore
  54656. * ID of the Fast Approximate Anti-Aliasing post process;
  54657. */
  54658. readonly FxaaPostProcessId: string;
  54659. /**
  54660. * ID of the chromatic aberration post process,
  54661. */
  54662. private readonly ChromaticAberrationPostProcessId;
  54663. /**
  54664. * ID of the grain post process
  54665. */
  54666. private readonly GrainPostProcessId;
  54667. /**
  54668. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54669. */
  54670. sharpen: SharpenPostProcess;
  54671. private _sharpenEffect;
  54672. private bloom;
  54673. /**
  54674. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54675. */
  54676. depthOfField: DepthOfFieldEffect;
  54677. /**
  54678. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54679. */
  54680. fxaa: FxaaPostProcess;
  54681. /**
  54682. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54683. */
  54684. imageProcessing: ImageProcessingPostProcess;
  54685. /**
  54686. * Chromatic aberration post process which will shift rgb colors in the image
  54687. */
  54688. chromaticAberration: ChromaticAberrationPostProcess;
  54689. private _chromaticAberrationEffect;
  54690. /**
  54691. * Grain post process which add noise to the image
  54692. */
  54693. grain: GrainPostProcess;
  54694. private _grainEffect;
  54695. /**
  54696. * Glow post process which adds a glow to emissive areas of the image
  54697. */
  54698. private _glowLayer;
  54699. /**
  54700. * Animations which can be used to tweak settings over a period of time
  54701. */
  54702. animations: Animation[];
  54703. private _imageProcessingConfigurationObserver;
  54704. private _sharpenEnabled;
  54705. private _bloomEnabled;
  54706. private _depthOfFieldEnabled;
  54707. private _depthOfFieldBlurLevel;
  54708. private _fxaaEnabled;
  54709. private _imageProcessingEnabled;
  54710. private _defaultPipelineTextureType;
  54711. private _bloomScale;
  54712. private _chromaticAberrationEnabled;
  54713. private _grainEnabled;
  54714. private _buildAllowed;
  54715. /**
  54716. * Gets active scene
  54717. */
  54718. readonly scene: Scene;
  54719. /**
  54720. * Enable or disable the sharpen process from the pipeline
  54721. */
  54722. sharpenEnabled: boolean;
  54723. private _resizeObserver;
  54724. private _hardwareScaleLevel;
  54725. private _bloomKernel;
  54726. /**
  54727. * Specifies the size of the bloom blur kernel, relative to the final output size
  54728. */
  54729. bloomKernel: number;
  54730. /**
  54731. * Specifies the weight of the bloom in the final rendering
  54732. */
  54733. private _bloomWeight;
  54734. /**
  54735. * Specifies the luma threshold for the area that will be blurred by the bloom
  54736. */
  54737. private _bloomThreshold;
  54738. private _hdr;
  54739. /**
  54740. * The strength of the bloom.
  54741. */
  54742. bloomWeight: number;
  54743. /**
  54744. * The strength of the bloom.
  54745. */
  54746. bloomThreshold: number;
  54747. /**
  54748. * The scale of the bloom, lower value will provide better performance.
  54749. */
  54750. bloomScale: number;
  54751. /**
  54752. * Enable or disable the bloom from the pipeline
  54753. */
  54754. bloomEnabled: boolean;
  54755. private _rebuildBloom;
  54756. /**
  54757. * If the depth of field is enabled.
  54758. */
  54759. depthOfFieldEnabled: boolean;
  54760. /**
  54761. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54762. */
  54763. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54764. /**
  54765. * If the anti aliasing is enabled.
  54766. */
  54767. fxaaEnabled: boolean;
  54768. private _samples;
  54769. /**
  54770. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54771. */
  54772. samples: number;
  54773. /**
  54774. * If image processing is enabled.
  54775. */
  54776. imageProcessingEnabled: boolean;
  54777. /**
  54778. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54779. */
  54780. glowLayerEnabled: boolean;
  54781. /**
  54782. * Enable or disable the chromaticAberration process from the pipeline
  54783. */
  54784. chromaticAberrationEnabled: boolean;
  54785. /**
  54786. * Enable or disable the grain process from the pipeline
  54787. */
  54788. grainEnabled: boolean;
  54789. /**
  54790. * @constructor
  54791. * @param name - The rendering pipeline name (default: "")
  54792. * @param hdr - If high dynamic range textures should be used (default: true)
  54793. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54794. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54795. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54796. */
  54797. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54798. /**
  54799. * Get the class name
  54800. * @returns "DefaultRenderingPipeline"
  54801. */
  54802. getClassName(): string;
  54803. /**
  54804. * Force the compilation of the entire pipeline.
  54805. */
  54806. prepare(): void;
  54807. private _hasCleared;
  54808. private _prevPostProcess;
  54809. private _prevPrevPostProcess;
  54810. private _setAutoClearAndTextureSharing;
  54811. private _depthOfFieldSceneObserver;
  54812. private _buildPipeline;
  54813. private _disposePostProcesses;
  54814. /**
  54815. * Adds a camera to the pipeline
  54816. * @param camera the camera to be added
  54817. */
  54818. addCamera(camera: Camera): void;
  54819. /**
  54820. * Removes a camera from the pipeline
  54821. * @param camera the camera to remove
  54822. */
  54823. removeCamera(camera: Camera): void;
  54824. /**
  54825. * Dispose of the pipeline and stop all post processes
  54826. */
  54827. dispose(): void;
  54828. /**
  54829. * Serialize the rendering pipeline (Used when exporting)
  54830. * @returns the serialized object
  54831. */
  54832. serialize(): any;
  54833. /**
  54834. * Parse the serialized pipeline
  54835. * @param source Source pipeline.
  54836. * @param scene The scene to load the pipeline to.
  54837. * @param rootUrl The URL of the serialized pipeline.
  54838. * @returns An instantiated pipeline from the serialized object.
  54839. */
  54840. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54841. }
  54842. }
  54843. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54844. /** @hidden */
  54845. export var lensHighlightsPixelShader: {
  54846. name: string;
  54847. shader: string;
  54848. };
  54849. }
  54850. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54851. /** @hidden */
  54852. export var depthOfFieldPixelShader: {
  54853. name: string;
  54854. shader: string;
  54855. };
  54856. }
  54857. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54858. import { Camera } from "babylonjs/Cameras/camera";
  54859. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54860. import { Scene } from "babylonjs/scene";
  54861. import "babylonjs/Shaders/chromaticAberration.fragment";
  54862. import "babylonjs/Shaders/lensHighlights.fragment";
  54863. import "babylonjs/Shaders/depthOfField.fragment";
  54864. /**
  54865. * BABYLON.JS Chromatic Aberration GLSL Shader
  54866. * Author: Olivier Guyot
  54867. * Separates very slightly R, G and B colors on the edges of the screen
  54868. * Inspired by Francois Tarlier & Martins Upitis
  54869. */
  54870. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54871. /**
  54872. * @ignore
  54873. * The chromatic aberration PostProcess id in the pipeline
  54874. */
  54875. LensChromaticAberrationEffect: string;
  54876. /**
  54877. * @ignore
  54878. * The highlights enhancing PostProcess id in the pipeline
  54879. */
  54880. HighlightsEnhancingEffect: string;
  54881. /**
  54882. * @ignore
  54883. * The depth-of-field PostProcess id in the pipeline
  54884. */
  54885. LensDepthOfFieldEffect: string;
  54886. private _scene;
  54887. private _depthTexture;
  54888. private _grainTexture;
  54889. private _chromaticAberrationPostProcess;
  54890. private _highlightsPostProcess;
  54891. private _depthOfFieldPostProcess;
  54892. private _edgeBlur;
  54893. private _grainAmount;
  54894. private _chromaticAberration;
  54895. private _distortion;
  54896. private _highlightsGain;
  54897. private _highlightsThreshold;
  54898. private _dofDistance;
  54899. private _dofAperture;
  54900. private _dofDarken;
  54901. private _dofPentagon;
  54902. private _blurNoise;
  54903. /**
  54904. * @constructor
  54905. *
  54906. * Effect parameters are as follow:
  54907. * {
  54908. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54909. * edge_blur: number; // from 0 to x (1 for realism)
  54910. * distortion: number; // from 0 to x (1 for realism)
  54911. * grain_amount: number; // from 0 to 1
  54912. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54913. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54914. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54915. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54916. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54917. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54918. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54919. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54920. * }
  54921. * Note: if an effect parameter is unset, effect is disabled
  54922. *
  54923. * @param name The rendering pipeline name
  54924. * @param parameters - An object containing all parameters (see above)
  54925. * @param scene The scene linked to this pipeline
  54926. * @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)
  54927. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54928. */
  54929. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54930. /**
  54931. * Get the class name
  54932. * @returns "LensRenderingPipeline"
  54933. */
  54934. getClassName(): string;
  54935. /**
  54936. * Gets associated scene
  54937. */
  54938. readonly scene: Scene;
  54939. /**
  54940. * Gets or sets the edge blur
  54941. */
  54942. edgeBlur: number;
  54943. /**
  54944. * Gets or sets the grain amount
  54945. */
  54946. grainAmount: number;
  54947. /**
  54948. * Gets or sets the chromatic aberration amount
  54949. */
  54950. chromaticAberration: number;
  54951. /**
  54952. * Gets or sets the depth of field aperture
  54953. */
  54954. dofAperture: number;
  54955. /**
  54956. * Gets or sets the edge distortion
  54957. */
  54958. edgeDistortion: number;
  54959. /**
  54960. * Gets or sets the depth of field distortion
  54961. */
  54962. dofDistortion: number;
  54963. /**
  54964. * Gets or sets the darken out of focus amount
  54965. */
  54966. darkenOutOfFocus: number;
  54967. /**
  54968. * Gets or sets a boolean indicating if blur noise is enabled
  54969. */
  54970. blurNoise: boolean;
  54971. /**
  54972. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  54973. */
  54974. pentagonBokeh: boolean;
  54975. /**
  54976. * Gets or sets the highlight grain amount
  54977. */
  54978. highlightsGain: number;
  54979. /**
  54980. * Gets or sets the highlight threshold
  54981. */
  54982. highlightsThreshold: number;
  54983. /**
  54984. * Sets the amount of blur at the edges
  54985. * @param amount blur amount
  54986. */
  54987. setEdgeBlur(amount: number): void;
  54988. /**
  54989. * Sets edge blur to 0
  54990. */
  54991. disableEdgeBlur(): void;
  54992. /**
  54993. * Sets the amout of grain
  54994. * @param amount Amount of grain
  54995. */
  54996. setGrainAmount(amount: number): void;
  54997. /**
  54998. * Set grain amount to 0
  54999. */
  55000. disableGrain(): void;
  55001. /**
  55002. * Sets the chromatic aberration amount
  55003. * @param amount amount of chromatic aberration
  55004. */
  55005. setChromaticAberration(amount: number): void;
  55006. /**
  55007. * Sets chromatic aberration amount to 0
  55008. */
  55009. disableChromaticAberration(): void;
  55010. /**
  55011. * Sets the EdgeDistortion amount
  55012. * @param amount amount of EdgeDistortion
  55013. */
  55014. setEdgeDistortion(amount: number): void;
  55015. /**
  55016. * Sets edge distortion to 0
  55017. */
  55018. disableEdgeDistortion(): void;
  55019. /**
  55020. * Sets the FocusDistance amount
  55021. * @param amount amount of FocusDistance
  55022. */
  55023. setFocusDistance(amount: number): void;
  55024. /**
  55025. * Disables depth of field
  55026. */
  55027. disableDepthOfField(): void;
  55028. /**
  55029. * Sets the Aperture amount
  55030. * @param amount amount of Aperture
  55031. */
  55032. setAperture(amount: number): void;
  55033. /**
  55034. * Sets the DarkenOutOfFocus amount
  55035. * @param amount amount of DarkenOutOfFocus
  55036. */
  55037. setDarkenOutOfFocus(amount: number): void;
  55038. private _pentagonBokehIsEnabled;
  55039. /**
  55040. * Creates a pentagon bokeh effect
  55041. */
  55042. enablePentagonBokeh(): void;
  55043. /**
  55044. * Disables the pentagon bokeh effect
  55045. */
  55046. disablePentagonBokeh(): void;
  55047. /**
  55048. * Enables noise blur
  55049. */
  55050. enableNoiseBlur(): void;
  55051. /**
  55052. * Disables noise blur
  55053. */
  55054. disableNoiseBlur(): void;
  55055. /**
  55056. * Sets the HighlightsGain amount
  55057. * @param amount amount of HighlightsGain
  55058. */
  55059. setHighlightsGain(amount: number): void;
  55060. /**
  55061. * Sets the HighlightsThreshold amount
  55062. * @param amount amount of HighlightsThreshold
  55063. */
  55064. setHighlightsThreshold(amount: number): void;
  55065. /**
  55066. * Disables highlights
  55067. */
  55068. disableHighlights(): void;
  55069. /**
  55070. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55071. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55072. */
  55073. dispose(disableDepthRender?: boolean): void;
  55074. private _createChromaticAberrationPostProcess;
  55075. private _createHighlightsPostProcess;
  55076. private _createDepthOfFieldPostProcess;
  55077. private _createGrainTexture;
  55078. }
  55079. }
  55080. declare module "babylonjs/Shaders/ssao2.fragment" {
  55081. /** @hidden */
  55082. export var ssao2PixelShader: {
  55083. name: string;
  55084. shader: string;
  55085. };
  55086. }
  55087. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55088. /** @hidden */
  55089. export var ssaoCombinePixelShader: {
  55090. name: string;
  55091. shader: string;
  55092. };
  55093. }
  55094. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55095. import { Camera } from "babylonjs/Cameras/camera";
  55096. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55097. import { Scene } from "babylonjs/scene";
  55098. import "babylonjs/Shaders/ssao2.fragment";
  55099. import "babylonjs/Shaders/ssaoCombine.fragment";
  55100. /**
  55101. * Render pipeline to produce ssao effect
  55102. */
  55103. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55104. /**
  55105. * @ignore
  55106. * The PassPostProcess id in the pipeline that contains the original scene color
  55107. */
  55108. SSAOOriginalSceneColorEffect: string;
  55109. /**
  55110. * @ignore
  55111. * The SSAO PostProcess id in the pipeline
  55112. */
  55113. SSAORenderEffect: string;
  55114. /**
  55115. * @ignore
  55116. * The horizontal blur PostProcess id in the pipeline
  55117. */
  55118. SSAOBlurHRenderEffect: string;
  55119. /**
  55120. * @ignore
  55121. * The vertical blur PostProcess id in the pipeline
  55122. */
  55123. SSAOBlurVRenderEffect: string;
  55124. /**
  55125. * @ignore
  55126. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55127. */
  55128. SSAOCombineRenderEffect: string;
  55129. /**
  55130. * The output strength of the SSAO post-process. Default value is 1.0.
  55131. */
  55132. totalStrength: number;
  55133. /**
  55134. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55135. */
  55136. maxZ: number;
  55137. /**
  55138. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55139. */
  55140. minZAspect: number;
  55141. private _samples;
  55142. /**
  55143. * Number of samples used for the SSAO calculations. Default value is 8
  55144. */
  55145. samples: number;
  55146. private _textureSamples;
  55147. /**
  55148. * Number of samples to use for antialiasing
  55149. */
  55150. textureSamples: number;
  55151. /**
  55152. * Ratio object used for SSAO ratio and blur ratio
  55153. */
  55154. private _ratio;
  55155. /**
  55156. * Dynamically generated sphere sampler.
  55157. */
  55158. private _sampleSphere;
  55159. /**
  55160. * Blur filter offsets
  55161. */
  55162. private _samplerOffsets;
  55163. private _expensiveBlur;
  55164. /**
  55165. * If bilateral blur should be used
  55166. */
  55167. expensiveBlur: boolean;
  55168. /**
  55169. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55170. */
  55171. radius: number;
  55172. /**
  55173. * The base color of the SSAO post-process
  55174. * The final result is "base + ssao" between [0, 1]
  55175. */
  55176. base: number;
  55177. /**
  55178. * Support test.
  55179. */
  55180. static readonly IsSupported: boolean;
  55181. private _scene;
  55182. private _depthTexture;
  55183. private _normalTexture;
  55184. private _randomTexture;
  55185. private _originalColorPostProcess;
  55186. private _ssaoPostProcess;
  55187. private _blurHPostProcess;
  55188. private _blurVPostProcess;
  55189. private _ssaoCombinePostProcess;
  55190. private _firstUpdate;
  55191. /**
  55192. * Gets active scene
  55193. */
  55194. readonly scene: Scene;
  55195. /**
  55196. * @constructor
  55197. * @param name The rendering pipeline name
  55198. * @param scene The scene linked to this pipeline
  55199. * @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 }
  55200. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55201. */
  55202. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55203. /**
  55204. * Get the class name
  55205. * @returns "SSAO2RenderingPipeline"
  55206. */
  55207. getClassName(): string;
  55208. /**
  55209. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55210. */
  55211. dispose(disableGeometryBufferRenderer?: boolean): void;
  55212. private _createBlurPostProcess;
  55213. /** @hidden */
  55214. _rebuild(): void;
  55215. private _bits;
  55216. private _radicalInverse_VdC;
  55217. private _hammersley;
  55218. private _hemisphereSample_uniform;
  55219. private _generateHemisphere;
  55220. private _createSSAOPostProcess;
  55221. private _createSSAOCombinePostProcess;
  55222. private _createRandomTexture;
  55223. /**
  55224. * Serialize the rendering pipeline (Used when exporting)
  55225. * @returns the serialized object
  55226. */
  55227. serialize(): any;
  55228. /**
  55229. * Parse the serialized pipeline
  55230. * @param source Source pipeline.
  55231. * @param scene The scene to load the pipeline to.
  55232. * @param rootUrl The URL of the serialized pipeline.
  55233. * @returns An instantiated pipeline from the serialized object.
  55234. */
  55235. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55236. }
  55237. }
  55238. declare module "babylonjs/Shaders/ssao.fragment" {
  55239. /** @hidden */
  55240. export var ssaoPixelShader: {
  55241. name: string;
  55242. shader: string;
  55243. };
  55244. }
  55245. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55246. import { Camera } from "babylonjs/Cameras/camera";
  55247. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55248. import { Scene } from "babylonjs/scene";
  55249. import "babylonjs/Shaders/ssao.fragment";
  55250. import "babylonjs/Shaders/ssaoCombine.fragment";
  55251. /**
  55252. * Render pipeline to produce ssao effect
  55253. */
  55254. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55255. /**
  55256. * @ignore
  55257. * The PassPostProcess id in the pipeline that contains the original scene color
  55258. */
  55259. SSAOOriginalSceneColorEffect: string;
  55260. /**
  55261. * @ignore
  55262. * The SSAO PostProcess id in the pipeline
  55263. */
  55264. SSAORenderEffect: string;
  55265. /**
  55266. * @ignore
  55267. * The horizontal blur PostProcess id in the pipeline
  55268. */
  55269. SSAOBlurHRenderEffect: string;
  55270. /**
  55271. * @ignore
  55272. * The vertical blur PostProcess id in the pipeline
  55273. */
  55274. SSAOBlurVRenderEffect: string;
  55275. /**
  55276. * @ignore
  55277. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55278. */
  55279. SSAOCombineRenderEffect: string;
  55280. /**
  55281. * The output strength of the SSAO post-process. Default value is 1.0.
  55282. */
  55283. totalStrength: number;
  55284. /**
  55285. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55286. */
  55287. radius: number;
  55288. /**
  55289. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55290. * Must not be equal to fallOff and superior to fallOff.
  55291. * Default value is 0.0075
  55292. */
  55293. area: number;
  55294. /**
  55295. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55296. * Must not be equal to area and inferior to area.
  55297. * Default value is 0.000001
  55298. */
  55299. fallOff: number;
  55300. /**
  55301. * The base color of the SSAO post-process
  55302. * The final result is "base + ssao" between [0, 1]
  55303. */
  55304. base: number;
  55305. private _scene;
  55306. private _depthTexture;
  55307. private _randomTexture;
  55308. private _originalColorPostProcess;
  55309. private _ssaoPostProcess;
  55310. private _blurHPostProcess;
  55311. private _blurVPostProcess;
  55312. private _ssaoCombinePostProcess;
  55313. private _firstUpdate;
  55314. /**
  55315. * Gets active scene
  55316. */
  55317. readonly scene: Scene;
  55318. /**
  55319. * @constructor
  55320. * @param name - The rendering pipeline name
  55321. * @param scene - The scene linked to this pipeline
  55322. * @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 }
  55323. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55324. */
  55325. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55326. /**
  55327. * Get the class name
  55328. * @returns "SSAORenderingPipeline"
  55329. */
  55330. getClassName(): string;
  55331. /**
  55332. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55333. */
  55334. dispose(disableDepthRender?: boolean): void;
  55335. private _createBlurPostProcess;
  55336. /** @hidden */
  55337. _rebuild(): void;
  55338. private _createSSAOPostProcess;
  55339. private _createSSAOCombinePostProcess;
  55340. private _createRandomTexture;
  55341. }
  55342. }
  55343. declare module "babylonjs/Shaders/standard.fragment" {
  55344. /** @hidden */
  55345. export var standardPixelShader: {
  55346. name: string;
  55347. shader: string;
  55348. };
  55349. }
  55350. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55351. import { Nullable } from "babylonjs/types";
  55352. import { IAnimatable } from "babylonjs/Misc/tools";
  55353. import { Camera } from "babylonjs/Cameras/camera";
  55354. import { Texture } from "babylonjs/Materials/Textures/texture";
  55355. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55356. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55357. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55358. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55359. import { IDisposable } from "babylonjs/scene";
  55360. import { SpotLight } from "babylonjs/Lights/spotLight";
  55361. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55362. import { Scene } from "babylonjs/scene";
  55363. import { Animation } from "babylonjs/Animations/animation";
  55364. import "babylonjs/Shaders/standard.fragment";
  55365. /**
  55366. * Standard rendering pipeline
  55367. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55368. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55369. */
  55370. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55371. /**
  55372. * Public members
  55373. */
  55374. /**
  55375. * Post-process which contains the original scene color before the pipeline applies all the effects
  55376. */
  55377. originalPostProcess: Nullable<PostProcess>;
  55378. /**
  55379. * Post-process used to down scale an image x4
  55380. */
  55381. downSampleX4PostProcess: Nullable<PostProcess>;
  55382. /**
  55383. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55384. */
  55385. brightPassPostProcess: Nullable<PostProcess>;
  55386. /**
  55387. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55388. */
  55389. blurHPostProcesses: PostProcess[];
  55390. /**
  55391. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55392. */
  55393. blurVPostProcesses: PostProcess[];
  55394. /**
  55395. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55396. */
  55397. textureAdderPostProcess: Nullable<PostProcess>;
  55398. /**
  55399. * Post-process used to create volumetric lighting effect
  55400. */
  55401. volumetricLightPostProcess: Nullable<PostProcess>;
  55402. /**
  55403. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55404. */
  55405. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55406. /**
  55407. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55408. */
  55409. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55410. /**
  55411. * Post-process used to merge the volumetric light effect and the real scene color
  55412. */
  55413. volumetricLightMergePostProces: Nullable<PostProcess>;
  55414. /**
  55415. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55416. */
  55417. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55418. /**
  55419. * Base post-process used to calculate the average luminance of the final image for HDR
  55420. */
  55421. luminancePostProcess: Nullable<PostProcess>;
  55422. /**
  55423. * Post-processes used to create down sample post-processes in order to get
  55424. * the average luminance of the final image for HDR
  55425. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55426. */
  55427. luminanceDownSamplePostProcesses: PostProcess[];
  55428. /**
  55429. * Post-process used to create a HDR effect (light adaptation)
  55430. */
  55431. hdrPostProcess: Nullable<PostProcess>;
  55432. /**
  55433. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  55434. */
  55435. textureAdderFinalPostProcess: Nullable<PostProcess>;
  55436. /**
  55437. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  55438. */
  55439. lensFlareFinalPostProcess: Nullable<PostProcess>;
  55440. /**
  55441. * Post-process used to merge the final HDR post-process and the real scene color
  55442. */
  55443. hdrFinalPostProcess: Nullable<PostProcess>;
  55444. /**
  55445. * Post-process used to create a lens flare effect
  55446. */
  55447. lensFlarePostProcess: Nullable<PostProcess>;
  55448. /**
  55449. * Post-process that merges the result of the lens flare post-process and the real scene color
  55450. */
  55451. lensFlareComposePostProcess: Nullable<PostProcess>;
  55452. /**
  55453. * Post-process used to create a motion blur effect
  55454. */
  55455. motionBlurPostProcess: Nullable<PostProcess>;
  55456. /**
  55457. * Post-process used to create a depth of field effect
  55458. */
  55459. depthOfFieldPostProcess: Nullable<PostProcess>;
  55460. /**
  55461. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55462. */
  55463. fxaaPostProcess: Nullable<FxaaPostProcess>;
  55464. /**
  55465. * Represents the brightness threshold in order to configure the illuminated surfaces
  55466. */
  55467. brightThreshold: number;
  55468. /**
  55469. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  55470. */
  55471. blurWidth: number;
  55472. /**
  55473. * Sets if the blur for highlighted surfaces must be only horizontal
  55474. */
  55475. horizontalBlur: boolean;
  55476. /**
  55477. * Sets the overall exposure used by the pipeline
  55478. */
  55479. exposure: number;
  55480. /**
  55481. * Texture used typically to simulate "dirty" on camera lens
  55482. */
  55483. lensTexture: Nullable<Texture>;
  55484. /**
  55485. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  55486. */
  55487. volumetricLightCoefficient: number;
  55488. /**
  55489. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  55490. */
  55491. volumetricLightPower: number;
  55492. /**
  55493. * Used the set the blur intensity to smooth the volumetric lights
  55494. */
  55495. volumetricLightBlurScale: number;
  55496. /**
  55497. * Light (spot or directional) used to generate the volumetric lights rays
  55498. * The source light must have a shadow generate so the pipeline can get its
  55499. * depth map
  55500. */
  55501. sourceLight: Nullable<SpotLight | DirectionalLight>;
  55502. /**
  55503. * For eye adaptation, represents the minimum luminance the eye can see
  55504. */
  55505. hdrMinimumLuminance: number;
  55506. /**
  55507. * For eye adaptation, represents the decrease luminance speed
  55508. */
  55509. hdrDecreaseRate: number;
  55510. /**
  55511. * For eye adaptation, represents the increase luminance speed
  55512. */
  55513. hdrIncreaseRate: number;
  55514. /**
  55515. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55516. */
  55517. lensColorTexture: Nullable<Texture>;
  55518. /**
  55519. * The overall strengh for the lens flare effect
  55520. */
  55521. lensFlareStrength: number;
  55522. /**
  55523. * Dispersion coefficient for lens flare ghosts
  55524. */
  55525. lensFlareGhostDispersal: number;
  55526. /**
  55527. * Main lens flare halo width
  55528. */
  55529. lensFlareHaloWidth: number;
  55530. /**
  55531. * Based on the lens distortion effect, defines how much the lens flare result
  55532. * is distorted
  55533. */
  55534. lensFlareDistortionStrength: number;
  55535. /**
  55536. * Lens star texture must be used to simulate rays on the flares and is available
  55537. * in the documentation
  55538. */
  55539. lensStarTexture: Nullable<Texture>;
  55540. /**
  55541. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55542. * flare effect by taking account of the dirt texture
  55543. */
  55544. lensFlareDirtTexture: Nullable<Texture>;
  55545. /**
  55546. * Represents the focal length for the depth of field effect
  55547. */
  55548. depthOfFieldDistance: number;
  55549. /**
  55550. * Represents the blur intensity for the blurred part of the depth of field effect
  55551. */
  55552. depthOfFieldBlurWidth: number;
  55553. /**
  55554. * For motion blur, defines how much the image is blurred by the movement
  55555. */
  55556. motionStrength: number;
  55557. /**
  55558. * List of animations for the pipeline (IAnimatable implementation)
  55559. */
  55560. animations: Animation[];
  55561. /**
  55562. * Private members
  55563. */
  55564. private _scene;
  55565. private _currentDepthOfFieldSource;
  55566. private _basePostProcess;
  55567. private _hdrCurrentLuminance;
  55568. private _floatTextureType;
  55569. private _ratio;
  55570. private _bloomEnabled;
  55571. private _depthOfFieldEnabled;
  55572. private _vlsEnabled;
  55573. private _lensFlareEnabled;
  55574. private _hdrEnabled;
  55575. private _motionBlurEnabled;
  55576. private _fxaaEnabled;
  55577. private _motionBlurSamples;
  55578. private _volumetricLightStepsCount;
  55579. private _samples;
  55580. /**
  55581. * @ignore
  55582. * Specifies if the bloom pipeline is enabled
  55583. */
  55584. BloomEnabled: boolean;
  55585. /**
  55586. * @ignore
  55587. * Specifies if the depth of field pipeline is enabed
  55588. */
  55589. DepthOfFieldEnabled: boolean;
  55590. /**
  55591. * @ignore
  55592. * Specifies if the lens flare pipeline is enabed
  55593. */
  55594. LensFlareEnabled: boolean;
  55595. /**
  55596. * @ignore
  55597. * Specifies if the HDR pipeline is enabled
  55598. */
  55599. HDREnabled: boolean;
  55600. /**
  55601. * @ignore
  55602. * Specifies if the volumetric lights scattering effect is enabled
  55603. */
  55604. VLSEnabled: boolean;
  55605. /**
  55606. * @ignore
  55607. * Specifies if the motion blur effect is enabled
  55608. */
  55609. MotionBlurEnabled: boolean;
  55610. /**
  55611. * Specifies if anti-aliasing is enabled
  55612. */
  55613. fxaaEnabled: boolean;
  55614. /**
  55615. * Specifies the number of steps used to calculate the volumetric lights
  55616. * Typically in interval [50, 200]
  55617. */
  55618. volumetricLightStepsCount: number;
  55619. /**
  55620. * Specifies the number of samples used for the motion blur effect
  55621. * Typically in interval [16, 64]
  55622. */
  55623. motionBlurSamples: number;
  55624. /**
  55625. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55626. */
  55627. samples: number;
  55628. /**
  55629. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55630. * @constructor
  55631. * @param name The rendering pipeline name
  55632. * @param scene The scene linked to this pipeline
  55633. * @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)
  55634. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55635. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55636. */
  55637. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55638. private _buildPipeline;
  55639. private _createDownSampleX4PostProcess;
  55640. private _createBrightPassPostProcess;
  55641. private _createBlurPostProcesses;
  55642. private _createTextureAdderPostProcess;
  55643. private _createVolumetricLightPostProcess;
  55644. private _createLuminancePostProcesses;
  55645. private _createHdrPostProcess;
  55646. private _createLensFlarePostProcess;
  55647. private _createDepthOfFieldPostProcess;
  55648. private _createMotionBlurPostProcess;
  55649. private _getDepthTexture;
  55650. private _disposePostProcesses;
  55651. /**
  55652. * Dispose of the pipeline and stop all post processes
  55653. */
  55654. dispose(): void;
  55655. /**
  55656. * Serialize the rendering pipeline (Used when exporting)
  55657. * @returns the serialized object
  55658. */
  55659. serialize(): any;
  55660. /**
  55661. * Parse the serialized pipeline
  55662. * @param source Source pipeline.
  55663. * @param scene The scene to load the pipeline to.
  55664. * @param rootUrl The URL of the serialized pipeline.
  55665. * @returns An instantiated pipeline from the serialized object.
  55666. */
  55667. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55668. /**
  55669. * Luminance steps
  55670. */
  55671. static LuminanceSteps: number;
  55672. }
  55673. }
  55674. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55675. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55676. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55677. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55678. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55679. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55680. }
  55681. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55682. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55683. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55684. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55685. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55686. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55687. }
  55688. declare module "babylonjs/Shaders/tonemap.fragment" {
  55689. /** @hidden */
  55690. export var tonemapPixelShader: {
  55691. name: string;
  55692. shader: string;
  55693. };
  55694. }
  55695. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55696. import { Camera } from "babylonjs/Cameras/camera";
  55697. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55698. import "babylonjs/Shaders/tonemap.fragment";
  55699. import { Engine } from "babylonjs/Engines/engine";
  55700. /** Defines operator used for tonemapping */
  55701. export enum TonemappingOperator {
  55702. /** Hable */
  55703. Hable = 0,
  55704. /** Reinhard */
  55705. Reinhard = 1,
  55706. /** HejiDawson */
  55707. HejiDawson = 2,
  55708. /** Photographic */
  55709. Photographic = 3
  55710. }
  55711. /**
  55712. * Defines a post process to apply tone mapping
  55713. */
  55714. export class TonemapPostProcess extends PostProcess {
  55715. private _operator;
  55716. /** Defines the required exposure adjustement */
  55717. exposureAdjustment: number;
  55718. /**
  55719. * Creates a new TonemapPostProcess
  55720. * @param name defines the name of the postprocess
  55721. * @param _operator defines the operator to use
  55722. * @param exposureAdjustment defines the required exposure adjustement
  55723. * @param camera defines the camera to use (can be null)
  55724. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55725. * @param engine defines the hosting engine (can be ignore if camera is set)
  55726. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55727. */
  55728. constructor(name: string, _operator: TonemappingOperator,
  55729. /** Defines the required exposure adjustement */
  55730. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55731. }
  55732. }
  55733. declare module "babylonjs/Shaders/depth.vertex" {
  55734. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55735. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55736. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55737. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55738. /** @hidden */
  55739. export var depthVertexShader: {
  55740. name: string;
  55741. shader: string;
  55742. };
  55743. }
  55744. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55745. /** @hidden */
  55746. export var volumetricLightScatteringPixelShader: {
  55747. name: string;
  55748. shader: string;
  55749. };
  55750. }
  55751. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55752. /** @hidden */
  55753. export var volumetricLightScatteringPassPixelShader: {
  55754. name: string;
  55755. shader: string;
  55756. };
  55757. }
  55758. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55759. import { Vector3 } from "babylonjs/Maths/math";
  55760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55761. import { Mesh } from "babylonjs/Meshes/mesh";
  55762. import { Camera } from "babylonjs/Cameras/camera";
  55763. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55764. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55765. import { Scene } from "babylonjs/scene";
  55766. import "babylonjs/Meshes/Builders/planeBuilder";
  55767. import "babylonjs/Shaders/depth.vertex";
  55768. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55769. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55770. import { Engine } from "babylonjs/Engines/engine";
  55771. /**
  55772. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55773. */
  55774. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55775. private _volumetricLightScatteringPass;
  55776. private _volumetricLightScatteringRTT;
  55777. private _viewPort;
  55778. private _screenCoordinates;
  55779. private _cachedDefines;
  55780. /**
  55781. * If not undefined, the mesh position is computed from the attached node position
  55782. */
  55783. attachedNode: {
  55784. position: Vector3;
  55785. };
  55786. /**
  55787. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55788. */
  55789. customMeshPosition: Vector3;
  55790. /**
  55791. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55792. */
  55793. useCustomMeshPosition: boolean;
  55794. /**
  55795. * If the post-process should inverse the light scattering direction
  55796. */
  55797. invert: boolean;
  55798. /**
  55799. * The internal mesh used by the post-process
  55800. */
  55801. mesh: Mesh;
  55802. /**
  55803. * @hidden
  55804. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55805. */
  55806. useDiffuseColor: boolean;
  55807. /**
  55808. * Array containing the excluded meshes not rendered in the internal pass
  55809. */
  55810. excludedMeshes: AbstractMesh[];
  55811. /**
  55812. * Controls the overall intensity of the post-process
  55813. */
  55814. exposure: number;
  55815. /**
  55816. * Dissipates each sample's contribution in range [0, 1]
  55817. */
  55818. decay: number;
  55819. /**
  55820. * Controls the overall intensity of each sample
  55821. */
  55822. weight: number;
  55823. /**
  55824. * Controls the density of each sample
  55825. */
  55826. density: number;
  55827. /**
  55828. * @constructor
  55829. * @param name The post-process name
  55830. * @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)
  55831. * @param camera The camera that the post-process will be attached to
  55832. * @param mesh The mesh used to create the light scattering
  55833. * @param samples The post-process quality, default 100
  55834. * @param samplingModeThe post-process filtering mode
  55835. * @param engine The babylon engine
  55836. * @param reusable If the post-process is reusable
  55837. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55838. */
  55839. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55840. /**
  55841. * Returns the string "VolumetricLightScatteringPostProcess"
  55842. * @returns "VolumetricLightScatteringPostProcess"
  55843. */
  55844. getClassName(): string;
  55845. private _isReady;
  55846. /**
  55847. * Sets the new light position for light scattering effect
  55848. * @param position The new custom light position
  55849. */
  55850. setCustomMeshPosition(position: Vector3): void;
  55851. /**
  55852. * Returns the light position for light scattering effect
  55853. * @return Vector3 The custom light position
  55854. */
  55855. getCustomMeshPosition(): Vector3;
  55856. /**
  55857. * Disposes the internal assets and detaches the post-process from the camera
  55858. */
  55859. dispose(camera: Camera): void;
  55860. /**
  55861. * Returns the render target texture used by the post-process
  55862. * @return the render target texture used by the post-process
  55863. */
  55864. getPass(): RenderTargetTexture;
  55865. private _meshExcluded;
  55866. private _createPass;
  55867. private _updateMeshScreenCoordinates;
  55868. /**
  55869. * Creates a default mesh for the Volumeric Light Scattering post-process
  55870. * @param name The mesh name
  55871. * @param scene The scene where to create the mesh
  55872. * @return the default mesh
  55873. */
  55874. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55875. }
  55876. }
  55877. declare module "babylonjs/PostProcesses/index" {
  55878. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55879. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55880. export * from "babylonjs/PostProcesses/bloomEffect";
  55881. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55882. export * from "babylonjs/PostProcesses/blurPostProcess";
  55883. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55884. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55885. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55886. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55887. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55888. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55889. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55890. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55891. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55892. export * from "babylonjs/PostProcesses/filterPostProcess";
  55893. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55894. export * from "babylonjs/PostProcesses/grainPostProcess";
  55895. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55896. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55897. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55898. export * from "babylonjs/PostProcesses/passPostProcess";
  55899. export * from "babylonjs/PostProcesses/postProcess";
  55900. export * from "babylonjs/PostProcesses/postProcessManager";
  55901. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55902. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55903. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55904. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55905. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55906. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55907. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55908. }
  55909. declare module "babylonjs/Probes/index" {
  55910. export * from "babylonjs/Probes/reflectionProbe";
  55911. }
  55912. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55913. import { Scene } from "babylonjs/scene";
  55914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55915. import { Color3 } from "babylonjs/Maths/math";
  55916. import { SmartArray } from "babylonjs/Misc/smartArray";
  55917. import { ISceneComponent } from "babylonjs/sceneComponent";
  55918. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55919. import "babylonjs/Meshes/Builders/boxBuilder";
  55920. import "babylonjs/Shaders/color.fragment";
  55921. import "babylonjs/Shaders/color.vertex";
  55922. module "babylonjs/scene" {
  55923. interface Scene {
  55924. /** @hidden (Backing field) */
  55925. _boundingBoxRenderer: BoundingBoxRenderer;
  55926. /** @hidden (Backing field) */
  55927. _forceShowBoundingBoxes: boolean;
  55928. /**
  55929. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55930. */
  55931. forceShowBoundingBoxes: boolean;
  55932. /**
  55933. * Gets the bounding box renderer associated with the scene
  55934. * @returns a BoundingBoxRenderer
  55935. */
  55936. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55937. }
  55938. }
  55939. module "babylonjs/Meshes/abstractMesh" {
  55940. interface AbstractMesh {
  55941. /** @hidden (Backing field) */
  55942. _showBoundingBox: boolean;
  55943. /**
  55944. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55945. */
  55946. showBoundingBox: boolean;
  55947. }
  55948. }
  55949. /**
  55950. * Component responsible of rendering the bounding box of the meshes in a scene.
  55951. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55952. */
  55953. export class BoundingBoxRenderer implements ISceneComponent {
  55954. /**
  55955. * The component name helpfull to identify the component in the list of scene components.
  55956. */
  55957. readonly name: string;
  55958. /**
  55959. * The scene the component belongs to.
  55960. */
  55961. scene: Scene;
  55962. /**
  55963. * Color of the bounding box lines placed in front of an object
  55964. */
  55965. frontColor: Color3;
  55966. /**
  55967. * Color of the bounding box lines placed behind an object
  55968. */
  55969. backColor: Color3;
  55970. /**
  55971. * Defines if the renderer should show the back lines or not
  55972. */
  55973. showBackLines: boolean;
  55974. /**
  55975. * @hidden
  55976. */
  55977. renderList: SmartArray<BoundingBox>;
  55978. private _colorShader;
  55979. private _vertexBuffers;
  55980. private _indexBuffer;
  55981. /**
  55982. * Instantiates a new bounding box renderer in a scene.
  55983. * @param scene the scene the renderer renders in
  55984. */
  55985. constructor(scene: Scene);
  55986. /**
  55987. * Registers the component in a given scene
  55988. */
  55989. register(): void;
  55990. private _evaluateSubMesh;
  55991. private _activeMesh;
  55992. private _prepareRessources;
  55993. private _createIndexBuffer;
  55994. /**
  55995. * Rebuilds the elements related to this component in case of
  55996. * context lost for instance.
  55997. */
  55998. rebuild(): void;
  55999. /**
  56000. * @hidden
  56001. */
  56002. reset(): void;
  56003. /**
  56004. * Render the bounding boxes of a specific rendering group
  56005. * @param renderingGroupId defines the rendering group to render
  56006. */
  56007. render(renderingGroupId: number): void;
  56008. /**
  56009. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56010. * @param mesh Define the mesh to render the occlusion bounding box for
  56011. */
  56012. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56013. /**
  56014. * Dispose and release the resources attached to this renderer.
  56015. */
  56016. dispose(): void;
  56017. }
  56018. }
  56019. declare module "babylonjs/Shaders/depth.fragment" {
  56020. /** @hidden */
  56021. export var depthPixelShader: {
  56022. name: string;
  56023. shader: string;
  56024. };
  56025. }
  56026. declare module "babylonjs/Rendering/depthRenderer" {
  56027. import { Nullable } from "babylonjs/types";
  56028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56029. import { Scene } from "babylonjs/scene";
  56030. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56031. import { Camera } from "babylonjs/Cameras/camera";
  56032. import "babylonjs/Shaders/depth.fragment";
  56033. import "babylonjs/Shaders/depth.vertex";
  56034. /**
  56035. * This represents a depth renderer in Babylon.
  56036. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56037. */
  56038. export class DepthRenderer {
  56039. private _scene;
  56040. private _depthMap;
  56041. private _effect;
  56042. private _cachedDefines;
  56043. private _camera;
  56044. /**
  56045. * Specifiess that the depth renderer will only be used within
  56046. * the camera it is created for.
  56047. * This can help forcing its rendering during the camera processing.
  56048. */
  56049. useOnlyInActiveCamera: boolean;
  56050. /** @hidden */
  56051. static _SceneComponentInitialization: (scene: Scene) => void;
  56052. /**
  56053. * Instantiates a depth renderer
  56054. * @param scene The scene the renderer belongs to
  56055. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56056. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56057. */
  56058. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56059. /**
  56060. * Creates the depth rendering effect and checks if the effect is ready.
  56061. * @param subMesh The submesh to be used to render the depth map of
  56062. * @param useInstances If multiple world instances should be used
  56063. * @returns if the depth renderer is ready to render the depth map
  56064. */
  56065. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56066. /**
  56067. * Gets the texture which the depth map will be written to.
  56068. * @returns The depth map texture
  56069. */
  56070. getDepthMap(): RenderTargetTexture;
  56071. /**
  56072. * Disposes of the depth renderer.
  56073. */
  56074. dispose(): void;
  56075. }
  56076. }
  56077. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56078. import { Nullable } from "babylonjs/types";
  56079. import { Scene } from "babylonjs/scene";
  56080. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56081. import { Camera } from "babylonjs/Cameras/camera";
  56082. import { ISceneComponent } from "babylonjs/sceneComponent";
  56083. module "babylonjs/scene" {
  56084. interface Scene {
  56085. /** @hidden (Backing field) */
  56086. _depthRenderer: {
  56087. [id: string]: DepthRenderer;
  56088. };
  56089. /**
  56090. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56091. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56092. * @returns the created depth renderer
  56093. */
  56094. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56095. /**
  56096. * Disables a depth renderer for a given camera
  56097. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56098. */
  56099. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56100. }
  56101. }
  56102. /**
  56103. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56104. * in several rendering techniques.
  56105. */
  56106. export class DepthRendererSceneComponent implements ISceneComponent {
  56107. /**
  56108. * The component name helpfull to identify the component in the list of scene components.
  56109. */
  56110. readonly name: string;
  56111. /**
  56112. * The scene the component belongs to.
  56113. */
  56114. scene: Scene;
  56115. /**
  56116. * Creates a new instance of the component for the given scene
  56117. * @param scene Defines the scene to register the component in
  56118. */
  56119. constructor(scene: Scene);
  56120. /**
  56121. * Registers the component in a given scene
  56122. */
  56123. register(): void;
  56124. /**
  56125. * Rebuilds the elements related to this component in case of
  56126. * context lost for instance.
  56127. */
  56128. rebuild(): void;
  56129. /**
  56130. * Disposes the component and the associated ressources
  56131. */
  56132. dispose(): void;
  56133. private _gatherRenderTargets;
  56134. private _gatherActiveCameraRenderTargets;
  56135. }
  56136. }
  56137. declare module "babylonjs/Shaders/outline.fragment" {
  56138. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56139. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56140. /** @hidden */
  56141. export var outlinePixelShader: {
  56142. name: string;
  56143. shader: string;
  56144. };
  56145. }
  56146. declare module "babylonjs/Shaders/outline.vertex" {
  56147. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56148. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56149. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56150. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56151. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56152. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56153. /** @hidden */
  56154. export var outlineVertexShader: {
  56155. name: string;
  56156. shader: string;
  56157. };
  56158. }
  56159. declare module "babylonjs/Rendering/outlineRenderer" {
  56160. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56161. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56162. import { Scene } from "babylonjs/scene";
  56163. import { ISceneComponent } from "babylonjs/sceneComponent";
  56164. import "babylonjs/Shaders/outline.fragment";
  56165. import "babylonjs/Shaders/outline.vertex";
  56166. module "babylonjs/scene" {
  56167. interface Scene {
  56168. /** @hidden */
  56169. _outlineRenderer: OutlineRenderer;
  56170. /**
  56171. * Gets the outline renderer associated with the scene
  56172. * @returns a OutlineRenderer
  56173. */
  56174. getOutlineRenderer(): OutlineRenderer;
  56175. }
  56176. }
  56177. module "babylonjs/Meshes/abstractMesh" {
  56178. interface AbstractMesh {
  56179. /** @hidden (Backing field) */
  56180. _renderOutline: boolean;
  56181. /**
  56182. * Gets or sets a boolean indicating if the outline must be rendered as well
  56183. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56184. */
  56185. renderOutline: boolean;
  56186. /** @hidden (Backing field) */
  56187. _renderOverlay: boolean;
  56188. /**
  56189. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56190. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56191. */
  56192. renderOverlay: boolean;
  56193. }
  56194. }
  56195. /**
  56196. * This class is responsible to draw bothe outline/overlay of meshes.
  56197. * It should not be used directly but through the available method on mesh.
  56198. */
  56199. export class OutlineRenderer implements ISceneComponent {
  56200. /**
  56201. * The name of the component. Each component must have a unique name.
  56202. */
  56203. name: string;
  56204. /**
  56205. * The scene the component belongs to.
  56206. */
  56207. scene: Scene;
  56208. /**
  56209. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56210. */
  56211. zOffset: number;
  56212. private _engine;
  56213. private _effect;
  56214. private _cachedDefines;
  56215. private _savedDepthWrite;
  56216. /**
  56217. * Instantiates a new outline renderer. (There could be only one per scene).
  56218. * @param scene Defines the scene it belongs to
  56219. */
  56220. constructor(scene: Scene);
  56221. /**
  56222. * Register the component to one instance of a scene.
  56223. */
  56224. register(): void;
  56225. /**
  56226. * Rebuilds the elements related to this component in case of
  56227. * context lost for instance.
  56228. */
  56229. rebuild(): void;
  56230. /**
  56231. * Disposes the component and the associated ressources.
  56232. */
  56233. dispose(): void;
  56234. /**
  56235. * Renders the outline in the canvas.
  56236. * @param subMesh Defines the sumesh to render
  56237. * @param batch Defines the batch of meshes in case of instances
  56238. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56239. */
  56240. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56241. /**
  56242. * Returns whether or not the outline renderer is ready for a given submesh.
  56243. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56244. * @param subMesh Defines the submesh to check readyness for
  56245. * @param useInstances Defines wheter wee are trying to render instances or not
  56246. * @returns true if ready otherwise false
  56247. */
  56248. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56249. private _beforeRenderingMesh;
  56250. private _afterRenderingMesh;
  56251. }
  56252. }
  56253. declare module "babylonjs/Rendering/index" {
  56254. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56255. export * from "babylonjs/Rendering/depthRenderer";
  56256. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56257. export * from "babylonjs/Rendering/edgesRenderer";
  56258. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56259. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56260. export * from "babylonjs/Rendering/outlineRenderer";
  56261. export * from "babylonjs/Rendering/renderingGroup";
  56262. export * from "babylonjs/Rendering/renderingManager";
  56263. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56264. }
  56265. declare module "babylonjs/Sprites/index" {
  56266. export * from "babylonjs/Sprites/sprite";
  56267. export * from "babylonjs/Sprites/spriteManager";
  56268. export * from "babylonjs/Sprites/spriteSceneComponent";
  56269. }
  56270. declare module "babylonjs/Misc/assetsManager" {
  56271. import { Scene } from "babylonjs/scene";
  56272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56273. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56274. import { Skeleton } from "babylonjs/Bones/skeleton";
  56275. import { Observable } from "babylonjs/Misc/observable";
  56276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56277. import { Texture } from "babylonjs/Materials/Textures/texture";
  56278. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56279. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56280. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56281. /**
  56282. * Defines the list of states available for a task inside a AssetsManager
  56283. */
  56284. export enum AssetTaskState {
  56285. /**
  56286. * Initialization
  56287. */
  56288. INIT = 0,
  56289. /**
  56290. * Running
  56291. */
  56292. RUNNING = 1,
  56293. /**
  56294. * Done
  56295. */
  56296. DONE = 2,
  56297. /**
  56298. * Error
  56299. */
  56300. ERROR = 3
  56301. }
  56302. /**
  56303. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56304. */
  56305. export abstract class AbstractAssetTask {
  56306. /**
  56307. * Task name
  56308. */ name: string;
  56309. /**
  56310. * Callback called when the task is successful
  56311. */
  56312. onSuccess: (task: any) => void;
  56313. /**
  56314. * Callback called when the task is not successful
  56315. */
  56316. onError: (task: any, message?: string, exception?: any) => void;
  56317. /**
  56318. * Creates a new AssetsManager
  56319. * @param name defines the name of the task
  56320. */
  56321. constructor(
  56322. /**
  56323. * Task name
  56324. */ name: string);
  56325. private _isCompleted;
  56326. private _taskState;
  56327. private _errorObject;
  56328. /**
  56329. * Get if the task is completed
  56330. */
  56331. readonly isCompleted: boolean;
  56332. /**
  56333. * Gets the current state of the task
  56334. */
  56335. readonly taskState: AssetTaskState;
  56336. /**
  56337. * Gets the current error object (if task is in error)
  56338. */
  56339. readonly errorObject: {
  56340. message?: string;
  56341. exception?: any;
  56342. };
  56343. /**
  56344. * Internal only
  56345. * @hidden
  56346. */
  56347. _setErrorObject(message?: string, exception?: any): void;
  56348. /**
  56349. * Execute the current task
  56350. * @param scene defines the scene where you want your assets to be loaded
  56351. * @param onSuccess is a callback called when the task is successfully executed
  56352. * @param onError is a callback called if an error occurs
  56353. */
  56354. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56355. /**
  56356. * Execute the current task
  56357. * @param scene defines the scene where you want your assets to be loaded
  56358. * @param onSuccess is a callback called when the task is successfully executed
  56359. * @param onError is a callback called if an error occurs
  56360. */
  56361. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56362. /**
  56363. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56364. * This can be used with failed tasks that have the reason for failure fixed.
  56365. */
  56366. reset(): void;
  56367. private onErrorCallback;
  56368. private onDoneCallback;
  56369. }
  56370. /**
  56371. * Define the interface used by progress events raised during assets loading
  56372. */
  56373. export interface IAssetsProgressEvent {
  56374. /**
  56375. * Defines the number of remaining tasks to process
  56376. */
  56377. remainingCount: number;
  56378. /**
  56379. * Defines the total number of tasks
  56380. */
  56381. totalCount: number;
  56382. /**
  56383. * Defines the task that was just processed
  56384. */
  56385. task: AbstractAssetTask;
  56386. }
  56387. /**
  56388. * Class used to share progress information about assets loading
  56389. */
  56390. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56391. /**
  56392. * Defines the number of remaining tasks to process
  56393. */
  56394. remainingCount: number;
  56395. /**
  56396. * Defines the total number of tasks
  56397. */
  56398. totalCount: number;
  56399. /**
  56400. * Defines the task that was just processed
  56401. */
  56402. task: AbstractAssetTask;
  56403. /**
  56404. * Creates a AssetsProgressEvent
  56405. * @param remainingCount defines the number of remaining tasks to process
  56406. * @param totalCount defines the total number of tasks
  56407. * @param task defines the task that was just processed
  56408. */
  56409. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56410. }
  56411. /**
  56412. * Define a task used by AssetsManager to load meshes
  56413. */
  56414. export class MeshAssetTask extends AbstractAssetTask {
  56415. /**
  56416. * Defines the name of the task
  56417. */
  56418. name: string;
  56419. /**
  56420. * Defines the list of mesh's names you want to load
  56421. */
  56422. meshesNames: any;
  56423. /**
  56424. * Defines the root url to use as a base to load your meshes and associated resources
  56425. */
  56426. rootUrl: string;
  56427. /**
  56428. * Defines the filename of the scene to load from
  56429. */
  56430. sceneFilename: string;
  56431. /**
  56432. * Gets the list of loaded meshes
  56433. */
  56434. loadedMeshes: Array<AbstractMesh>;
  56435. /**
  56436. * Gets the list of loaded particle systems
  56437. */
  56438. loadedParticleSystems: Array<IParticleSystem>;
  56439. /**
  56440. * Gets the list of loaded skeletons
  56441. */
  56442. loadedSkeletons: Array<Skeleton>;
  56443. /**
  56444. * Gets the list of loaded animation groups
  56445. */
  56446. loadedAnimationGroups: Array<AnimationGroup>;
  56447. /**
  56448. * Callback called when the task is successful
  56449. */
  56450. onSuccess: (task: MeshAssetTask) => void;
  56451. /**
  56452. * Callback called when the task is successful
  56453. */
  56454. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56455. /**
  56456. * Creates a new MeshAssetTask
  56457. * @param name defines the name of the task
  56458. * @param meshesNames defines the list of mesh's names you want to load
  56459. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56460. * @param sceneFilename defines the filename of the scene to load from
  56461. */
  56462. constructor(
  56463. /**
  56464. * Defines the name of the task
  56465. */
  56466. name: string,
  56467. /**
  56468. * Defines the list of mesh's names you want to load
  56469. */
  56470. meshesNames: any,
  56471. /**
  56472. * Defines the root url to use as a base to load your meshes and associated resources
  56473. */
  56474. rootUrl: string,
  56475. /**
  56476. * Defines the filename of the scene to load from
  56477. */
  56478. sceneFilename: string);
  56479. /**
  56480. * Execute the current task
  56481. * @param scene defines the scene where you want your assets to be loaded
  56482. * @param onSuccess is a callback called when the task is successfully executed
  56483. * @param onError is a callback called if an error occurs
  56484. */
  56485. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56486. }
  56487. /**
  56488. * Define a task used by AssetsManager to load text content
  56489. */
  56490. export class TextFileAssetTask extends AbstractAssetTask {
  56491. /**
  56492. * Defines the name of the task
  56493. */
  56494. name: string;
  56495. /**
  56496. * Defines the location of the file to load
  56497. */
  56498. url: string;
  56499. /**
  56500. * Gets the loaded text string
  56501. */
  56502. text: string;
  56503. /**
  56504. * Callback called when the task is successful
  56505. */
  56506. onSuccess: (task: TextFileAssetTask) => void;
  56507. /**
  56508. * Callback called when the task is successful
  56509. */
  56510. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56511. /**
  56512. * Creates a new TextFileAssetTask object
  56513. * @param name defines the name of the task
  56514. * @param url defines the location of the file to load
  56515. */
  56516. constructor(
  56517. /**
  56518. * Defines the name of the task
  56519. */
  56520. name: string,
  56521. /**
  56522. * Defines the location of the file to load
  56523. */
  56524. url: string);
  56525. /**
  56526. * Execute the current task
  56527. * @param scene defines the scene where you want your assets to be loaded
  56528. * @param onSuccess is a callback called when the task is successfully executed
  56529. * @param onError is a callback called if an error occurs
  56530. */
  56531. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56532. }
  56533. /**
  56534. * Define a task used by AssetsManager to load binary data
  56535. */
  56536. export class BinaryFileAssetTask extends AbstractAssetTask {
  56537. /**
  56538. * Defines the name of the task
  56539. */
  56540. name: string;
  56541. /**
  56542. * Defines the location of the file to load
  56543. */
  56544. url: string;
  56545. /**
  56546. * Gets the lodaded data (as an array buffer)
  56547. */
  56548. data: ArrayBuffer;
  56549. /**
  56550. * Callback called when the task is successful
  56551. */
  56552. onSuccess: (task: BinaryFileAssetTask) => void;
  56553. /**
  56554. * Callback called when the task is successful
  56555. */
  56556. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56557. /**
  56558. * Creates a new BinaryFileAssetTask object
  56559. * @param name defines the name of the new task
  56560. * @param url defines the location of the file to load
  56561. */
  56562. constructor(
  56563. /**
  56564. * Defines the name of the task
  56565. */
  56566. name: string,
  56567. /**
  56568. * Defines the location of the file to load
  56569. */
  56570. url: string);
  56571. /**
  56572. * Execute the current task
  56573. * @param scene defines the scene where you want your assets to be loaded
  56574. * @param onSuccess is a callback called when the task is successfully executed
  56575. * @param onError is a callback called if an error occurs
  56576. */
  56577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56578. }
  56579. /**
  56580. * Define a task used by AssetsManager to load images
  56581. */
  56582. export class ImageAssetTask extends AbstractAssetTask {
  56583. /**
  56584. * Defines the name of the task
  56585. */
  56586. name: string;
  56587. /**
  56588. * Defines the location of the image to load
  56589. */
  56590. url: string;
  56591. /**
  56592. * Gets the loaded images
  56593. */
  56594. image: HTMLImageElement;
  56595. /**
  56596. * Callback called when the task is successful
  56597. */
  56598. onSuccess: (task: ImageAssetTask) => void;
  56599. /**
  56600. * Callback called when the task is successful
  56601. */
  56602. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56603. /**
  56604. * Creates a new ImageAssetTask
  56605. * @param name defines the name of the task
  56606. * @param url defines the location of the image to load
  56607. */
  56608. constructor(
  56609. /**
  56610. * Defines the name of the task
  56611. */
  56612. name: string,
  56613. /**
  56614. * Defines the location of the image to load
  56615. */
  56616. url: string);
  56617. /**
  56618. * Execute the current task
  56619. * @param scene defines the scene where you want your assets to be loaded
  56620. * @param onSuccess is a callback called when the task is successfully executed
  56621. * @param onError is a callback called if an error occurs
  56622. */
  56623. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56624. }
  56625. /**
  56626. * Defines the interface used by texture loading tasks
  56627. */
  56628. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56629. /**
  56630. * Gets the loaded texture
  56631. */
  56632. texture: TEX;
  56633. }
  56634. /**
  56635. * Define a task used by AssetsManager to load 2D textures
  56636. */
  56637. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56638. /**
  56639. * Defines the name of the task
  56640. */
  56641. name: string;
  56642. /**
  56643. * Defines the location of the file to load
  56644. */
  56645. url: string;
  56646. /**
  56647. * Defines if mipmap should not be generated (default is false)
  56648. */
  56649. noMipmap?: boolean | undefined;
  56650. /**
  56651. * Defines if texture must be inverted on Y axis (default is false)
  56652. */
  56653. invertY?: boolean | undefined;
  56654. /**
  56655. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56656. */
  56657. samplingMode: number;
  56658. /**
  56659. * Gets the loaded texture
  56660. */
  56661. texture: Texture;
  56662. /**
  56663. * Callback called when the task is successful
  56664. */
  56665. onSuccess: (task: TextureAssetTask) => void;
  56666. /**
  56667. * Callback called when the task is successful
  56668. */
  56669. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56670. /**
  56671. * Creates a new TextureAssetTask object
  56672. * @param name defines the name of the task
  56673. * @param url defines the location of the file to load
  56674. * @param noMipmap defines if mipmap should not be generated (default is false)
  56675. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56676. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56677. */
  56678. constructor(
  56679. /**
  56680. * Defines the name of the task
  56681. */
  56682. name: string,
  56683. /**
  56684. * Defines the location of the file to load
  56685. */
  56686. url: string,
  56687. /**
  56688. * Defines if mipmap should not be generated (default is false)
  56689. */
  56690. noMipmap?: boolean | undefined,
  56691. /**
  56692. * Defines if texture must be inverted on Y axis (default is false)
  56693. */
  56694. invertY?: boolean | undefined,
  56695. /**
  56696. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56697. */
  56698. samplingMode?: number);
  56699. /**
  56700. * Execute the current task
  56701. * @param scene defines the scene where you want your assets to be loaded
  56702. * @param onSuccess is a callback called when the task is successfully executed
  56703. * @param onError is a callback called if an error occurs
  56704. */
  56705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56706. }
  56707. /**
  56708. * Define a task used by AssetsManager to load cube textures
  56709. */
  56710. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56711. /**
  56712. * Defines the name of the task
  56713. */
  56714. name: string;
  56715. /**
  56716. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56717. */
  56718. url: string;
  56719. /**
  56720. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56721. */
  56722. extensions?: string[] | undefined;
  56723. /**
  56724. * Defines if mipmaps should not be generated (default is false)
  56725. */
  56726. noMipmap?: boolean | undefined;
  56727. /**
  56728. * Defines the explicit list of files (undefined by default)
  56729. */
  56730. files?: string[] | undefined;
  56731. /**
  56732. * Gets the loaded texture
  56733. */
  56734. texture: CubeTexture;
  56735. /**
  56736. * Callback called when the task is successful
  56737. */
  56738. onSuccess: (task: CubeTextureAssetTask) => void;
  56739. /**
  56740. * Callback called when the task is successful
  56741. */
  56742. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56743. /**
  56744. * Creates a new CubeTextureAssetTask
  56745. * @param name defines the name of the task
  56746. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56747. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56748. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56749. * @param files defines the explicit list of files (undefined by default)
  56750. */
  56751. constructor(
  56752. /**
  56753. * Defines the name of the task
  56754. */
  56755. name: string,
  56756. /**
  56757. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56758. */
  56759. url: string,
  56760. /**
  56761. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56762. */
  56763. extensions?: string[] | undefined,
  56764. /**
  56765. * Defines if mipmaps should not be generated (default is false)
  56766. */
  56767. noMipmap?: boolean | undefined,
  56768. /**
  56769. * Defines the explicit list of files (undefined by default)
  56770. */
  56771. files?: string[] | undefined);
  56772. /**
  56773. * Execute the current task
  56774. * @param scene defines the scene where you want your assets to be loaded
  56775. * @param onSuccess is a callback called when the task is successfully executed
  56776. * @param onError is a callback called if an error occurs
  56777. */
  56778. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56779. }
  56780. /**
  56781. * Define a task used by AssetsManager to load HDR cube textures
  56782. */
  56783. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56784. /**
  56785. * Defines the name of the task
  56786. */
  56787. name: string;
  56788. /**
  56789. * Defines the location of the file to load
  56790. */
  56791. url: string;
  56792. /**
  56793. * Defines the desired size (the more it increases the longer the generation will be)
  56794. */
  56795. size: number;
  56796. /**
  56797. * Defines if mipmaps should not be generated (default is false)
  56798. */
  56799. noMipmap: boolean;
  56800. /**
  56801. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56802. */
  56803. generateHarmonics: boolean;
  56804. /**
  56805. * 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)
  56806. */
  56807. gammaSpace: boolean;
  56808. /**
  56809. * Internal Use Only
  56810. */
  56811. reserved: boolean;
  56812. /**
  56813. * Gets the loaded texture
  56814. */
  56815. texture: HDRCubeTexture;
  56816. /**
  56817. * Callback called when the task is successful
  56818. */
  56819. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56820. /**
  56821. * Callback called when the task is successful
  56822. */
  56823. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56824. /**
  56825. * Creates a new HDRCubeTextureAssetTask object
  56826. * @param name defines the name of the task
  56827. * @param url defines the location of the file to load
  56828. * @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.
  56829. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56830. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56831. * @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)
  56832. * @param reserved Internal use only
  56833. */
  56834. constructor(
  56835. /**
  56836. * Defines the name of the task
  56837. */
  56838. name: string,
  56839. /**
  56840. * Defines the location of the file to load
  56841. */
  56842. url: string,
  56843. /**
  56844. * Defines the desired size (the more it increases the longer the generation will be)
  56845. */
  56846. size: number,
  56847. /**
  56848. * Defines if mipmaps should not be generated (default is false)
  56849. */
  56850. noMipmap?: boolean,
  56851. /**
  56852. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56853. */
  56854. generateHarmonics?: boolean,
  56855. /**
  56856. * 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)
  56857. */
  56858. gammaSpace?: boolean,
  56859. /**
  56860. * Internal Use Only
  56861. */
  56862. reserved?: boolean);
  56863. /**
  56864. * Execute the current task
  56865. * @param scene defines the scene where you want your assets to be loaded
  56866. * @param onSuccess is a callback called when the task is successfully executed
  56867. * @param onError is a callback called if an error occurs
  56868. */
  56869. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56870. }
  56871. /**
  56872. * This class can be used to easily import assets into a scene
  56873. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56874. */
  56875. export class AssetsManager {
  56876. private _scene;
  56877. private _isLoading;
  56878. protected _tasks: AbstractAssetTask[];
  56879. protected _waitingTasksCount: number;
  56880. protected _totalTasksCount: number;
  56881. /**
  56882. * Callback called when all tasks are processed
  56883. */
  56884. onFinish: (tasks: AbstractAssetTask[]) => void;
  56885. /**
  56886. * Callback called when a task is successful
  56887. */
  56888. onTaskSuccess: (task: AbstractAssetTask) => void;
  56889. /**
  56890. * Callback called when a task had an error
  56891. */
  56892. onTaskError: (task: AbstractAssetTask) => void;
  56893. /**
  56894. * Callback called when a task is done (whatever the result is)
  56895. */
  56896. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56897. /**
  56898. * Observable called when all tasks are processed
  56899. */
  56900. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56901. /**
  56902. * Observable called when a task had an error
  56903. */
  56904. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56905. /**
  56906. * Observable called when all tasks were executed
  56907. */
  56908. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56909. /**
  56910. * Observable called when a task is done (whatever the result is)
  56911. */
  56912. onProgressObservable: Observable<IAssetsProgressEvent>;
  56913. /**
  56914. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56915. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56916. */
  56917. useDefaultLoadingScreen: boolean;
  56918. /**
  56919. * Creates a new AssetsManager
  56920. * @param scene defines the scene to work on
  56921. */
  56922. constructor(scene: Scene);
  56923. /**
  56924. * Add a MeshAssetTask to the list of active tasks
  56925. * @param taskName defines the name of the new task
  56926. * @param meshesNames defines the name of meshes to load
  56927. * @param rootUrl defines the root url to use to locate files
  56928. * @param sceneFilename defines the filename of the scene file
  56929. * @returns a new MeshAssetTask object
  56930. */
  56931. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56932. /**
  56933. * Add a TextFileAssetTask to the list of active tasks
  56934. * @param taskName defines the name of the new task
  56935. * @param url defines the url of the file to load
  56936. * @returns a new TextFileAssetTask object
  56937. */
  56938. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56939. /**
  56940. * Add a BinaryFileAssetTask to the list of active tasks
  56941. * @param taskName defines the name of the new task
  56942. * @param url defines the url of the file to load
  56943. * @returns a new BinaryFileAssetTask object
  56944. */
  56945. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56946. /**
  56947. * Add a ImageAssetTask to the list of active tasks
  56948. * @param taskName defines the name of the new task
  56949. * @param url defines the url of the file to load
  56950. * @returns a new ImageAssetTask object
  56951. */
  56952. addImageTask(taskName: string, url: string): ImageAssetTask;
  56953. /**
  56954. * Add a TextureAssetTask to the list of active tasks
  56955. * @param taskName defines the name of the new task
  56956. * @param url defines the url of the file to load
  56957. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56958. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56959. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56960. * @returns a new TextureAssetTask object
  56961. */
  56962. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56963. /**
  56964. * Add a CubeTextureAssetTask to the list of active tasks
  56965. * @param taskName defines the name of the new task
  56966. * @param url defines the url of the file to load
  56967. * @param extensions defines the extension to use to load the cube map (can be null)
  56968. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56969. * @param files defines the list of files to load (can be null)
  56970. * @returns a new CubeTextureAssetTask object
  56971. */
  56972. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56973. /**
  56974. *
  56975. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56976. * @param taskName defines the name of the new task
  56977. * @param url defines the url of the file to load
  56978. * @param size defines the size you want for the cubemap (can be null)
  56979. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56980. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56981. * @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)
  56982. * @param reserved Internal use only
  56983. * @returns a new HDRCubeTextureAssetTask object
  56984. */
  56985. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56986. /**
  56987. * Remove a task from the assets manager.
  56988. * @param task the task to remove
  56989. */
  56990. removeTask(task: AbstractAssetTask): void;
  56991. private _decreaseWaitingTasksCount;
  56992. private _runTask;
  56993. /**
  56994. * Reset the AssetsManager and remove all tasks
  56995. * @return the current instance of the AssetsManager
  56996. */
  56997. reset(): AssetsManager;
  56998. /**
  56999. * Start the loading process
  57000. * @return the current instance of the AssetsManager
  57001. */
  57002. load(): AssetsManager;
  57003. /**
  57004. * Start the loading process as an async operation
  57005. * @return a promise returning the list of failed tasks
  57006. */
  57007. loadAsync(): Promise<void>;
  57008. }
  57009. }
  57010. declare module "babylonjs/Misc/deferred" {
  57011. /**
  57012. * Wrapper class for promise with external resolve and reject.
  57013. */
  57014. export class Deferred<T> {
  57015. /**
  57016. * The promise associated with this deferred object.
  57017. */
  57018. readonly promise: Promise<T>;
  57019. private _resolve;
  57020. private _reject;
  57021. /**
  57022. * The resolve method of the promise associated with this deferred object.
  57023. */
  57024. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57025. /**
  57026. * The reject method of the promise associated with this deferred object.
  57027. */
  57028. readonly reject: (reason?: any) => void;
  57029. /**
  57030. * Constructor for this deferred object.
  57031. */
  57032. constructor();
  57033. }
  57034. }
  57035. declare module "babylonjs/Misc/meshExploder" {
  57036. import { Mesh } from "babylonjs/Meshes/mesh";
  57037. /**
  57038. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57039. */
  57040. export class MeshExploder {
  57041. private _centerMesh;
  57042. private _meshes;
  57043. private _meshesOrigins;
  57044. private _toCenterVectors;
  57045. private _scaledDirection;
  57046. private _newPosition;
  57047. private _centerPosition;
  57048. /**
  57049. * Explodes meshes from a center mesh.
  57050. * @param meshes The meshes to explode.
  57051. * @param centerMesh The mesh to be center of explosion.
  57052. */
  57053. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57054. private _setCenterMesh;
  57055. /**
  57056. * Get class name
  57057. * @returns "MeshExploder"
  57058. */
  57059. getClassName(): string;
  57060. /**
  57061. * "Exploded meshes"
  57062. * @returns Array of meshes with the centerMesh at index 0.
  57063. */
  57064. getMeshes(): Array<Mesh>;
  57065. /**
  57066. * Explodes meshes giving a specific direction
  57067. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57068. */
  57069. explode(direction?: number): void;
  57070. }
  57071. }
  57072. declare module "babylonjs/Misc/filesInput" {
  57073. import { Engine } from "babylonjs/Engines/engine";
  57074. import { Scene } from "babylonjs/scene";
  57075. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57076. /**
  57077. * Class used to help managing file picking and drag'n'drop
  57078. */
  57079. export class FilesInput {
  57080. /**
  57081. * List of files ready to be loaded
  57082. */
  57083. static readonly FilesToLoad: {
  57084. [key: string]: File;
  57085. };
  57086. /**
  57087. * Callback called when a file is processed
  57088. */
  57089. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57090. private _engine;
  57091. private _currentScene;
  57092. private _sceneLoadedCallback;
  57093. private _progressCallback;
  57094. private _additionalRenderLoopLogicCallback;
  57095. private _textureLoadingCallback;
  57096. private _startingProcessingFilesCallback;
  57097. private _onReloadCallback;
  57098. private _errorCallback;
  57099. private _elementToMonitor;
  57100. private _sceneFileToLoad;
  57101. private _filesToLoad;
  57102. /**
  57103. * Creates a new FilesInput
  57104. * @param engine defines the rendering engine
  57105. * @param scene defines the hosting scene
  57106. * @param sceneLoadedCallback callback called when scene is loaded
  57107. * @param progressCallback callback called to track progress
  57108. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57109. * @param textureLoadingCallback callback called when a texture is loading
  57110. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57111. * @param onReloadCallback callback called when a reload is requested
  57112. * @param errorCallback callback call if an error occurs
  57113. */
  57114. 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);
  57115. private _dragEnterHandler;
  57116. private _dragOverHandler;
  57117. private _dropHandler;
  57118. /**
  57119. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57120. * @param elementToMonitor defines the DOM element to track
  57121. */
  57122. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57123. /**
  57124. * Release all associated resources
  57125. */
  57126. dispose(): void;
  57127. private renderFunction;
  57128. private drag;
  57129. private drop;
  57130. private _traverseFolder;
  57131. private _processFiles;
  57132. /**
  57133. * Load files from a drop event
  57134. * @param event defines the drop event to use as source
  57135. */
  57136. loadFiles(event: any): void;
  57137. private _processReload;
  57138. /**
  57139. * Reload the current scene from the loaded files
  57140. */
  57141. reload(): void;
  57142. }
  57143. }
  57144. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57145. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57146. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57147. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57148. }
  57149. declare module "babylonjs/Misc/sceneOptimizer" {
  57150. import { Scene, IDisposable } from "babylonjs/scene";
  57151. import { Observable } from "babylonjs/Misc/observable";
  57152. /**
  57153. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57155. */
  57156. export class SceneOptimization {
  57157. /**
  57158. * Defines the priority of this optimization (0 by default which means first in the list)
  57159. */
  57160. priority: number;
  57161. /**
  57162. * Gets a string describing the action executed by the current optimization
  57163. * @returns description string
  57164. */
  57165. getDescription(): string;
  57166. /**
  57167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57168. * @param scene defines the current scene where to apply this optimization
  57169. * @param optimizer defines the current optimizer
  57170. * @returns true if everything that can be done was applied
  57171. */
  57172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57173. /**
  57174. * Creates the SceneOptimization object
  57175. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57176. * @param desc defines the description associated with the optimization
  57177. */
  57178. constructor(
  57179. /**
  57180. * Defines the priority of this optimization (0 by default which means first in the list)
  57181. */
  57182. priority?: number);
  57183. }
  57184. /**
  57185. * Defines an optimization used to reduce the size of render target textures
  57186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57187. */
  57188. export class TextureOptimization extends SceneOptimization {
  57189. /**
  57190. * Defines the priority of this optimization (0 by default which means first in the list)
  57191. */
  57192. priority: number;
  57193. /**
  57194. * 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
  57195. */
  57196. maximumSize: number;
  57197. /**
  57198. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57199. */
  57200. step: number;
  57201. /**
  57202. * Gets a string describing the action executed by the current optimization
  57203. * @returns description string
  57204. */
  57205. getDescription(): string;
  57206. /**
  57207. * Creates the TextureOptimization object
  57208. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57209. * @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
  57210. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57211. */
  57212. constructor(
  57213. /**
  57214. * Defines the priority of this optimization (0 by default which means first in the list)
  57215. */
  57216. priority?: number,
  57217. /**
  57218. * 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
  57219. */
  57220. maximumSize?: number,
  57221. /**
  57222. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57223. */
  57224. step?: number);
  57225. /**
  57226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57227. * @param scene defines the current scene where to apply this optimization
  57228. * @param optimizer defines the current optimizer
  57229. * @returns true if everything that can be done was applied
  57230. */
  57231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57232. }
  57233. /**
  57234. * Defines an optimization used to increase or decrease the rendering resolution
  57235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57236. */
  57237. export class HardwareScalingOptimization extends SceneOptimization {
  57238. /**
  57239. * Defines the priority of this optimization (0 by default which means first in the list)
  57240. */
  57241. priority: number;
  57242. /**
  57243. * Defines the maximum scale to use (2 by default)
  57244. */
  57245. maximumScale: number;
  57246. /**
  57247. * Defines the step to use between two passes (0.5 by default)
  57248. */
  57249. step: number;
  57250. private _currentScale;
  57251. private _directionOffset;
  57252. /**
  57253. * Gets a string describing the action executed by the current optimization
  57254. * @return description string
  57255. */
  57256. getDescription(): string;
  57257. /**
  57258. * Creates the HardwareScalingOptimization object
  57259. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57260. * @param maximumScale defines the maximum scale to use (2 by default)
  57261. * @param step defines the step to use between two passes (0.5 by default)
  57262. */
  57263. constructor(
  57264. /**
  57265. * Defines the priority of this optimization (0 by default which means first in the list)
  57266. */
  57267. priority?: number,
  57268. /**
  57269. * Defines the maximum scale to use (2 by default)
  57270. */
  57271. maximumScale?: number,
  57272. /**
  57273. * Defines the step to use between two passes (0.5 by default)
  57274. */
  57275. step?: number);
  57276. /**
  57277. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57278. * @param scene defines the current scene where to apply this optimization
  57279. * @param optimizer defines the current optimizer
  57280. * @returns true if everything that can be done was applied
  57281. */
  57282. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57283. }
  57284. /**
  57285. * Defines an optimization used to remove shadows
  57286. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57287. */
  57288. export class ShadowsOptimization extends SceneOptimization {
  57289. /**
  57290. * Gets a string describing the action executed by the current optimization
  57291. * @return description string
  57292. */
  57293. getDescription(): string;
  57294. /**
  57295. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57296. * @param scene defines the current scene where to apply this optimization
  57297. * @param optimizer defines the current optimizer
  57298. * @returns true if everything that can be done was applied
  57299. */
  57300. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57301. }
  57302. /**
  57303. * Defines an optimization used to turn post-processes off
  57304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57305. */
  57306. export class PostProcessesOptimization extends SceneOptimization {
  57307. /**
  57308. * Gets a string describing the action executed by the current optimization
  57309. * @return description string
  57310. */
  57311. getDescription(): string;
  57312. /**
  57313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57314. * @param scene defines the current scene where to apply this optimization
  57315. * @param optimizer defines the current optimizer
  57316. * @returns true if everything that can be done was applied
  57317. */
  57318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57319. }
  57320. /**
  57321. * Defines an optimization used to turn lens flares off
  57322. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57323. */
  57324. export class LensFlaresOptimization extends SceneOptimization {
  57325. /**
  57326. * Gets a string describing the action executed by the current optimization
  57327. * @return description string
  57328. */
  57329. getDescription(): string;
  57330. /**
  57331. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57332. * @param scene defines the current scene where to apply this optimization
  57333. * @param optimizer defines the current optimizer
  57334. * @returns true if everything that can be done was applied
  57335. */
  57336. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57337. }
  57338. /**
  57339. * Defines an optimization based on user defined callback.
  57340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57341. */
  57342. export class CustomOptimization extends SceneOptimization {
  57343. /**
  57344. * Callback called to apply the custom optimization.
  57345. */
  57346. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57347. /**
  57348. * Callback called to get custom description
  57349. */
  57350. onGetDescription: () => string;
  57351. /**
  57352. * Gets a string describing the action executed by the current optimization
  57353. * @returns description string
  57354. */
  57355. getDescription(): string;
  57356. /**
  57357. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57358. * @param scene defines the current scene where to apply this optimization
  57359. * @param optimizer defines the current optimizer
  57360. * @returns true if everything that can be done was applied
  57361. */
  57362. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57363. }
  57364. /**
  57365. * Defines an optimization used to turn particles off
  57366. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57367. */
  57368. export class ParticlesOptimization extends SceneOptimization {
  57369. /**
  57370. * Gets a string describing the action executed by the current optimization
  57371. * @return description string
  57372. */
  57373. getDescription(): string;
  57374. /**
  57375. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57376. * @param scene defines the current scene where to apply this optimization
  57377. * @param optimizer defines the current optimizer
  57378. * @returns true if everything that can be done was applied
  57379. */
  57380. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57381. }
  57382. /**
  57383. * Defines an optimization used to turn render targets off
  57384. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57385. */
  57386. export class RenderTargetsOptimization extends SceneOptimization {
  57387. /**
  57388. * Gets a string describing the action executed by the current optimization
  57389. * @return description string
  57390. */
  57391. getDescription(): string;
  57392. /**
  57393. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57394. * @param scene defines the current scene where to apply this optimization
  57395. * @param optimizer defines the current optimizer
  57396. * @returns true if everything that can be done was applied
  57397. */
  57398. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57399. }
  57400. /**
  57401. * Defines an optimization used to merge meshes with compatible materials
  57402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57403. */
  57404. export class MergeMeshesOptimization extends SceneOptimization {
  57405. private static _UpdateSelectionTree;
  57406. /**
  57407. * Gets or sets a boolean which defines if optimization octree has to be updated
  57408. */
  57409. /**
  57410. * Gets or sets a boolean which defines if optimization octree has to be updated
  57411. */
  57412. static UpdateSelectionTree: boolean;
  57413. /**
  57414. * Gets a string describing the action executed by the current optimization
  57415. * @return description string
  57416. */
  57417. getDescription(): string;
  57418. private _canBeMerged;
  57419. /**
  57420. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57421. * @param scene defines the current scene where to apply this optimization
  57422. * @param optimizer defines the current optimizer
  57423. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  57424. * @returns true if everything that can be done was applied
  57425. */
  57426. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  57427. }
  57428. /**
  57429. * Defines a list of options used by SceneOptimizer
  57430. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57431. */
  57432. export class SceneOptimizerOptions {
  57433. /**
  57434. * Defines the target frame rate to reach (60 by default)
  57435. */
  57436. targetFrameRate: number;
  57437. /**
  57438. * Defines the interval between two checkes (2000ms by default)
  57439. */
  57440. trackerDuration: number;
  57441. /**
  57442. * Gets the list of optimizations to apply
  57443. */
  57444. optimizations: SceneOptimization[];
  57445. /**
  57446. * Creates a new list of options used by SceneOptimizer
  57447. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  57448. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  57449. */
  57450. constructor(
  57451. /**
  57452. * Defines the target frame rate to reach (60 by default)
  57453. */
  57454. targetFrameRate?: number,
  57455. /**
  57456. * Defines the interval between two checkes (2000ms by default)
  57457. */
  57458. trackerDuration?: number);
  57459. /**
  57460. * Add a new optimization
  57461. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  57462. * @returns the current SceneOptimizerOptions
  57463. */
  57464. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  57465. /**
  57466. * Add a new custom optimization
  57467. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  57468. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  57469. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57470. * @returns the current SceneOptimizerOptions
  57471. */
  57472. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  57473. /**
  57474. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  57475. * @param targetFrameRate defines the target frame rate (60 by default)
  57476. * @returns a SceneOptimizerOptions object
  57477. */
  57478. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57479. /**
  57480. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  57481. * @param targetFrameRate defines the target frame rate (60 by default)
  57482. * @returns a SceneOptimizerOptions object
  57483. */
  57484. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57485. /**
  57486. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  57487. * @param targetFrameRate defines the target frame rate (60 by default)
  57488. * @returns a SceneOptimizerOptions object
  57489. */
  57490. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57491. }
  57492. /**
  57493. * Class used to run optimizations in order to reach a target frame rate
  57494. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57495. */
  57496. export class SceneOptimizer implements IDisposable {
  57497. private _isRunning;
  57498. private _options;
  57499. private _scene;
  57500. private _currentPriorityLevel;
  57501. private _targetFrameRate;
  57502. private _trackerDuration;
  57503. private _currentFrameRate;
  57504. private _sceneDisposeObserver;
  57505. private _improvementMode;
  57506. /**
  57507. * Defines an observable called when the optimizer reaches the target frame rate
  57508. */
  57509. onSuccessObservable: Observable<SceneOptimizer>;
  57510. /**
  57511. * Defines an observable called when the optimizer enables an optimization
  57512. */
  57513. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57514. /**
  57515. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57516. */
  57517. onFailureObservable: Observable<SceneOptimizer>;
  57518. /**
  57519. * Gets a boolean indicating if the optimizer is in improvement mode
  57520. */
  57521. readonly isInImprovementMode: boolean;
  57522. /**
  57523. * Gets the current priority level (0 at start)
  57524. */
  57525. readonly currentPriorityLevel: number;
  57526. /**
  57527. * Gets the current frame rate checked by the SceneOptimizer
  57528. */
  57529. readonly currentFrameRate: number;
  57530. /**
  57531. * Gets or sets the current target frame rate (60 by default)
  57532. */
  57533. /**
  57534. * Gets or sets the current target frame rate (60 by default)
  57535. */
  57536. targetFrameRate: number;
  57537. /**
  57538. * Gets or sets the current interval between two checks (every 2000ms by default)
  57539. */
  57540. /**
  57541. * Gets or sets the current interval between two checks (every 2000ms by default)
  57542. */
  57543. trackerDuration: number;
  57544. /**
  57545. * Gets the list of active optimizations
  57546. */
  57547. readonly optimizations: SceneOptimization[];
  57548. /**
  57549. * Creates a new SceneOptimizer
  57550. * @param scene defines the scene to work on
  57551. * @param options defines the options to use with the SceneOptimizer
  57552. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57553. * @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)
  57554. */
  57555. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57556. /**
  57557. * Stops the current optimizer
  57558. */
  57559. stop(): void;
  57560. /**
  57561. * Reset the optimizer to initial step (current priority level = 0)
  57562. */
  57563. reset(): void;
  57564. /**
  57565. * Start the optimizer. By default it will try to reach a specific framerate
  57566. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57567. */
  57568. start(): void;
  57569. private _checkCurrentState;
  57570. /**
  57571. * Release all resources
  57572. */
  57573. dispose(): void;
  57574. /**
  57575. * Helper function to create a SceneOptimizer with one single line of code
  57576. * @param scene defines the scene to work on
  57577. * @param options defines the options to use with the SceneOptimizer
  57578. * @param onSuccess defines a callback to call on success
  57579. * @param onFailure defines a callback to call on failure
  57580. * @returns the new SceneOptimizer object
  57581. */
  57582. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57583. }
  57584. }
  57585. declare module "babylonjs/Misc/sceneSerializer" {
  57586. import { Scene } from "babylonjs/scene";
  57587. /**
  57588. * Class used to serialize a scene into a string
  57589. */
  57590. export class SceneSerializer {
  57591. /**
  57592. * Clear cache used by a previous serialization
  57593. */
  57594. static ClearCache(): void;
  57595. /**
  57596. * Serialize a scene into a JSON compatible object
  57597. * @param scene defines the scene to serialize
  57598. * @returns a JSON compatible object
  57599. */
  57600. static Serialize(scene: Scene): any;
  57601. /**
  57602. * Serialize a mesh into a JSON compatible object
  57603. * @param toSerialize defines the mesh to serialize
  57604. * @param withParents defines if parents must be serialized as well
  57605. * @param withChildren defines if children must be serialized as well
  57606. * @returns a JSON compatible object
  57607. */
  57608. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57609. }
  57610. }
  57611. declare module "babylonjs/Misc/videoRecorder" {
  57612. import { Nullable } from "babylonjs/types";
  57613. import { Engine } from "babylonjs/Engines/engine";
  57614. /**
  57615. * This represents the different options avilable for the video capture.
  57616. */
  57617. export interface VideoRecorderOptions {
  57618. /** Defines the mime type of the video */
  57619. mimeType: string;
  57620. /** Defines the video the video should be recorded at */
  57621. fps: number;
  57622. /** Defines the chunk size for the recording data */
  57623. recordChunckSize: number;
  57624. /** The audio tracks to attach to the record */
  57625. audioTracks?: MediaStreamTrack[];
  57626. }
  57627. /**
  57628. * This can helps recording videos from BabylonJS.
  57629. * This is based on the available WebRTC functionalities of the browser.
  57630. *
  57631. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57632. */
  57633. export class VideoRecorder {
  57634. private static readonly _defaultOptions;
  57635. /**
  57636. * Returns wehther or not the VideoRecorder is available in your browser.
  57637. * @param engine Defines the Babylon Engine to check the support for
  57638. * @returns true if supported otherwise false
  57639. */
  57640. static IsSupported(engine: Engine): boolean;
  57641. private readonly _options;
  57642. private _canvas;
  57643. private _mediaRecorder;
  57644. private _recordedChunks;
  57645. private _fileName;
  57646. private _resolve;
  57647. private _reject;
  57648. /**
  57649. * True wether a recording is already in progress.
  57650. */
  57651. readonly isRecording: boolean;
  57652. /**
  57653. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57654. * a video file.
  57655. * @param engine Defines the BabylonJS Engine you wish to record
  57656. * @param options Defines options that can be used to customized the capture
  57657. */
  57658. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57659. /**
  57660. * Stops the current recording before the default capture timeout passed in the startRecording
  57661. * functions.
  57662. */
  57663. stopRecording(): void;
  57664. /**
  57665. * Starts recording the canvas for a max duration specified in parameters.
  57666. * @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.
  57667. * @param maxDuration Defines the maximum recording time in seconds.
  57668. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57669. * @return a promise callback at the end of the recording with the video data in Blob.
  57670. */
  57671. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57672. /**
  57673. * Releases internal resources used during the recording.
  57674. */
  57675. dispose(): void;
  57676. private _handleDataAvailable;
  57677. private _handleError;
  57678. private _handleStop;
  57679. }
  57680. }
  57681. declare module "babylonjs/Misc/workerPool" {
  57682. import { IDisposable } from "babylonjs/scene";
  57683. /**
  57684. * Helper class to push actions to a pool of workers.
  57685. */
  57686. export class WorkerPool implements IDisposable {
  57687. private _workerInfos;
  57688. private _pendingActions;
  57689. /**
  57690. * Constructor
  57691. * @param workers Array of workers to use for actions
  57692. */
  57693. constructor(workers: Array<Worker>);
  57694. /**
  57695. * Terminates all workers and clears any pending actions.
  57696. */
  57697. dispose(): void;
  57698. /**
  57699. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57700. * pended until a worker has completed its action.
  57701. * @param action The action to perform. Call onComplete when the action is complete.
  57702. */
  57703. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57704. private _execute;
  57705. }
  57706. }
  57707. declare module "babylonjs/Misc/screenshotTools" {
  57708. import { Camera } from "babylonjs/Cameras/camera";
  57709. import { Engine } from "babylonjs/Engines/engine";
  57710. /**
  57711. * Class containing a set of static utilities functions for screenshots
  57712. */
  57713. export class ScreenshotTools {
  57714. /**
  57715. * Captures a screenshot of the current rendering
  57716. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57717. * @param engine defines the rendering engine
  57718. * @param camera defines the source camera
  57719. * @param size This parameter can be set to a single number or to an object with the
  57720. * following (optional) properties: precision, width, height. If a single number is passed,
  57721. * it will be used for both width and height. If an object is passed, the screenshot size
  57722. * will be derived from the parameters. The precision property is a multiplier allowing
  57723. * rendering at a higher or lower resolution
  57724. * @param successCallback defines the callback receives a single parameter which contains the
  57725. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57726. * src parameter of an <img> to display it
  57727. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57728. * Check your browser for supported MIME types
  57729. */
  57730. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57731. /**
  57732. * Generates an image screenshot from the specified camera.
  57733. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57734. * @param engine The engine to use for rendering
  57735. * @param camera The camera to use for rendering
  57736. * @param size This parameter can be set to a single number or to an object with the
  57737. * following (optional) properties: precision, width, height. If a single number is passed,
  57738. * it will be used for both width and height. If an object is passed, the screenshot size
  57739. * will be derived from the parameters. The precision property is a multiplier allowing
  57740. * rendering at a higher or lower resolution
  57741. * @param successCallback The callback receives a single parameter which contains the
  57742. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57743. * src parameter of an <img> to display it
  57744. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57745. * Check your browser for supported MIME types
  57746. * @param samples Texture samples (default: 1)
  57747. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57748. * @param fileName A name for for the downloaded file.
  57749. */
  57750. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57751. }
  57752. }
  57753. declare module "babylonjs/Misc/index" {
  57754. export * from "babylonjs/Misc/andOrNotEvaluator";
  57755. export * from "babylonjs/Misc/assetsManager";
  57756. export * from "babylonjs/Misc/dds";
  57757. export * from "babylonjs/Misc/decorators";
  57758. export * from "babylonjs/Misc/deferred";
  57759. export * from "babylonjs/Misc/environmentTextureTools";
  57760. export * from "babylonjs/Misc/meshExploder";
  57761. export * from "babylonjs/Misc/filesInput";
  57762. export * from "babylonjs/Misc/HighDynamicRange/index";
  57763. export * from "babylonjs/Misc/khronosTextureContainer";
  57764. export * from "babylonjs/Misc/observable";
  57765. export * from "babylonjs/Misc/performanceMonitor";
  57766. export * from "babylonjs/Misc/promise";
  57767. export * from "babylonjs/Misc/sceneOptimizer";
  57768. export * from "babylonjs/Misc/sceneSerializer";
  57769. export * from "babylonjs/Misc/smartArray";
  57770. export * from "babylonjs/Misc/stringDictionary";
  57771. export * from "babylonjs/Misc/tags";
  57772. export * from "babylonjs/Misc/textureTools";
  57773. export * from "babylonjs/Misc/tga";
  57774. export * from "babylonjs/Misc/tools";
  57775. export * from "babylonjs/Misc/videoRecorder";
  57776. export * from "babylonjs/Misc/virtualJoystick";
  57777. export * from "babylonjs/Misc/workerPool";
  57778. export * from "babylonjs/Misc/logger";
  57779. export * from "babylonjs/Misc/typeStore";
  57780. export * from "babylonjs/Misc/filesInputStore";
  57781. export * from "babylonjs/Misc/deepCopier";
  57782. export * from "babylonjs/Misc/pivotTools";
  57783. export * from "babylonjs/Misc/precisionDate";
  57784. export * from "babylonjs/Misc/screenshotTools";
  57785. export * from "babylonjs/Misc/typeStore";
  57786. export * from "babylonjs/Misc/webRequest";
  57787. export * from "babylonjs/Misc/iInspectable";
  57788. }
  57789. declare module "babylonjs/index" {
  57790. export * from "babylonjs/abstractScene";
  57791. export * from "babylonjs/Actions/index";
  57792. export * from "babylonjs/Animations/index";
  57793. export * from "babylonjs/assetContainer";
  57794. export * from "babylonjs/Audio/index";
  57795. export * from "babylonjs/Behaviors/index";
  57796. export * from "babylonjs/Bones/index";
  57797. export * from "babylonjs/Cameras/index";
  57798. export * from "babylonjs/Collisions/index";
  57799. export * from "babylonjs/Culling/index";
  57800. export * from "babylonjs/Debug/index";
  57801. export * from "babylonjs/Engines/index";
  57802. export * from "babylonjs/Events/index";
  57803. export * from "babylonjs/Gamepads/index";
  57804. export * from "babylonjs/Gizmos/index";
  57805. export * from "babylonjs/Helpers/index";
  57806. export * from "babylonjs/Instrumentation/index";
  57807. export * from "babylonjs/Layers/index";
  57808. export * from "babylonjs/LensFlares/index";
  57809. export * from "babylonjs/Lights/index";
  57810. export * from "babylonjs/Loading/index";
  57811. export * from "babylonjs/Materials/index";
  57812. export * from "babylonjs/Maths/index";
  57813. export * from "babylonjs/Meshes/index";
  57814. export * from "babylonjs/Morph/index";
  57815. export * from "babylonjs/node";
  57816. export * from "babylonjs/Offline/index";
  57817. export * from "babylonjs/Particles/index";
  57818. export * from "babylonjs/Physics/index";
  57819. export * from "babylonjs/PostProcesses/index";
  57820. export * from "babylonjs/Probes/index";
  57821. export * from "babylonjs/Rendering/index";
  57822. export * from "babylonjs/scene";
  57823. export * from "babylonjs/sceneComponent";
  57824. export * from "babylonjs/Sprites/index";
  57825. export * from "babylonjs/States/index";
  57826. export * from "babylonjs/Misc/index";
  57827. export * from "babylonjs/types";
  57828. }
  57829. declare module "babylonjs/Animations/pathCursor" {
  57830. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57831. /**
  57832. * A cursor which tracks a point on a path
  57833. */
  57834. export class PathCursor {
  57835. private path;
  57836. /**
  57837. * Stores path cursor callbacks for when an onchange event is triggered
  57838. */
  57839. private _onchange;
  57840. /**
  57841. * The value of the path cursor
  57842. */
  57843. value: number;
  57844. /**
  57845. * The animation array of the path cursor
  57846. */
  57847. animations: Animation[];
  57848. /**
  57849. * Initializes the path cursor
  57850. * @param path The path to track
  57851. */
  57852. constructor(path: Path2);
  57853. /**
  57854. * Gets the cursor point on the path
  57855. * @returns A point on the path cursor at the cursor location
  57856. */
  57857. getPoint(): Vector3;
  57858. /**
  57859. * Moves the cursor ahead by the step amount
  57860. * @param step The amount to move the cursor forward
  57861. * @returns This path cursor
  57862. */
  57863. moveAhead(step?: number): PathCursor;
  57864. /**
  57865. * Moves the cursor behind by the step amount
  57866. * @param step The amount to move the cursor back
  57867. * @returns This path cursor
  57868. */
  57869. moveBack(step?: number): PathCursor;
  57870. /**
  57871. * Moves the cursor by the step amount
  57872. * If the step amount is greater than one, an exception is thrown
  57873. * @param step The amount to move the cursor
  57874. * @returns This path cursor
  57875. */
  57876. move(step: number): PathCursor;
  57877. /**
  57878. * Ensures that the value is limited between zero and one
  57879. * @returns This path cursor
  57880. */
  57881. private ensureLimits;
  57882. /**
  57883. * Runs onchange callbacks on change (used by the animation engine)
  57884. * @returns This path cursor
  57885. */
  57886. private raiseOnChange;
  57887. /**
  57888. * Executes a function on change
  57889. * @param f A path cursor onchange callback
  57890. * @returns This path cursor
  57891. */
  57892. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57893. }
  57894. }
  57895. declare module "babylonjs/Legacy/legacy" {
  57896. import * as Babylon from "babylonjs/index";
  57897. export * from "babylonjs/index";
  57898. }
  57899. declare module "babylonjs/Shaders/blur.fragment" {
  57900. /** @hidden */
  57901. export var blurPixelShader: {
  57902. name: string;
  57903. shader: string;
  57904. };
  57905. }
  57906. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57907. /** @hidden */
  57908. export var bones300Declaration: {
  57909. name: string;
  57910. shader: string;
  57911. };
  57912. }
  57913. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57914. /** @hidden */
  57915. export var instances300Declaration: {
  57916. name: string;
  57917. shader: string;
  57918. };
  57919. }
  57920. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57921. /** @hidden */
  57922. export var pointCloudVertexDeclaration: {
  57923. name: string;
  57924. shader: string;
  57925. };
  57926. }
  57927. // Mixins
  57928. interface Window {
  57929. mozIndexedDB: IDBFactory;
  57930. webkitIndexedDB: IDBFactory;
  57931. msIndexedDB: IDBFactory;
  57932. webkitURL: typeof URL;
  57933. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57934. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57935. WebGLRenderingContext: WebGLRenderingContext;
  57936. MSGesture: MSGesture;
  57937. CANNON: any;
  57938. AudioContext: AudioContext;
  57939. webkitAudioContext: AudioContext;
  57940. PointerEvent: any;
  57941. Math: Math;
  57942. Uint8Array: Uint8ArrayConstructor;
  57943. Float32Array: Float32ArrayConstructor;
  57944. mozURL: typeof URL;
  57945. msURL: typeof URL;
  57946. VRFrameData: any; // WebVR, from specs 1.1
  57947. DracoDecoderModule: any;
  57948. setImmediate(handler: (...args: any[]) => void): number;
  57949. }
  57950. interface HTMLCanvasElement {
  57951. requestPointerLock(): void;
  57952. msRequestPointerLock?(): void;
  57953. mozRequestPointerLock?(): void;
  57954. webkitRequestPointerLock?(): void;
  57955. /** Track wether a record is in progress */
  57956. isRecording: boolean;
  57957. /** Capture Stream method defined by some browsers */
  57958. captureStream(fps?: number): MediaStream;
  57959. }
  57960. interface CanvasRenderingContext2D {
  57961. msImageSmoothingEnabled: boolean;
  57962. }
  57963. interface MouseEvent {
  57964. mozMovementX: number;
  57965. mozMovementY: number;
  57966. webkitMovementX: number;
  57967. webkitMovementY: number;
  57968. msMovementX: number;
  57969. msMovementY: number;
  57970. }
  57971. interface Navigator {
  57972. mozGetVRDevices: (any: any) => any;
  57973. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57974. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57975. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57976. webkitGetGamepads(): Gamepad[];
  57977. msGetGamepads(): Gamepad[];
  57978. webkitGamepads(): Gamepad[];
  57979. }
  57980. interface HTMLVideoElement {
  57981. mozSrcObject: any;
  57982. }
  57983. interface Math {
  57984. fround(x: number): number;
  57985. imul(a: number, b: number): number;
  57986. }
  57987. interface WebGLProgram {
  57988. context?: WebGLRenderingContext;
  57989. vertexShader?: WebGLShader;
  57990. fragmentShader?: WebGLShader;
  57991. isParallelCompiled: boolean;
  57992. onCompiled?: () => void;
  57993. }
  57994. interface WebGLRenderingContext {
  57995. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57996. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57997. vertexAttribDivisor(index: number, divisor: number): void;
  57998. createVertexArray(): any;
  57999. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58000. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58001. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58002. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58003. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58004. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58005. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58006. // Queries
  58007. createQuery(): WebGLQuery;
  58008. deleteQuery(query: WebGLQuery): void;
  58009. beginQuery(target: number, query: WebGLQuery): void;
  58010. endQuery(target: number): void;
  58011. getQueryParameter(query: WebGLQuery, pname: number): any;
  58012. getQuery(target: number, pname: number): any;
  58013. MAX_SAMPLES: number;
  58014. RGBA8: number;
  58015. READ_FRAMEBUFFER: number;
  58016. DRAW_FRAMEBUFFER: number;
  58017. UNIFORM_BUFFER: number;
  58018. HALF_FLOAT_OES: number;
  58019. RGBA16F: number;
  58020. RGBA32F: number;
  58021. R32F: number;
  58022. RG32F: number;
  58023. RGB32F: number;
  58024. R16F: number;
  58025. RG16F: number;
  58026. RGB16F: number;
  58027. RED: number;
  58028. RG: number;
  58029. R8: number;
  58030. RG8: number;
  58031. UNSIGNED_INT_24_8: number;
  58032. DEPTH24_STENCIL8: number;
  58033. /* Multiple Render Targets */
  58034. drawBuffers(buffers: number[]): void;
  58035. readBuffer(src: number): void;
  58036. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58037. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58038. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58039. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58040. // Occlusion Query
  58041. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58042. ANY_SAMPLES_PASSED: number;
  58043. QUERY_RESULT_AVAILABLE: number;
  58044. QUERY_RESULT: number;
  58045. }
  58046. interface WebGLBuffer {
  58047. references: number;
  58048. capacity: number;
  58049. is32Bits: boolean;
  58050. }
  58051. interface WebGLProgram {
  58052. transformFeedback?: WebGLTransformFeedback | null;
  58053. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58054. }
  58055. interface EXT_disjoint_timer_query {
  58056. QUERY_COUNTER_BITS_EXT: number;
  58057. TIME_ELAPSED_EXT: number;
  58058. TIMESTAMP_EXT: number;
  58059. GPU_DISJOINT_EXT: number;
  58060. QUERY_RESULT_EXT: number;
  58061. QUERY_RESULT_AVAILABLE_EXT: number;
  58062. queryCounterEXT(query: WebGLQuery, target: number): void;
  58063. createQueryEXT(): WebGLQuery;
  58064. beginQueryEXT(target: number, query: WebGLQuery): void;
  58065. endQueryEXT(target: number): void;
  58066. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58067. deleteQueryEXT(query: WebGLQuery): void;
  58068. }
  58069. interface WebGLUniformLocation {
  58070. _currentState: any;
  58071. }
  58072. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58073. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58074. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58075. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58076. interface WebGLRenderingContext {
  58077. readonly RASTERIZER_DISCARD: number;
  58078. readonly DEPTH_COMPONENT24: number;
  58079. readonly TEXTURE_3D: number;
  58080. readonly TEXTURE_2D_ARRAY: number;
  58081. readonly TEXTURE_COMPARE_FUNC: number;
  58082. readonly TEXTURE_COMPARE_MODE: number;
  58083. readonly COMPARE_REF_TO_TEXTURE: number;
  58084. readonly TEXTURE_WRAP_R: number;
  58085. readonly HALF_FLOAT: number;
  58086. readonly RGB8: number;
  58087. readonly RED_INTEGER: number;
  58088. readonly RG_INTEGER: number;
  58089. readonly RGB_INTEGER: number;
  58090. readonly RGBA_INTEGER: number;
  58091. readonly R8_SNORM: number;
  58092. readonly RG8_SNORM: number;
  58093. readonly RGB8_SNORM: number;
  58094. readonly RGBA8_SNORM: number;
  58095. readonly R8I: number;
  58096. readonly RG8I: number;
  58097. readonly RGB8I: number;
  58098. readonly RGBA8I: number;
  58099. readonly R8UI: number;
  58100. readonly RG8UI: number;
  58101. readonly RGB8UI: number;
  58102. readonly RGBA8UI: number;
  58103. readonly R16I: number;
  58104. readonly RG16I: number;
  58105. readonly RGB16I: number;
  58106. readonly RGBA16I: number;
  58107. readonly R16UI: number;
  58108. readonly RG16UI: number;
  58109. readonly RGB16UI: number;
  58110. readonly RGBA16UI: number;
  58111. readonly R32I: number;
  58112. readonly RG32I: number;
  58113. readonly RGB32I: number;
  58114. readonly RGBA32I: number;
  58115. readonly R32UI: number;
  58116. readonly RG32UI: number;
  58117. readonly RGB32UI: number;
  58118. readonly RGBA32UI: number;
  58119. readonly RGB10_A2UI: number;
  58120. readonly R11F_G11F_B10F: number;
  58121. readonly RGB9_E5: number;
  58122. readonly RGB10_A2: number;
  58123. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58124. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58125. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58126. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58127. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58128. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58129. 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;
  58130. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58131. readonly TRANSFORM_FEEDBACK: number;
  58132. readonly INTERLEAVED_ATTRIBS: number;
  58133. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58134. createTransformFeedback(): WebGLTransformFeedback;
  58135. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58136. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58137. beginTransformFeedback(primitiveMode: number): void;
  58138. endTransformFeedback(): void;
  58139. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58140. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58141. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58142. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58143. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58144. }
  58145. interface ImageBitmap {
  58146. readonly width: number;
  58147. readonly height: number;
  58148. close(): void;
  58149. }
  58150. interface WebGLQuery extends WebGLObject {
  58151. }
  58152. declare var WebGLQuery: {
  58153. prototype: WebGLQuery;
  58154. new(): WebGLQuery;
  58155. };
  58156. interface WebGLSampler extends WebGLObject {
  58157. }
  58158. declare var WebGLSampler: {
  58159. prototype: WebGLSampler;
  58160. new(): WebGLSampler;
  58161. };
  58162. interface WebGLSync extends WebGLObject {
  58163. }
  58164. declare var WebGLSync: {
  58165. prototype: WebGLSync;
  58166. new(): WebGLSync;
  58167. };
  58168. interface WebGLTransformFeedback extends WebGLObject {
  58169. }
  58170. declare var WebGLTransformFeedback: {
  58171. prototype: WebGLTransformFeedback;
  58172. new(): WebGLTransformFeedback;
  58173. };
  58174. interface WebGLVertexArrayObject extends WebGLObject {
  58175. }
  58176. declare var WebGLVertexArrayObject: {
  58177. prototype: WebGLVertexArrayObject;
  58178. new(): WebGLVertexArrayObject;
  58179. };
  58180. // Type definitions for WebVR API
  58181. // Project: https://w3c.github.io/webvr/
  58182. // Definitions by: six a <https://github.com/lostfictions>
  58183. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58184. interface VRDisplay extends EventTarget {
  58185. /**
  58186. * Dictionary of capabilities describing the VRDisplay.
  58187. */
  58188. readonly capabilities: VRDisplayCapabilities;
  58189. /**
  58190. * z-depth defining the far plane of the eye view frustum
  58191. * enables mapping of values in the render target depth
  58192. * attachment to scene coordinates. Initially set to 10000.0.
  58193. */
  58194. depthFar: number;
  58195. /**
  58196. * z-depth defining the near plane of the eye view frustum
  58197. * enables mapping of values in the render target depth
  58198. * attachment to scene coordinates. Initially set to 0.01.
  58199. */
  58200. depthNear: number;
  58201. /**
  58202. * An identifier for this distinct VRDisplay. Used as an
  58203. * association point in the Gamepad API.
  58204. */
  58205. readonly displayId: number;
  58206. /**
  58207. * A display name, a user-readable name identifying it.
  58208. */
  58209. readonly displayName: string;
  58210. readonly isConnected: boolean;
  58211. readonly isPresenting: boolean;
  58212. /**
  58213. * If this VRDisplay supports room-scale experiences, the optional
  58214. * stage attribute contains details on the room-scale parameters.
  58215. */
  58216. readonly stageParameters: VRStageParameters | null;
  58217. /**
  58218. * Passing the value returned by `requestAnimationFrame` to
  58219. * `cancelAnimationFrame` will unregister the callback.
  58220. * @param handle Define the hanle of the request to cancel
  58221. */
  58222. cancelAnimationFrame(handle: number): void;
  58223. /**
  58224. * Stops presenting to the VRDisplay.
  58225. * @returns a promise to know when it stopped
  58226. */
  58227. exitPresent(): Promise<void>;
  58228. /**
  58229. * Return the current VREyeParameters for the given eye.
  58230. * @param whichEye Define the eye we want the parameter for
  58231. * @returns the eye parameters
  58232. */
  58233. getEyeParameters(whichEye: string): VREyeParameters;
  58234. /**
  58235. * Populates the passed VRFrameData with the information required to render
  58236. * the current frame.
  58237. * @param frameData Define the data structure to populate
  58238. * @returns true if ok otherwise false
  58239. */
  58240. getFrameData(frameData: VRFrameData): boolean;
  58241. /**
  58242. * Get the layers currently being presented.
  58243. * @returns the list of VR layers
  58244. */
  58245. getLayers(): VRLayer[];
  58246. /**
  58247. * Return a VRPose containing the future predicted pose of the VRDisplay
  58248. * when the current frame will be presented. The value returned will not
  58249. * change until JavaScript has returned control to the browser.
  58250. *
  58251. * The VRPose will contain the position, orientation, velocity,
  58252. * and acceleration of each of these properties.
  58253. * @returns the pose object
  58254. */
  58255. getPose(): VRPose;
  58256. /**
  58257. * Return the current instantaneous pose of the VRDisplay, with no
  58258. * prediction applied.
  58259. * @returns the current instantaneous pose
  58260. */
  58261. getImmediatePose(): VRPose;
  58262. /**
  58263. * The callback passed to `requestAnimationFrame` will be called
  58264. * any time a new frame should be rendered. When the VRDisplay is
  58265. * presenting the callback will be called at the native refresh
  58266. * rate of the HMD. When not presenting this function acts
  58267. * identically to how window.requestAnimationFrame acts. Content should
  58268. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58269. * asynchronously from other displays and at differing refresh rates.
  58270. * @param callback Define the eaction to run next frame
  58271. * @returns the request handle it
  58272. */
  58273. requestAnimationFrame(callback: FrameRequestCallback): number;
  58274. /**
  58275. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58276. * Repeat calls while already presenting will update the VRLayers being displayed.
  58277. * @param layers Define the list of layer to present
  58278. * @returns a promise to know when the request has been fulfilled
  58279. */
  58280. requestPresent(layers: VRLayer[]): Promise<void>;
  58281. /**
  58282. * Reset the pose for this display, treating its current position and
  58283. * orientation as the "origin/zero" values. VRPose.position,
  58284. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58285. * updated when calling resetPose(). This should be called in only
  58286. * sitting-space experiences.
  58287. */
  58288. resetPose(): void;
  58289. /**
  58290. * The VRLayer provided to the VRDisplay will be captured and presented
  58291. * in the HMD. Calling this function has the same effect on the source
  58292. * canvas as any other operation that uses its source image, and canvases
  58293. * created without preserveDrawingBuffer set to true will be cleared.
  58294. * @param pose Define the pose to submit
  58295. */
  58296. submitFrame(pose?: VRPose): void;
  58297. }
  58298. declare var VRDisplay: {
  58299. prototype: VRDisplay;
  58300. new(): VRDisplay;
  58301. };
  58302. interface VRLayer {
  58303. leftBounds?: number[] | Float32Array | null;
  58304. rightBounds?: number[] | Float32Array | null;
  58305. source?: HTMLCanvasElement | null;
  58306. }
  58307. interface VRDisplayCapabilities {
  58308. readonly canPresent: boolean;
  58309. readonly hasExternalDisplay: boolean;
  58310. readonly hasOrientation: boolean;
  58311. readonly hasPosition: boolean;
  58312. readonly maxLayers: number;
  58313. }
  58314. interface VREyeParameters {
  58315. /** @deprecated */
  58316. readonly fieldOfView: VRFieldOfView;
  58317. readonly offset: Float32Array;
  58318. readonly renderHeight: number;
  58319. readonly renderWidth: number;
  58320. }
  58321. interface VRFieldOfView {
  58322. readonly downDegrees: number;
  58323. readonly leftDegrees: number;
  58324. readonly rightDegrees: number;
  58325. readonly upDegrees: number;
  58326. }
  58327. interface VRFrameData {
  58328. readonly leftProjectionMatrix: Float32Array;
  58329. readonly leftViewMatrix: Float32Array;
  58330. readonly pose: VRPose;
  58331. readonly rightProjectionMatrix: Float32Array;
  58332. readonly rightViewMatrix: Float32Array;
  58333. readonly timestamp: number;
  58334. }
  58335. interface VRPose {
  58336. readonly angularAcceleration: Float32Array | null;
  58337. readonly angularVelocity: Float32Array | null;
  58338. readonly linearAcceleration: Float32Array | null;
  58339. readonly linearVelocity: Float32Array | null;
  58340. readonly orientation: Float32Array | null;
  58341. readonly position: Float32Array | null;
  58342. readonly timestamp: number;
  58343. }
  58344. interface VRStageParameters {
  58345. sittingToStandingTransform?: Float32Array;
  58346. sizeX?: number;
  58347. sizeY?: number;
  58348. }
  58349. interface Navigator {
  58350. getVRDisplays(): Promise<VRDisplay[]>;
  58351. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58352. }
  58353. interface Window {
  58354. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58355. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58356. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58357. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58358. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58359. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58360. }
  58361. interface Gamepad {
  58362. readonly displayId: number;
  58363. }
  58364. interface XRDevice {
  58365. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58366. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58367. }
  58368. interface XRSession {
  58369. getInputSources(): Array<any>;
  58370. baseLayer: XRWebGLLayer;
  58371. requestFrameOfReference(type: string): Promise<void>;
  58372. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58373. end(): Promise<void>;
  58374. requestAnimationFrame: Function;
  58375. addEventListener: Function;
  58376. }
  58377. interface XRSessionCreationOptions {
  58378. outputContext?: WebGLRenderingContext | null;
  58379. immersive?: boolean;
  58380. environmentIntegration?: boolean;
  58381. }
  58382. interface XRLayer {
  58383. getViewport: Function;
  58384. framebufferWidth: number;
  58385. framebufferHeight: number;
  58386. }
  58387. interface XRView {
  58388. projectionMatrix: Float32Array;
  58389. }
  58390. interface XRFrame {
  58391. getDevicePose: Function;
  58392. getInputPose: Function;
  58393. views: Array<XRView>;
  58394. baseLayer: XRLayer;
  58395. }
  58396. interface XRFrameOfReference {
  58397. }
  58398. interface XRWebGLLayer extends XRLayer {
  58399. framebuffer: WebGLFramebuffer;
  58400. }
  58401. declare var XRWebGLLayer: {
  58402. prototype: XRWebGLLayer;
  58403. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58404. };
  58405. declare module "babylonjs" {
  58406. export * from "babylonjs/Legacy/legacy";
  58407. }
  58408. declare module BABYLON {
  58409. /** Alias type for value that can be null */
  58410. export type Nullable<T> = T | null;
  58411. /**
  58412. * Alias type for number that are floats
  58413. * @ignorenaming
  58414. */
  58415. export type float = number;
  58416. /**
  58417. * Alias type for number that are doubles.
  58418. * @ignorenaming
  58419. */
  58420. export type double = number;
  58421. /**
  58422. * Alias type for number that are integer
  58423. * @ignorenaming
  58424. */
  58425. export type int = number;
  58426. /** Alias type for number array or Float32Array */
  58427. export type FloatArray = number[] | Float32Array;
  58428. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  58429. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  58430. /**
  58431. * Alias for types that can be used by a Buffer or VertexBuffer.
  58432. */
  58433. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  58434. /**
  58435. * Alias type for primitive types
  58436. * @ignorenaming
  58437. */
  58438. type Primitive = undefined | null | boolean | string | number | Function;
  58439. /**
  58440. * Type modifier to make all the properties of an object Readonly
  58441. */
  58442. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  58443. /**
  58444. * Type modifier to make all the properties of an object Readonly recursively
  58445. */
  58446. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  58447. /** @hidden */
  58448. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  58449. }
  58450. /** @hidden */
  58451. /** @hidden */
  58452. type DeepImmutableObject<T> = {
  58453. readonly [K in keyof T]: DeepImmutable<T[K]>;
  58454. };
  58455. }
  58456. declare module BABYLON {
  58457. /**
  58458. * Class containing a set of static utilities functions for arrays.
  58459. */
  58460. export class ArrayTools {
  58461. /**
  58462. * Returns an array of the given size filled with element built from the given constructor and the paramters
  58463. * @param size the number of element to construct and put in the array
  58464. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58465. * @returns a new array filled with new objects
  58466. */
  58467. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  58468. }
  58469. }
  58470. declare module BABYLON {
  58471. /**
  58472. * Scalar computation library
  58473. */
  58474. export class Scalar {
  58475. /**
  58476. * Two pi constants convenient for computation.
  58477. */
  58478. static TwoPi: number;
  58479. /**
  58480. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58481. * @param a number
  58482. * @param b number
  58483. * @param epsilon (default = 1.401298E-45)
  58484. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58485. */
  58486. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  58487. /**
  58488. * Returns a string : the upper case translation of the number i to hexadecimal.
  58489. * @param i number
  58490. * @returns the upper case translation of the number i to hexadecimal.
  58491. */
  58492. static ToHex(i: number): string;
  58493. /**
  58494. * Returns -1 if value is negative and +1 is value is positive.
  58495. * @param value the value
  58496. * @returns the value itself if it's equal to zero.
  58497. */
  58498. static Sign(value: number): number;
  58499. /**
  58500. * Returns the value itself if it's between min and max.
  58501. * Returns min if the value is lower than min.
  58502. * Returns max if the value is greater than max.
  58503. * @param value the value to clmap
  58504. * @param min the min value to clamp to (default: 0)
  58505. * @param max the max value to clamp to (default: 1)
  58506. * @returns the clamped value
  58507. */
  58508. static Clamp(value: number, min?: number, max?: number): number;
  58509. /**
  58510. * the log2 of value.
  58511. * @param value the value to compute log2 of
  58512. * @returns the log2 of value.
  58513. */
  58514. static Log2(value: number): number;
  58515. /**
  58516. * Loops the value, so that it is never larger than length and never smaller than 0.
  58517. *
  58518. * This is similar to the modulo operator but it works with floating point numbers.
  58519. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  58520. * With t = 5 and length = 2.5, the result would be 0.0.
  58521. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  58522. * @param value the value
  58523. * @param length the length
  58524. * @returns the looped value
  58525. */
  58526. static Repeat(value: number, length: number): number;
  58527. /**
  58528. * Normalize the value between 0.0 and 1.0 using min and max values
  58529. * @param value value to normalize
  58530. * @param min max to normalize between
  58531. * @param max min to normalize between
  58532. * @returns the normalized value
  58533. */
  58534. static Normalize(value: number, min: number, max: number): number;
  58535. /**
  58536. * Denormalize the value from 0.0 and 1.0 using min and max values
  58537. * @param normalized value to denormalize
  58538. * @param min max to denormalize between
  58539. * @param max min to denormalize between
  58540. * @returns the denormalized value
  58541. */
  58542. static Denormalize(normalized: number, min: number, max: number): number;
  58543. /**
  58544. * Calculates the shortest difference between two given angles given in degrees.
  58545. * @param current current angle in degrees
  58546. * @param target target angle in degrees
  58547. * @returns the delta
  58548. */
  58549. static DeltaAngle(current: number, target: number): number;
  58550. /**
  58551. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  58552. * @param tx value
  58553. * @param length length
  58554. * @returns The returned value will move back and forth between 0 and length
  58555. */
  58556. static PingPong(tx: number, length: number): number;
  58557. /**
  58558. * Interpolates between min and max with smoothing at the limits.
  58559. *
  58560. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  58561. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  58562. * @param from from
  58563. * @param to to
  58564. * @param tx value
  58565. * @returns the smooth stepped value
  58566. */
  58567. static SmoothStep(from: number, to: number, tx: number): number;
  58568. /**
  58569. * Moves a value current towards target.
  58570. *
  58571. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  58572. * Negative values of maxDelta pushes the value away from target.
  58573. * @param current current value
  58574. * @param target target value
  58575. * @param maxDelta max distance to move
  58576. * @returns resulting value
  58577. */
  58578. static MoveTowards(current: number, target: number, maxDelta: number): number;
  58579. /**
  58580. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58581. *
  58582. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  58583. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  58584. * @param current current value
  58585. * @param target target value
  58586. * @param maxDelta max distance to move
  58587. * @returns resulting angle
  58588. */
  58589. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  58590. /**
  58591. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  58592. * @param start start value
  58593. * @param end target value
  58594. * @param amount amount to lerp between
  58595. * @returns the lerped value
  58596. */
  58597. static Lerp(start: number, end: number, amount: number): number;
  58598. /**
  58599. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58600. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  58601. * @param start start value
  58602. * @param end target value
  58603. * @param amount amount to lerp between
  58604. * @returns the lerped value
  58605. */
  58606. static LerpAngle(start: number, end: number, amount: number): number;
  58607. /**
  58608. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  58609. * @param a start value
  58610. * @param b target value
  58611. * @param value value between a and b
  58612. * @returns the inverseLerp value
  58613. */
  58614. static InverseLerp(a: number, b: number, value: number): number;
  58615. /**
  58616. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  58617. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  58618. * @param value1 spline value
  58619. * @param tangent1 spline value
  58620. * @param value2 spline value
  58621. * @param tangent2 spline value
  58622. * @param amount input value
  58623. * @returns hermite result
  58624. */
  58625. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  58626. /**
  58627. * Returns a random float number between and min and max values
  58628. * @param min min value of random
  58629. * @param max max value of random
  58630. * @returns random value
  58631. */
  58632. static RandomRange(min: number, max: number): number;
  58633. /**
  58634. * This function returns percentage of a number in a given range.
  58635. *
  58636. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58637. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58638. * @param number to convert to percentage
  58639. * @param min min range
  58640. * @param max max range
  58641. * @returns the percentage
  58642. */
  58643. static RangeToPercent(number: number, min: number, max: number): number;
  58644. /**
  58645. * This function returns number that corresponds to the percentage in a given range.
  58646. *
  58647. * PercentToRange(0.34,0,100) will return 34.
  58648. * @param percent to convert to number
  58649. * @param min min range
  58650. * @param max max range
  58651. * @returns the number
  58652. */
  58653. static PercentToRange(percent: number, min: number, max: number): number;
  58654. /**
  58655. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58656. * @param angle The angle to normalize in radian.
  58657. * @return The converted angle.
  58658. */
  58659. static NormalizeRadians(angle: number): number;
  58660. }
  58661. }
  58662. declare module BABYLON {
  58663. /**
  58664. * Constant used to convert a value to gamma space
  58665. * @ignorenaming
  58666. */
  58667. export const ToGammaSpace: number;
  58668. /**
  58669. * Constant used to convert a value to linear space
  58670. * @ignorenaming
  58671. */
  58672. export const ToLinearSpace = 2.2;
  58673. /**
  58674. * Constant used to define the minimal number value in Babylon.js
  58675. * @ignorenaming
  58676. */
  58677. export const Epsilon = 0.001;
  58678. /**
  58679. * Class used to hold a RBG color
  58680. */
  58681. export class Color3 {
  58682. /**
  58683. * Defines the red component (between 0 and 1, default is 0)
  58684. */
  58685. r: number;
  58686. /**
  58687. * Defines the green component (between 0 and 1, default is 0)
  58688. */
  58689. g: number;
  58690. /**
  58691. * Defines the blue component (between 0 and 1, default is 0)
  58692. */
  58693. b: number;
  58694. /**
  58695. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58696. * @param r defines the red component (between 0 and 1, default is 0)
  58697. * @param g defines the green component (between 0 and 1, default is 0)
  58698. * @param b defines the blue component (between 0 and 1, default is 0)
  58699. */
  58700. constructor(
  58701. /**
  58702. * Defines the red component (between 0 and 1, default is 0)
  58703. */
  58704. r?: number,
  58705. /**
  58706. * Defines the green component (between 0 and 1, default is 0)
  58707. */
  58708. g?: number,
  58709. /**
  58710. * Defines the blue component (between 0 and 1, default is 0)
  58711. */
  58712. b?: number);
  58713. /**
  58714. * Creates a string with the Color3 current values
  58715. * @returns the string representation of the Color3 object
  58716. */
  58717. toString(): string;
  58718. /**
  58719. * Returns the string "Color3"
  58720. * @returns "Color3"
  58721. */
  58722. getClassName(): string;
  58723. /**
  58724. * Compute the Color3 hash code
  58725. * @returns an unique number that can be used to hash Color3 objects
  58726. */
  58727. getHashCode(): number;
  58728. /**
  58729. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58730. * @param array defines the array where to store the r,g,b components
  58731. * @param index defines an optional index in the target array to define where to start storing values
  58732. * @returns the current Color3 object
  58733. */
  58734. toArray(array: FloatArray, index?: number): Color3;
  58735. /**
  58736. * Returns a new Color4 object from the current Color3 and the given alpha
  58737. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58738. * @returns a new Color4 object
  58739. */
  58740. toColor4(alpha?: number): Color4;
  58741. /**
  58742. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58743. * @returns the new array
  58744. */
  58745. asArray(): number[];
  58746. /**
  58747. * Returns the luminance value
  58748. * @returns a float value
  58749. */
  58750. toLuminance(): number;
  58751. /**
  58752. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58753. * @param otherColor defines the second operand
  58754. * @returns the new Color3 object
  58755. */
  58756. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58757. /**
  58758. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58759. * @param otherColor defines the second operand
  58760. * @param result defines the Color3 object where to store the result
  58761. * @returns the current Color3
  58762. */
  58763. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58764. /**
  58765. * Determines equality between Color3 objects
  58766. * @param otherColor defines the second operand
  58767. * @returns true if the rgb values are equal to the given ones
  58768. */
  58769. equals(otherColor: DeepImmutable<Color3>): boolean;
  58770. /**
  58771. * Determines equality between the current Color3 object and a set of r,b,g values
  58772. * @param r defines the red component to check
  58773. * @param g defines the green component to check
  58774. * @param b defines the blue component to check
  58775. * @returns true if the rgb values are equal to the given ones
  58776. */
  58777. equalsFloats(r: number, g: number, b: number): boolean;
  58778. /**
  58779. * Multiplies in place each rgb value by scale
  58780. * @param scale defines the scaling factor
  58781. * @returns the updated Color3
  58782. */
  58783. scale(scale: number): Color3;
  58784. /**
  58785. * Multiplies the rgb values by scale and stores the result into "result"
  58786. * @param scale defines the scaling factor
  58787. * @param result defines the Color3 object where to store the result
  58788. * @returns the unmodified current Color3
  58789. */
  58790. scaleToRef(scale: number, result: Color3): Color3;
  58791. /**
  58792. * Scale the current Color3 values by a factor and add the result to a given Color3
  58793. * @param scale defines the scale factor
  58794. * @param result defines color to store the result into
  58795. * @returns the unmodified current Color3
  58796. */
  58797. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58798. /**
  58799. * Clamps the rgb values by the min and max values and stores the result into "result"
  58800. * @param min defines minimum clamping value (default is 0)
  58801. * @param max defines maximum clamping value (default is 1)
  58802. * @param result defines color to store the result into
  58803. * @returns the original Color3
  58804. */
  58805. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58806. /**
  58807. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58808. * @param otherColor defines the second operand
  58809. * @returns the new Color3
  58810. */
  58811. add(otherColor: DeepImmutable<Color3>): Color3;
  58812. /**
  58813. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58814. * @param otherColor defines the second operand
  58815. * @param result defines Color3 object to store the result into
  58816. * @returns the unmodified current Color3
  58817. */
  58818. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58819. /**
  58820. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58821. * @param otherColor defines the second operand
  58822. * @returns the new Color3
  58823. */
  58824. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58825. /**
  58826. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58827. * @param otherColor defines the second operand
  58828. * @param result defines Color3 object to store the result into
  58829. * @returns the unmodified current Color3
  58830. */
  58831. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58832. /**
  58833. * Copy the current object
  58834. * @returns a new Color3 copied the current one
  58835. */
  58836. clone(): Color3;
  58837. /**
  58838. * Copies the rgb values from the source in the current Color3
  58839. * @param source defines the source Color3 object
  58840. * @returns the updated Color3 object
  58841. */
  58842. copyFrom(source: DeepImmutable<Color3>): Color3;
  58843. /**
  58844. * Updates the Color3 rgb values from the given floats
  58845. * @param r defines the red component to read from
  58846. * @param g defines the green component to read from
  58847. * @param b defines the blue component to read from
  58848. * @returns the current Color3 object
  58849. */
  58850. copyFromFloats(r: number, g: number, b: number): Color3;
  58851. /**
  58852. * Updates the Color3 rgb values from the given floats
  58853. * @param r defines the red component to read from
  58854. * @param g defines the green component to read from
  58855. * @param b defines the blue component to read from
  58856. * @returns the current Color3 object
  58857. */
  58858. set(r: number, g: number, b: number): Color3;
  58859. /**
  58860. * Compute the Color3 hexadecimal code as a string
  58861. * @returns a string containing the hexadecimal representation of the Color3 object
  58862. */
  58863. toHexString(): string;
  58864. /**
  58865. * Computes a new Color3 converted from the current one to linear space
  58866. * @returns a new Color3 object
  58867. */
  58868. toLinearSpace(): Color3;
  58869. /**
  58870. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58871. * @param convertedColor defines the Color3 object where to store the linear space version
  58872. * @returns the unmodified Color3
  58873. */
  58874. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58875. /**
  58876. * Computes a new Color3 converted from the current one to gamma space
  58877. * @returns a new Color3 object
  58878. */
  58879. toGammaSpace(): Color3;
  58880. /**
  58881. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58882. * @param convertedColor defines the Color3 object where to store the gamma space version
  58883. * @returns the unmodified Color3
  58884. */
  58885. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58886. private static _BlackReadOnly;
  58887. /**
  58888. * Creates a new Color3 from the string containing valid hexadecimal values
  58889. * @param hex defines a string containing valid hexadecimal values
  58890. * @returns a new Color3 object
  58891. */
  58892. static FromHexString(hex: string): Color3;
  58893. /**
  58894. * Creates a new Vector3 from the starting index of the given array
  58895. * @param array defines the source array
  58896. * @param offset defines an offset in the source array
  58897. * @returns a new Color3 object
  58898. */
  58899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58900. /**
  58901. * Creates a new Color3 from integer values (< 256)
  58902. * @param r defines the red component to read from (value between 0 and 255)
  58903. * @param g defines the green component to read from (value between 0 and 255)
  58904. * @param b defines the blue component to read from (value between 0 and 255)
  58905. * @returns a new Color3 object
  58906. */
  58907. static FromInts(r: number, g: number, b: number): Color3;
  58908. /**
  58909. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58910. * @param start defines the start Color3 value
  58911. * @param end defines the end Color3 value
  58912. * @param amount defines the gradient value between start and end
  58913. * @returns a new Color3 object
  58914. */
  58915. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58916. /**
  58917. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58918. * @param left defines the start value
  58919. * @param right defines the end value
  58920. * @param amount defines the gradient factor
  58921. * @param result defines the Color3 object where to store the result
  58922. */
  58923. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58924. /**
  58925. * Returns a Color3 value containing a red color
  58926. * @returns a new Color3 object
  58927. */
  58928. static Red(): Color3;
  58929. /**
  58930. * Returns a Color3 value containing a green color
  58931. * @returns a new Color3 object
  58932. */
  58933. static Green(): Color3;
  58934. /**
  58935. * Returns a Color3 value containing a blue color
  58936. * @returns a new Color3 object
  58937. */
  58938. static Blue(): Color3;
  58939. /**
  58940. * Returns a Color3 value containing a black color
  58941. * @returns a new Color3 object
  58942. */
  58943. static Black(): Color3;
  58944. /**
  58945. * Gets a Color3 value containing a black color that must not be updated
  58946. */
  58947. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58948. /**
  58949. * Returns a Color3 value containing a white color
  58950. * @returns a new Color3 object
  58951. */
  58952. static White(): Color3;
  58953. /**
  58954. * Returns a Color3 value containing a purple color
  58955. * @returns a new Color3 object
  58956. */
  58957. static Purple(): Color3;
  58958. /**
  58959. * Returns a Color3 value containing a magenta color
  58960. * @returns a new Color3 object
  58961. */
  58962. static Magenta(): Color3;
  58963. /**
  58964. * Returns a Color3 value containing a yellow color
  58965. * @returns a new Color3 object
  58966. */
  58967. static Yellow(): Color3;
  58968. /**
  58969. * Returns a Color3 value containing a gray color
  58970. * @returns a new Color3 object
  58971. */
  58972. static Gray(): Color3;
  58973. /**
  58974. * Returns a Color3 value containing a teal color
  58975. * @returns a new Color3 object
  58976. */
  58977. static Teal(): Color3;
  58978. /**
  58979. * Returns a Color3 value containing a random color
  58980. * @returns a new Color3 object
  58981. */
  58982. static Random(): Color3;
  58983. }
  58984. /**
  58985. * Class used to hold a RBGA color
  58986. */
  58987. export class Color4 {
  58988. /**
  58989. * Defines the red component (between 0 and 1, default is 0)
  58990. */
  58991. r: number;
  58992. /**
  58993. * Defines the green component (between 0 and 1, default is 0)
  58994. */
  58995. g: number;
  58996. /**
  58997. * Defines the blue component (between 0 and 1, default is 0)
  58998. */
  58999. b: number;
  59000. /**
  59001. * Defines the alpha component (between 0 and 1, default is 1)
  59002. */
  59003. a: number;
  59004. /**
  59005. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59006. * @param r defines the red component (between 0 and 1, default is 0)
  59007. * @param g defines the green component (between 0 and 1, default is 0)
  59008. * @param b defines the blue component (between 0 and 1, default is 0)
  59009. * @param a defines the alpha component (between 0 and 1, default is 1)
  59010. */
  59011. constructor(
  59012. /**
  59013. * Defines the red component (between 0 and 1, default is 0)
  59014. */
  59015. r?: number,
  59016. /**
  59017. * Defines the green component (between 0 and 1, default is 0)
  59018. */
  59019. g?: number,
  59020. /**
  59021. * Defines the blue component (between 0 and 1, default is 0)
  59022. */
  59023. b?: number,
  59024. /**
  59025. * Defines the alpha component (between 0 and 1, default is 1)
  59026. */
  59027. a?: number);
  59028. /**
  59029. * Adds in place the given Color4 values to the current Color4 object
  59030. * @param right defines the second operand
  59031. * @returns the current updated Color4 object
  59032. */
  59033. addInPlace(right: DeepImmutable<Color4>): Color4;
  59034. /**
  59035. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59036. * @returns the new array
  59037. */
  59038. asArray(): number[];
  59039. /**
  59040. * Stores from the starting index in the given array the Color4 successive values
  59041. * @param array defines the array where to store the r,g,b components
  59042. * @param index defines an optional index in the target array to define where to start storing values
  59043. * @returns the current Color4 object
  59044. */
  59045. toArray(array: number[], index?: number): Color4;
  59046. /**
  59047. * Determines equality between Color4 objects
  59048. * @param otherColor defines the second operand
  59049. * @returns true if the rgba values are equal to the given ones
  59050. */
  59051. equals(otherColor: DeepImmutable<Color4>): boolean;
  59052. /**
  59053. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59054. * @param right defines the second operand
  59055. * @returns a new Color4 object
  59056. */
  59057. add(right: DeepImmutable<Color4>): Color4;
  59058. /**
  59059. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59060. * @param right defines the second operand
  59061. * @returns a new Color4 object
  59062. */
  59063. subtract(right: DeepImmutable<Color4>): Color4;
  59064. /**
  59065. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59066. * @param right defines the second operand
  59067. * @param result defines the Color4 object where to store the result
  59068. * @returns the current Color4 object
  59069. */
  59070. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59071. /**
  59072. * Creates a new Color4 with the current Color4 values multiplied by scale
  59073. * @param scale defines the scaling factor to apply
  59074. * @returns a new Color4 object
  59075. */
  59076. scale(scale: number): Color4;
  59077. /**
  59078. * Multiplies the current Color4 values by scale and stores the result in "result"
  59079. * @param scale defines the scaling factor to apply
  59080. * @param result defines the Color4 object where to store the result
  59081. * @returns the current unmodified Color4
  59082. */
  59083. scaleToRef(scale: number, result: Color4): Color4;
  59084. /**
  59085. * Scale the current Color4 values by a factor and add the result to a given Color4
  59086. * @param scale defines the scale factor
  59087. * @param result defines the Color4 object where to store the result
  59088. * @returns the unmodified current Color4
  59089. */
  59090. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59091. /**
  59092. * Clamps the rgb values by the min and max values and stores the result into "result"
  59093. * @param min defines minimum clamping value (default is 0)
  59094. * @param max defines maximum clamping value (default is 1)
  59095. * @param result defines color to store the result into.
  59096. * @returns the cuurent Color4
  59097. */
  59098. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59099. /**
  59100. * Multipy an Color4 value by another and return a new Color4 object
  59101. * @param color defines the Color4 value to multiply by
  59102. * @returns a new Color4 object
  59103. */
  59104. multiply(color: Color4): Color4;
  59105. /**
  59106. * Multipy a Color4 value by another and push the result in a reference value
  59107. * @param color defines the Color4 value to multiply by
  59108. * @param result defines the Color4 to fill the result in
  59109. * @returns the result Color4
  59110. */
  59111. multiplyToRef(color: Color4, result: Color4): Color4;
  59112. /**
  59113. * Creates a string with the Color4 current values
  59114. * @returns the string representation of the Color4 object
  59115. */
  59116. toString(): string;
  59117. /**
  59118. * Returns the string "Color4"
  59119. * @returns "Color4"
  59120. */
  59121. getClassName(): string;
  59122. /**
  59123. * Compute the Color4 hash code
  59124. * @returns an unique number that can be used to hash Color4 objects
  59125. */
  59126. getHashCode(): number;
  59127. /**
  59128. * Creates a new Color4 copied from the current one
  59129. * @returns a new Color4 object
  59130. */
  59131. clone(): Color4;
  59132. /**
  59133. * Copies the given Color4 values into the current one
  59134. * @param source defines the source Color4 object
  59135. * @returns the current updated Color4 object
  59136. */
  59137. copyFrom(source: Color4): Color4;
  59138. /**
  59139. * Copies the given float values into the current one
  59140. * @param r defines the red component to read from
  59141. * @param g defines the green component to read from
  59142. * @param b defines the blue component to read from
  59143. * @param a defines the alpha component to read from
  59144. * @returns the current updated Color4 object
  59145. */
  59146. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59147. /**
  59148. * Copies the given float values into the current one
  59149. * @param r defines the red component to read from
  59150. * @param g defines the green component to read from
  59151. * @param b defines the blue component to read from
  59152. * @param a defines the alpha component to read from
  59153. * @returns the current updated Color4 object
  59154. */
  59155. set(r: number, g: number, b: number, a: number): Color4;
  59156. /**
  59157. * Compute the Color4 hexadecimal code as a string
  59158. * @returns a string containing the hexadecimal representation of the Color4 object
  59159. */
  59160. toHexString(): string;
  59161. /**
  59162. * Computes a new Color4 converted from the current one to linear space
  59163. * @returns a new Color4 object
  59164. */
  59165. toLinearSpace(): Color4;
  59166. /**
  59167. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59168. * @param convertedColor defines the Color4 object where to store the linear space version
  59169. * @returns the unmodified Color4
  59170. */
  59171. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59172. /**
  59173. * Computes a new Color4 converted from the current one to gamma space
  59174. * @returns a new Color4 object
  59175. */
  59176. toGammaSpace(): Color4;
  59177. /**
  59178. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59179. * @param convertedColor defines the Color4 object where to store the gamma space version
  59180. * @returns the unmodified Color4
  59181. */
  59182. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59183. /**
  59184. * Creates a new Color4 from the string containing valid hexadecimal values
  59185. * @param hex defines a string containing valid hexadecimal values
  59186. * @returns a new Color4 object
  59187. */
  59188. static FromHexString(hex: string): Color4;
  59189. /**
  59190. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59191. * @param left defines the start value
  59192. * @param right defines the end value
  59193. * @param amount defines the gradient factor
  59194. * @returns a new Color4 object
  59195. */
  59196. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59197. /**
  59198. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59199. * @param left defines the start value
  59200. * @param right defines the end value
  59201. * @param amount defines the gradient factor
  59202. * @param result defines the Color4 object where to store data
  59203. */
  59204. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59205. /**
  59206. * Creates a new Color4 from a Color3 and an alpha value
  59207. * @param color3 defines the source Color3 to read from
  59208. * @param alpha defines the alpha component (1.0 by default)
  59209. * @returns a new Color4 object
  59210. */
  59211. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59212. /**
  59213. * Creates a new Color4 from the starting index element of the given array
  59214. * @param array defines the source array to read from
  59215. * @param offset defines the offset in the source array
  59216. * @returns a new Color4 object
  59217. */
  59218. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59219. /**
  59220. * Creates a new Color3 from integer values (< 256)
  59221. * @param r defines the red component to read from (value between 0 and 255)
  59222. * @param g defines the green component to read from (value between 0 and 255)
  59223. * @param b defines the blue component to read from (value between 0 and 255)
  59224. * @param a defines the alpha component to read from (value between 0 and 255)
  59225. * @returns a new Color3 object
  59226. */
  59227. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59228. /**
  59229. * Check the content of a given array and convert it to an array containing RGBA data
  59230. * If the original array was already containing count * 4 values then it is returned directly
  59231. * @param colors defines the array to check
  59232. * @param count defines the number of RGBA data to expect
  59233. * @returns an array containing count * 4 values (RGBA)
  59234. */
  59235. static CheckColors4(colors: number[], count: number): number[];
  59236. }
  59237. /**
  59238. * Class representing a vector containing 2 coordinates
  59239. */
  59240. export class Vector2 {
  59241. /** defines the first coordinate */
  59242. x: number;
  59243. /** defines the second coordinate */
  59244. y: number;
  59245. /**
  59246. * Creates a new Vector2 from the given x and y coordinates
  59247. * @param x defines the first coordinate
  59248. * @param y defines the second coordinate
  59249. */
  59250. constructor(
  59251. /** defines the first coordinate */
  59252. x?: number,
  59253. /** defines the second coordinate */
  59254. y?: number);
  59255. /**
  59256. * Gets a string with the Vector2 coordinates
  59257. * @returns a string with the Vector2 coordinates
  59258. */
  59259. toString(): string;
  59260. /**
  59261. * Gets class name
  59262. * @returns the string "Vector2"
  59263. */
  59264. getClassName(): string;
  59265. /**
  59266. * Gets current vector hash code
  59267. * @returns the Vector2 hash code as a number
  59268. */
  59269. getHashCode(): number;
  59270. /**
  59271. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59272. * @param array defines the source array
  59273. * @param index defines the offset in source array
  59274. * @returns the current Vector2
  59275. */
  59276. toArray(array: FloatArray, index?: number): Vector2;
  59277. /**
  59278. * Copy the current vector to an array
  59279. * @returns a new array with 2 elements: the Vector2 coordinates.
  59280. */
  59281. asArray(): number[];
  59282. /**
  59283. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59284. * @param source defines the source Vector2
  59285. * @returns the current updated Vector2
  59286. */
  59287. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59288. /**
  59289. * Sets the Vector2 coordinates with the given floats
  59290. * @param x defines the first coordinate
  59291. * @param y defines the second coordinate
  59292. * @returns the current updated Vector2
  59293. */
  59294. copyFromFloats(x: number, y: number): Vector2;
  59295. /**
  59296. * Sets the Vector2 coordinates with the given floats
  59297. * @param x defines the first coordinate
  59298. * @param y defines the second coordinate
  59299. * @returns the current updated Vector2
  59300. */
  59301. set(x: number, y: number): Vector2;
  59302. /**
  59303. * Add another vector with the current one
  59304. * @param otherVector defines the other vector
  59305. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  59306. */
  59307. add(otherVector: DeepImmutable<Vector2>): Vector2;
  59308. /**
  59309. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  59310. * @param otherVector defines the other vector
  59311. * @param result defines the target vector
  59312. * @returns the unmodified current Vector2
  59313. */
  59314. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59315. /**
  59316. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  59317. * @param otherVector defines the other vector
  59318. * @returns the current updated Vector2
  59319. */
  59320. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59321. /**
  59322. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  59323. * @param otherVector defines the other vector
  59324. * @returns a new Vector2
  59325. */
  59326. addVector3(otherVector: Vector3): Vector2;
  59327. /**
  59328. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  59329. * @param otherVector defines the other vector
  59330. * @returns a new Vector2
  59331. */
  59332. subtract(otherVector: Vector2): Vector2;
  59333. /**
  59334. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  59335. * @param otherVector defines the other vector
  59336. * @param result defines the target vector
  59337. * @returns the unmodified current Vector2
  59338. */
  59339. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59340. /**
  59341. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  59342. * @param otherVector defines the other vector
  59343. * @returns the current updated Vector2
  59344. */
  59345. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59346. /**
  59347. * Multiplies in place the current Vector2 coordinates by the given ones
  59348. * @param otherVector defines the other vector
  59349. * @returns the current updated Vector2
  59350. */
  59351. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59352. /**
  59353. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  59354. * @param otherVector defines the other vector
  59355. * @returns a new Vector2
  59356. */
  59357. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  59358. /**
  59359. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  59360. * @param otherVector defines the other vector
  59361. * @param result defines the target vector
  59362. * @returns the unmodified current Vector2
  59363. */
  59364. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59365. /**
  59366. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  59367. * @param x defines the first coordinate
  59368. * @param y defines the second coordinate
  59369. * @returns a new Vector2
  59370. */
  59371. multiplyByFloats(x: number, y: number): Vector2;
  59372. /**
  59373. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  59374. * @param otherVector defines the other vector
  59375. * @returns a new Vector2
  59376. */
  59377. divide(otherVector: Vector2): Vector2;
  59378. /**
  59379. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  59380. * @param otherVector defines the other vector
  59381. * @param result defines the target vector
  59382. * @returns the unmodified current Vector2
  59383. */
  59384. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59385. /**
  59386. * Divides the current Vector2 coordinates by the given ones
  59387. * @param otherVector defines the other vector
  59388. * @returns the current updated Vector2
  59389. */
  59390. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59391. /**
  59392. * Gets a new Vector2 with current Vector2 negated coordinates
  59393. * @returns a new Vector2
  59394. */
  59395. negate(): Vector2;
  59396. /**
  59397. * Multiply the Vector2 coordinates by scale
  59398. * @param scale defines the scaling factor
  59399. * @returns the current updated Vector2
  59400. */
  59401. scaleInPlace(scale: number): Vector2;
  59402. /**
  59403. * Returns a new Vector2 scaled by "scale" from the current Vector2
  59404. * @param scale defines the scaling factor
  59405. * @returns a new Vector2
  59406. */
  59407. scale(scale: number): Vector2;
  59408. /**
  59409. * Scale the current Vector2 values by a factor to a given Vector2
  59410. * @param scale defines the scale factor
  59411. * @param result defines the Vector2 object where to store the result
  59412. * @returns the unmodified current Vector2
  59413. */
  59414. scaleToRef(scale: number, result: Vector2): Vector2;
  59415. /**
  59416. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  59417. * @param scale defines the scale factor
  59418. * @param result defines the Vector2 object where to store the result
  59419. * @returns the unmodified current Vector2
  59420. */
  59421. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  59422. /**
  59423. * Gets a boolean if two vectors are equals
  59424. * @param otherVector defines the other vector
  59425. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  59426. */
  59427. equals(otherVector: DeepImmutable<Vector2>): boolean;
  59428. /**
  59429. * Gets a boolean if two vectors are equals (using an epsilon value)
  59430. * @param otherVector defines the other vector
  59431. * @param epsilon defines the minimal distance to consider equality
  59432. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  59433. */
  59434. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  59435. /**
  59436. * Gets a new Vector2 from current Vector2 floored values
  59437. * @returns a new Vector2
  59438. */
  59439. floor(): Vector2;
  59440. /**
  59441. * Gets a new Vector2 from current Vector2 floored values
  59442. * @returns a new Vector2
  59443. */
  59444. fract(): Vector2;
  59445. /**
  59446. * Gets the length of the vector
  59447. * @returns the vector length (float)
  59448. */
  59449. length(): number;
  59450. /**
  59451. * Gets the vector squared length
  59452. * @returns the vector squared length (float)
  59453. */
  59454. lengthSquared(): number;
  59455. /**
  59456. * Normalize the vector
  59457. * @returns the current updated Vector2
  59458. */
  59459. normalize(): Vector2;
  59460. /**
  59461. * Gets a new Vector2 copied from the Vector2
  59462. * @returns a new Vector2
  59463. */
  59464. clone(): Vector2;
  59465. /**
  59466. * Gets a new Vector2(0, 0)
  59467. * @returns a new Vector2
  59468. */
  59469. static Zero(): Vector2;
  59470. /**
  59471. * Gets a new Vector2(1, 1)
  59472. * @returns a new Vector2
  59473. */
  59474. static One(): Vector2;
  59475. /**
  59476. * Gets a new Vector2 set from the given index element of the given array
  59477. * @param array defines the data source
  59478. * @param offset defines the offset in the data source
  59479. * @returns a new Vector2
  59480. */
  59481. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  59482. /**
  59483. * Sets "result" from the given index element of the given array
  59484. * @param array defines the data source
  59485. * @param offset defines the offset in the data source
  59486. * @param result defines the target vector
  59487. */
  59488. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  59489. /**
  59490. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  59491. * @param value1 defines 1st point of control
  59492. * @param value2 defines 2nd point of control
  59493. * @param value3 defines 3rd point of control
  59494. * @param value4 defines 4th point of control
  59495. * @param amount defines the interpolation factor
  59496. * @returns a new Vector2
  59497. */
  59498. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  59499. /**
  59500. * 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".
  59501. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  59502. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  59503. * @param value defines the value to clamp
  59504. * @param min defines the lower limit
  59505. * @param max defines the upper limit
  59506. * @returns a new Vector2
  59507. */
  59508. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  59509. /**
  59510. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  59511. * @param value1 defines the 1st control point
  59512. * @param tangent1 defines the outgoing tangent
  59513. * @param value2 defines the 2nd control point
  59514. * @param tangent2 defines the incoming tangent
  59515. * @param amount defines the interpolation factor
  59516. * @returns a new Vector2
  59517. */
  59518. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  59519. /**
  59520. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  59521. * @param start defines the start vector
  59522. * @param end defines the end vector
  59523. * @param amount defines the interpolation factor
  59524. * @returns a new Vector2
  59525. */
  59526. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  59527. /**
  59528. * Gets the dot product of the vector "left" and the vector "right"
  59529. * @param left defines first vector
  59530. * @param right defines second vector
  59531. * @returns the dot product (float)
  59532. */
  59533. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  59534. /**
  59535. * Returns a new Vector2 equal to the normalized given vector
  59536. * @param vector defines the vector to normalize
  59537. * @returns a new Vector2
  59538. */
  59539. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  59540. /**
  59541. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  59542. * @param left defines 1st vector
  59543. * @param right defines 2nd vector
  59544. * @returns a new Vector2
  59545. */
  59546. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59547. /**
  59548. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  59549. * @param left defines 1st vector
  59550. * @param right defines 2nd vector
  59551. * @returns a new Vector2
  59552. */
  59553. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59554. /**
  59555. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  59556. * @param vector defines the vector to transform
  59557. * @param transformation defines the matrix to apply
  59558. * @returns a new Vector2
  59559. */
  59560. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  59561. /**
  59562. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  59563. * @param vector defines the vector to transform
  59564. * @param transformation defines the matrix to apply
  59565. * @param result defines the target vector
  59566. */
  59567. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  59568. /**
  59569. * Determines if a given vector is included in a triangle
  59570. * @param p defines the vector to test
  59571. * @param p0 defines 1st triangle point
  59572. * @param p1 defines 2nd triangle point
  59573. * @param p2 defines 3rd triangle point
  59574. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  59575. */
  59576. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  59577. /**
  59578. * Gets the distance between the vectors "value1" and "value2"
  59579. * @param value1 defines first vector
  59580. * @param value2 defines second vector
  59581. * @returns the distance between vectors
  59582. */
  59583. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59584. /**
  59585. * Returns the squared distance between the vectors "value1" and "value2"
  59586. * @param value1 defines first vector
  59587. * @param value2 defines second vector
  59588. * @returns the squared distance between vectors
  59589. */
  59590. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59591. /**
  59592. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  59593. * @param value1 defines first vector
  59594. * @param value2 defines second vector
  59595. * @returns a new Vector2
  59596. */
  59597. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  59598. /**
  59599. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  59600. * @param p defines the middle point
  59601. * @param segA defines one point of the segment
  59602. * @param segB defines the other point of the segment
  59603. * @returns the shortest distance
  59604. */
  59605. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  59606. }
  59607. /**
  59608. * Classed used to store (x,y,z) vector representation
  59609. * A Vector3 is the main object used in 3D geometry
  59610. * It can represent etiher the coordinates of a point the space, either a direction
  59611. * Reminder: js uses a left handed forward facing system
  59612. */
  59613. export class Vector3 {
  59614. /**
  59615. * Defines the first coordinates (on X axis)
  59616. */
  59617. x: number;
  59618. /**
  59619. * Defines the second coordinates (on Y axis)
  59620. */
  59621. y: number;
  59622. /**
  59623. * Defines the third coordinates (on Z axis)
  59624. */
  59625. z: number;
  59626. private static _UpReadOnly;
  59627. /**
  59628. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59629. * @param x defines the first coordinates (on X axis)
  59630. * @param y defines the second coordinates (on Y axis)
  59631. * @param z defines the third coordinates (on Z axis)
  59632. */
  59633. constructor(
  59634. /**
  59635. * Defines the first coordinates (on X axis)
  59636. */
  59637. x?: number,
  59638. /**
  59639. * Defines the second coordinates (on Y axis)
  59640. */
  59641. y?: number,
  59642. /**
  59643. * Defines the third coordinates (on Z axis)
  59644. */
  59645. z?: number);
  59646. /**
  59647. * Creates a string representation of the Vector3
  59648. * @returns a string with the Vector3 coordinates.
  59649. */
  59650. toString(): string;
  59651. /**
  59652. * Gets the class name
  59653. * @returns the string "Vector3"
  59654. */
  59655. getClassName(): string;
  59656. /**
  59657. * Creates the Vector3 hash code
  59658. * @returns a number which tends to be unique between Vector3 instances
  59659. */
  59660. getHashCode(): number;
  59661. /**
  59662. * Creates an array containing three elements : the coordinates of the Vector3
  59663. * @returns a new array of numbers
  59664. */
  59665. asArray(): number[];
  59666. /**
  59667. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59668. * @param array defines the destination array
  59669. * @param index defines the offset in the destination array
  59670. * @returns the current Vector3
  59671. */
  59672. toArray(array: FloatArray, index?: number): Vector3;
  59673. /**
  59674. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59675. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59676. */
  59677. toQuaternion(): Quaternion;
  59678. /**
  59679. * Adds the given vector to the current Vector3
  59680. * @param otherVector defines the second operand
  59681. * @returns the current updated Vector3
  59682. */
  59683. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59684. /**
  59685. * Adds the given coordinates to the current Vector3
  59686. * @param x defines the x coordinate of the operand
  59687. * @param y defines the y coordinate of the operand
  59688. * @param z defines the z coordinate of the operand
  59689. * @returns the current updated Vector3
  59690. */
  59691. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59692. /**
  59693. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59694. * @param otherVector defines the second operand
  59695. * @returns the resulting Vector3
  59696. */
  59697. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59698. /**
  59699. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59700. * @param otherVector defines the second operand
  59701. * @param result defines the Vector3 object where to store the result
  59702. * @returns the current Vector3
  59703. */
  59704. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59705. /**
  59706. * Subtract the given vector from the current Vector3
  59707. * @param otherVector defines the second operand
  59708. * @returns the current updated Vector3
  59709. */
  59710. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59711. /**
  59712. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59713. * @param otherVector defines the second operand
  59714. * @returns the resulting Vector3
  59715. */
  59716. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59717. /**
  59718. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59719. * @param otherVector defines the second operand
  59720. * @param result defines the Vector3 object where to store the result
  59721. * @returns the current Vector3
  59722. */
  59723. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59724. /**
  59725. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59726. * @param x defines the x coordinate of the operand
  59727. * @param y defines the y coordinate of the operand
  59728. * @param z defines the z coordinate of the operand
  59729. * @returns the resulting Vector3
  59730. */
  59731. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59732. /**
  59733. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59734. * @param x defines the x coordinate of the operand
  59735. * @param y defines the y coordinate of the operand
  59736. * @param z defines the z coordinate of the operand
  59737. * @param result defines the Vector3 object where to store the result
  59738. * @returns the current Vector3
  59739. */
  59740. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59741. /**
  59742. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59743. * @returns a new Vector3
  59744. */
  59745. negate(): Vector3;
  59746. /**
  59747. * Multiplies the Vector3 coordinates by the float "scale"
  59748. * @param scale defines the multiplier factor
  59749. * @returns the current updated Vector3
  59750. */
  59751. scaleInPlace(scale: number): Vector3;
  59752. /**
  59753. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59754. * @param scale defines the multiplier factor
  59755. * @returns a new Vector3
  59756. */
  59757. scale(scale: number): Vector3;
  59758. /**
  59759. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59760. * @param scale defines the multiplier factor
  59761. * @param result defines the Vector3 object where to store the result
  59762. * @returns the current Vector3
  59763. */
  59764. scaleToRef(scale: number, result: Vector3): Vector3;
  59765. /**
  59766. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59767. * @param scale defines the scale factor
  59768. * @param result defines the Vector3 object where to store the result
  59769. * @returns the unmodified current Vector3
  59770. */
  59771. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59772. /**
  59773. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59774. * @param otherVector defines the second operand
  59775. * @returns true if both vectors are equals
  59776. */
  59777. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59778. /**
  59779. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59780. * @param otherVector defines the second operand
  59781. * @param epsilon defines the minimal distance to define values as equals
  59782. * @returns true if both vectors are distant less than epsilon
  59783. */
  59784. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59785. /**
  59786. * Returns true if the current Vector3 coordinates equals the given floats
  59787. * @param x defines the x coordinate of the operand
  59788. * @param y defines the y coordinate of the operand
  59789. * @param z defines the z coordinate of the operand
  59790. * @returns true if both vectors are equals
  59791. */
  59792. equalsToFloats(x: number, y: number, z: number): boolean;
  59793. /**
  59794. * Multiplies the current Vector3 coordinates by the given ones
  59795. * @param otherVector defines the second operand
  59796. * @returns the current updated Vector3
  59797. */
  59798. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59799. /**
  59800. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59801. * @param otherVector defines the second operand
  59802. * @returns the new Vector3
  59803. */
  59804. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59805. /**
  59806. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59807. * @param otherVector defines the second operand
  59808. * @param result defines the Vector3 object where to store the result
  59809. * @returns the current Vector3
  59810. */
  59811. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59812. /**
  59813. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59814. * @param x defines the x coordinate of the operand
  59815. * @param y defines the y coordinate of the operand
  59816. * @param z defines the z coordinate of the operand
  59817. * @returns the new Vector3
  59818. */
  59819. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59820. /**
  59821. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59822. * @param otherVector defines the second operand
  59823. * @returns the new Vector3
  59824. */
  59825. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59826. /**
  59827. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59828. * @param otherVector defines the second operand
  59829. * @param result defines the Vector3 object where to store the result
  59830. * @returns the current Vector3
  59831. */
  59832. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59833. /**
  59834. * Divides the current Vector3 coordinates by the given ones.
  59835. * @param otherVector defines the second operand
  59836. * @returns the current updated Vector3
  59837. */
  59838. divideInPlace(otherVector: Vector3): Vector3;
  59839. /**
  59840. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59841. * @param other defines the second operand
  59842. * @returns the current updated Vector3
  59843. */
  59844. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59845. /**
  59846. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59847. * @param other defines the second operand
  59848. * @returns the current updated Vector3
  59849. */
  59850. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59851. /**
  59852. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59853. * @param x defines the x coordinate of the operand
  59854. * @param y defines the y coordinate of the operand
  59855. * @param z defines the z coordinate of the operand
  59856. * @returns the current updated Vector3
  59857. */
  59858. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59859. /**
  59860. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59861. * @param x defines the x coordinate of the operand
  59862. * @param y defines the y coordinate of the operand
  59863. * @param z defines the z coordinate of the operand
  59864. * @returns the current updated Vector3
  59865. */
  59866. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59867. /**
  59868. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59869. * Check if is non uniform within a certain amount of decimal places to account for this
  59870. * @param epsilon the amount the values can differ
  59871. * @returns if the the vector is non uniform to a certain number of decimal places
  59872. */
  59873. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59874. /**
  59875. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59876. */
  59877. readonly isNonUniform: boolean;
  59878. /**
  59879. * Gets a new Vector3 from current Vector3 floored values
  59880. * @returns a new Vector3
  59881. */
  59882. floor(): Vector3;
  59883. /**
  59884. * Gets a new Vector3 from current Vector3 floored values
  59885. * @returns a new Vector3
  59886. */
  59887. fract(): Vector3;
  59888. /**
  59889. * Gets the length of the Vector3
  59890. * @returns the length of the Vecto3
  59891. */
  59892. length(): number;
  59893. /**
  59894. * Gets the squared length of the Vector3
  59895. * @returns squared length of the Vector3
  59896. */
  59897. lengthSquared(): number;
  59898. /**
  59899. * Normalize the current Vector3.
  59900. * Please note that this is an in place operation.
  59901. * @returns the current updated Vector3
  59902. */
  59903. normalize(): Vector3;
  59904. /**
  59905. * Reorders the x y z properties of the vector in place
  59906. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59907. * @returns the current updated vector
  59908. */
  59909. reorderInPlace(order: string): this;
  59910. /**
  59911. * Rotates the vector around 0,0,0 by a quaternion
  59912. * @param quaternion the rotation quaternion
  59913. * @param result vector to store the result
  59914. * @returns the resulting vector
  59915. */
  59916. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59917. /**
  59918. * Rotates a vector around a given point
  59919. * @param quaternion the rotation quaternion
  59920. * @param point the point to rotate around
  59921. * @param result vector to store the result
  59922. * @returns the resulting vector
  59923. */
  59924. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59925. /**
  59926. * Normalize the current Vector3 with the given input length.
  59927. * Please note that this is an in place operation.
  59928. * @param len the length of the vector
  59929. * @returns the current updated Vector3
  59930. */
  59931. normalizeFromLength(len: number): Vector3;
  59932. /**
  59933. * Normalize the current Vector3 to a new vector
  59934. * @returns the new Vector3
  59935. */
  59936. normalizeToNew(): Vector3;
  59937. /**
  59938. * Normalize the current Vector3 to the reference
  59939. * @param reference define the Vector3 to update
  59940. * @returns the updated Vector3
  59941. */
  59942. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59943. /**
  59944. * Creates a new Vector3 copied from the current Vector3
  59945. * @returns the new Vector3
  59946. */
  59947. clone(): Vector3;
  59948. /**
  59949. * Copies the given vector coordinates to the current Vector3 ones
  59950. * @param source defines the source Vector3
  59951. * @returns the current updated Vector3
  59952. */
  59953. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59954. /**
  59955. * Copies the given floats to the current Vector3 coordinates
  59956. * @param x defines the x coordinate of the operand
  59957. * @param y defines the y coordinate of the operand
  59958. * @param z defines the z coordinate of the operand
  59959. * @returns the current updated Vector3
  59960. */
  59961. copyFromFloats(x: number, y: number, z: number): Vector3;
  59962. /**
  59963. * Copies the given floats to the current Vector3 coordinates
  59964. * @param x defines the x coordinate of the operand
  59965. * @param y defines the y coordinate of the operand
  59966. * @param z defines the z coordinate of the operand
  59967. * @returns the current updated Vector3
  59968. */
  59969. set(x: number, y: number, z: number): Vector3;
  59970. /**
  59971. * Copies the given float to the current Vector3 coordinates
  59972. * @param v defines the x, y and z coordinates of the operand
  59973. * @returns the current updated Vector3
  59974. */
  59975. setAll(v: number): Vector3;
  59976. /**
  59977. * Get the clip factor between two vectors
  59978. * @param vector0 defines the first operand
  59979. * @param vector1 defines the second operand
  59980. * @param axis defines the axis to use
  59981. * @param size defines the size along the axis
  59982. * @returns the clip factor
  59983. */
  59984. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59985. /**
  59986. * Get angle between two vectors
  59987. * @param vector0 angle between vector0 and vector1
  59988. * @param vector1 angle between vector0 and vector1
  59989. * @param normal direction of the normal
  59990. * @return the angle between vector0 and vector1
  59991. */
  59992. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59993. /**
  59994. * Returns a new Vector3 set from the index "offset" of the given array
  59995. * @param array defines the source array
  59996. * @param offset defines the offset in the source array
  59997. * @returns the new Vector3
  59998. */
  59999. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60000. /**
  60001. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60002. * This function is deprecated. Use FromArray instead
  60003. * @param array defines the source array
  60004. * @param offset defines the offset in the source array
  60005. * @returns the new Vector3
  60006. */
  60007. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60008. /**
  60009. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60010. * @param array defines the source array
  60011. * @param offset defines the offset in the source array
  60012. * @param result defines the Vector3 where to store the result
  60013. */
  60014. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60015. /**
  60016. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60017. * This function is deprecated. Use FromArrayToRef instead.
  60018. * @param array defines the source array
  60019. * @param offset defines the offset in the source array
  60020. * @param result defines the Vector3 where to store the result
  60021. */
  60022. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60023. /**
  60024. * Sets the given vector "result" with the given floats.
  60025. * @param x defines the x coordinate of the source
  60026. * @param y defines the y coordinate of the source
  60027. * @param z defines the z coordinate of the source
  60028. * @param result defines the Vector3 where to store the result
  60029. */
  60030. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60031. /**
  60032. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60033. * @returns a new empty Vector3
  60034. */
  60035. static Zero(): Vector3;
  60036. /**
  60037. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60038. * @returns a new unit Vector3
  60039. */
  60040. static One(): Vector3;
  60041. /**
  60042. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60043. * @returns a new up Vector3
  60044. */
  60045. static Up(): Vector3;
  60046. /**
  60047. * Gets a up Vector3 that must not be updated
  60048. */
  60049. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60050. /**
  60051. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60052. * @returns a new down Vector3
  60053. */
  60054. static Down(): Vector3;
  60055. /**
  60056. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60057. * @returns a new forward Vector3
  60058. */
  60059. static Forward(): Vector3;
  60060. /**
  60061. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60062. * @returns a new forward Vector3
  60063. */
  60064. static Backward(): Vector3;
  60065. /**
  60066. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60067. * @returns a new right Vector3
  60068. */
  60069. static Right(): Vector3;
  60070. /**
  60071. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60072. * @returns a new left Vector3
  60073. */
  60074. static Left(): Vector3;
  60075. /**
  60076. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60077. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60078. * @param vector defines the Vector3 to transform
  60079. * @param transformation defines the transformation matrix
  60080. * @returns the transformed Vector3
  60081. */
  60082. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60083. /**
  60084. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60085. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60086. * @param vector defines the Vector3 to transform
  60087. * @param transformation defines the transformation matrix
  60088. * @param result defines the Vector3 where to store the result
  60089. */
  60090. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60091. /**
  60092. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60093. * This method computes tranformed coordinates only, not transformed direction vectors
  60094. * @param x define the x coordinate of the source vector
  60095. * @param y define the y coordinate of the source vector
  60096. * @param z define the z coordinate of the source vector
  60097. * @param transformation defines the transformation matrix
  60098. * @param result defines the Vector3 where to store the result
  60099. */
  60100. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60101. /**
  60102. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60103. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60104. * @param vector defines the Vector3 to transform
  60105. * @param transformation defines the transformation matrix
  60106. * @returns the new Vector3
  60107. */
  60108. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60109. /**
  60110. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60111. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60112. * @param vector defines the Vector3 to transform
  60113. * @param transformation defines the transformation matrix
  60114. * @param result defines the Vector3 where to store the result
  60115. */
  60116. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60117. /**
  60118. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60119. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60120. * @param x define the x coordinate of the source vector
  60121. * @param y define the y coordinate of the source vector
  60122. * @param z define the z coordinate of the source vector
  60123. * @param transformation defines the transformation matrix
  60124. * @param result defines the Vector3 where to store the result
  60125. */
  60126. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60127. /**
  60128. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60129. * @param value1 defines the first control point
  60130. * @param value2 defines the second control point
  60131. * @param value3 defines the third control point
  60132. * @param value4 defines the fourth control point
  60133. * @param amount defines the amount on the spline to use
  60134. * @returns the new Vector3
  60135. */
  60136. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60137. /**
  60138. * 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"
  60139. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60140. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60141. * @param value defines the current value
  60142. * @param min defines the lower range value
  60143. * @param max defines the upper range value
  60144. * @returns the new Vector3
  60145. */
  60146. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60147. /**
  60148. * 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"
  60149. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60150. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60151. * @param value defines the current value
  60152. * @param min defines the lower range value
  60153. * @param max defines the upper range value
  60154. * @param result defines the Vector3 where to store the result
  60155. */
  60156. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60157. /**
  60158. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60159. * @param value1 defines the first control point
  60160. * @param tangent1 defines the first tangent vector
  60161. * @param value2 defines the second control point
  60162. * @param tangent2 defines the second tangent vector
  60163. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60164. * @returns the new Vector3
  60165. */
  60166. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60167. /**
  60168. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60169. * @param start defines the start value
  60170. * @param end defines the end value
  60171. * @param amount max defines amount between both (between 0 and 1)
  60172. * @returns the new Vector3
  60173. */
  60174. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60175. /**
  60176. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60177. * @param start defines the start value
  60178. * @param end defines the end value
  60179. * @param amount max defines amount between both (between 0 and 1)
  60180. * @param result defines the Vector3 where to store the result
  60181. */
  60182. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60183. /**
  60184. * Returns the dot product (float) between the vectors "left" and "right"
  60185. * @param left defines the left operand
  60186. * @param right defines the right operand
  60187. * @returns the dot product
  60188. */
  60189. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60190. /**
  60191. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60192. * The cross product is then orthogonal to both "left" and "right"
  60193. * @param left defines the left operand
  60194. * @param right defines the right operand
  60195. * @returns the cross product
  60196. */
  60197. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60198. /**
  60199. * Sets the given vector "result" with the cross product of "left" and "right"
  60200. * The cross product is then orthogonal to both "left" and "right"
  60201. * @param left defines the left operand
  60202. * @param right defines the right operand
  60203. * @param result defines the Vector3 where to store the result
  60204. */
  60205. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60206. /**
  60207. * Returns a new Vector3 as the normalization of the given vector
  60208. * @param vector defines the Vector3 to normalize
  60209. * @returns the new Vector3
  60210. */
  60211. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60212. /**
  60213. * Sets the given vector "result" with the normalization of the given first vector
  60214. * @param vector defines the Vector3 to normalize
  60215. * @param result defines the Vector3 where to store the result
  60216. */
  60217. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60218. /**
  60219. * Project a Vector3 onto screen space
  60220. * @param vector defines the Vector3 to project
  60221. * @param world defines the world matrix to use
  60222. * @param transform defines the transform (view x projection) matrix to use
  60223. * @param viewport defines the screen viewport to use
  60224. * @returns the new Vector3
  60225. */
  60226. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60227. /** @hidden */
  60228. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60229. /**
  60230. * Unproject from screen space to object space
  60231. * @param source defines the screen space Vector3 to use
  60232. * @param viewportWidth defines the current width of the viewport
  60233. * @param viewportHeight defines the current height of the viewport
  60234. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60235. * @param transform defines the transform (view x projection) matrix to use
  60236. * @returns the new Vector3
  60237. */
  60238. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60239. /**
  60240. * Unproject from screen space to object space
  60241. * @param source defines the screen space Vector3 to use
  60242. * @param viewportWidth defines the current width of the viewport
  60243. * @param viewportHeight defines the current height of the viewport
  60244. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60245. * @param view defines the view matrix to use
  60246. * @param projection defines the projection matrix to use
  60247. * @returns the new Vector3
  60248. */
  60249. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60250. /**
  60251. * Unproject from screen space to object space
  60252. * @param source defines the screen space Vector3 to use
  60253. * @param viewportWidth defines the current width of the viewport
  60254. * @param viewportHeight defines the current height of the viewport
  60255. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60256. * @param view defines the view matrix to use
  60257. * @param projection defines the projection matrix to use
  60258. * @param result defines the Vector3 where to store the result
  60259. */
  60260. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60261. /**
  60262. * Unproject from screen space to object space
  60263. * @param sourceX defines the screen space x coordinate to use
  60264. * @param sourceY defines the screen space y coordinate to use
  60265. * @param sourceZ defines the screen space z coordinate to use
  60266. * @param viewportWidth defines the current width of the viewport
  60267. * @param viewportHeight defines the current height of the viewport
  60268. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60269. * @param view defines the view matrix to use
  60270. * @param projection defines the projection matrix to use
  60271. * @param result defines the Vector3 where to store the result
  60272. */
  60273. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60274. /**
  60275. * Gets the minimal coordinate values between two Vector3
  60276. * @param left defines the first operand
  60277. * @param right defines the second operand
  60278. * @returns the new Vector3
  60279. */
  60280. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60281. /**
  60282. * Gets the maximal coordinate values between two Vector3
  60283. * @param left defines the first operand
  60284. * @param right defines the second operand
  60285. * @returns the new Vector3
  60286. */
  60287. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60288. /**
  60289. * Returns the distance between the vectors "value1" and "value2"
  60290. * @param value1 defines the first operand
  60291. * @param value2 defines the second operand
  60292. * @returns the distance
  60293. */
  60294. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60295. /**
  60296. * Returns the squared distance between the vectors "value1" and "value2"
  60297. * @param value1 defines the first operand
  60298. * @param value2 defines the second operand
  60299. * @returns the squared distance
  60300. */
  60301. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60302. /**
  60303. * Returns a new Vector3 located at the center between "value1" and "value2"
  60304. * @param value1 defines the first operand
  60305. * @param value2 defines the second operand
  60306. * @returns the new Vector3
  60307. */
  60308. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  60309. /**
  60310. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  60311. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  60312. * to something in order to rotate it from its local system to the given target system
  60313. * Note: axis1, axis2 and axis3 are normalized during this operation
  60314. * @param axis1 defines the first axis
  60315. * @param axis2 defines the second axis
  60316. * @param axis3 defines the third axis
  60317. * @returns a new Vector3
  60318. */
  60319. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  60320. /**
  60321. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  60322. * @param axis1 defines the first axis
  60323. * @param axis2 defines the second axis
  60324. * @param axis3 defines the third axis
  60325. * @param ref defines the Vector3 where to store the result
  60326. */
  60327. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  60328. }
  60329. /**
  60330. * Vector4 class created for EulerAngle class conversion to Quaternion
  60331. */
  60332. export class Vector4 {
  60333. /** x value of the vector */
  60334. x: number;
  60335. /** y value of the vector */
  60336. y: number;
  60337. /** z value of the vector */
  60338. z: number;
  60339. /** w value of the vector */
  60340. w: number;
  60341. /**
  60342. * Creates a Vector4 object from the given floats.
  60343. * @param x x value of the vector
  60344. * @param y y value of the vector
  60345. * @param z z value of the vector
  60346. * @param w w value of the vector
  60347. */
  60348. constructor(
  60349. /** x value of the vector */
  60350. x: number,
  60351. /** y value of the vector */
  60352. y: number,
  60353. /** z value of the vector */
  60354. z: number,
  60355. /** w value of the vector */
  60356. w: number);
  60357. /**
  60358. * Returns the string with the Vector4 coordinates.
  60359. * @returns a string containing all the vector values
  60360. */
  60361. toString(): string;
  60362. /**
  60363. * Returns the string "Vector4".
  60364. * @returns "Vector4"
  60365. */
  60366. getClassName(): string;
  60367. /**
  60368. * Returns the Vector4 hash code.
  60369. * @returns a unique hash code
  60370. */
  60371. getHashCode(): number;
  60372. /**
  60373. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  60374. * @returns the resulting array
  60375. */
  60376. asArray(): number[];
  60377. /**
  60378. * Populates the given array from the given index with the Vector4 coordinates.
  60379. * @param array array to populate
  60380. * @param index index of the array to start at (default: 0)
  60381. * @returns the Vector4.
  60382. */
  60383. toArray(array: FloatArray, index?: number): Vector4;
  60384. /**
  60385. * Adds the given vector to the current Vector4.
  60386. * @param otherVector the vector to add
  60387. * @returns the updated Vector4.
  60388. */
  60389. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60390. /**
  60391. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  60392. * @param otherVector the vector to add
  60393. * @returns the resulting vector
  60394. */
  60395. add(otherVector: DeepImmutable<Vector4>): Vector4;
  60396. /**
  60397. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  60398. * @param otherVector the vector to add
  60399. * @param result the vector to store the result
  60400. * @returns the current Vector4.
  60401. */
  60402. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60403. /**
  60404. * Subtract in place the given vector from the current Vector4.
  60405. * @param otherVector the vector to subtract
  60406. * @returns the updated Vector4.
  60407. */
  60408. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60409. /**
  60410. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  60411. * @param otherVector the vector to add
  60412. * @returns the new vector with the result
  60413. */
  60414. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  60415. /**
  60416. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  60417. * @param otherVector the vector to subtract
  60418. * @param result the vector to store the result
  60419. * @returns the current Vector4.
  60420. */
  60421. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60422. /**
  60423. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60424. */
  60425. /**
  60426. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60427. * @param x value to subtract
  60428. * @param y value to subtract
  60429. * @param z value to subtract
  60430. * @param w value to subtract
  60431. * @returns new vector containing the result
  60432. */
  60433. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60434. /**
  60435. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60436. * @param x value to subtract
  60437. * @param y value to subtract
  60438. * @param z value to subtract
  60439. * @param w value to subtract
  60440. * @param result the vector to store the result in
  60441. * @returns the current Vector4.
  60442. */
  60443. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  60444. /**
  60445. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  60446. * @returns a new vector with the negated values
  60447. */
  60448. negate(): Vector4;
  60449. /**
  60450. * Multiplies the current Vector4 coordinates by scale (float).
  60451. * @param scale the number to scale with
  60452. * @returns the updated Vector4.
  60453. */
  60454. scaleInPlace(scale: number): Vector4;
  60455. /**
  60456. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  60457. * @param scale the number to scale with
  60458. * @returns a new vector with the result
  60459. */
  60460. scale(scale: number): Vector4;
  60461. /**
  60462. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  60463. * @param scale the number to scale with
  60464. * @param result a vector to store the result in
  60465. * @returns the current Vector4.
  60466. */
  60467. scaleToRef(scale: number, result: Vector4): Vector4;
  60468. /**
  60469. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  60470. * @param scale defines the scale factor
  60471. * @param result defines the Vector4 object where to store the result
  60472. * @returns the unmodified current Vector4
  60473. */
  60474. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  60475. /**
  60476. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  60477. * @param otherVector the vector to compare against
  60478. * @returns true if they are equal
  60479. */
  60480. equals(otherVector: DeepImmutable<Vector4>): boolean;
  60481. /**
  60482. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  60483. * @param otherVector vector to compare against
  60484. * @param epsilon (Default: very small number)
  60485. * @returns true if they are equal
  60486. */
  60487. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  60488. /**
  60489. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  60490. * @param x x value to compare against
  60491. * @param y y value to compare against
  60492. * @param z z value to compare against
  60493. * @param w w value to compare against
  60494. * @returns true if equal
  60495. */
  60496. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  60497. /**
  60498. * Multiplies in place the current Vector4 by the given one.
  60499. * @param otherVector vector to multiple with
  60500. * @returns the updated Vector4.
  60501. */
  60502. multiplyInPlace(otherVector: Vector4): Vector4;
  60503. /**
  60504. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  60505. * @param otherVector vector to multiple with
  60506. * @returns resulting new vector
  60507. */
  60508. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  60509. /**
  60510. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  60511. * @param otherVector vector to multiple with
  60512. * @param result vector to store the result
  60513. * @returns the current Vector4.
  60514. */
  60515. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60516. /**
  60517. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  60518. * @param x x value multiply with
  60519. * @param y y value multiply with
  60520. * @param z z value multiply with
  60521. * @param w w value multiply with
  60522. * @returns resulting new vector
  60523. */
  60524. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  60525. /**
  60526. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  60527. * @param otherVector vector to devide with
  60528. * @returns resulting new vector
  60529. */
  60530. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  60531. /**
  60532. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  60533. * @param otherVector vector to devide with
  60534. * @param result vector to store the result
  60535. * @returns the current Vector4.
  60536. */
  60537. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60538. /**
  60539. * Divides the current Vector3 coordinates by the given ones.
  60540. * @param otherVector vector to devide with
  60541. * @returns the updated Vector3.
  60542. */
  60543. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60544. /**
  60545. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  60546. * @param other defines the second operand
  60547. * @returns the current updated Vector4
  60548. */
  60549. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60550. /**
  60551. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  60552. * @param other defines the second operand
  60553. * @returns the current updated Vector4
  60554. */
  60555. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60556. /**
  60557. * Gets a new Vector4 from current Vector4 floored values
  60558. * @returns a new Vector4
  60559. */
  60560. floor(): Vector4;
  60561. /**
  60562. * Gets a new Vector4 from current Vector3 floored values
  60563. * @returns a new Vector4
  60564. */
  60565. fract(): Vector4;
  60566. /**
  60567. * Returns the Vector4 length (float).
  60568. * @returns the length
  60569. */
  60570. length(): number;
  60571. /**
  60572. * Returns the Vector4 squared length (float).
  60573. * @returns the length squared
  60574. */
  60575. lengthSquared(): number;
  60576. /**
  60577. * Normalizes in place the Vector4.
  60578. * @returns the updated Vector4.
  60579. */
  60580. normalize(): Vector4;
  60581. /**
  60582. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  60583. * @returns this converted to a new vector3
  60584. */
  60585. toVector3(): Vector3;
  60586. /**
  60587. * Returns a new Vector4 copied from the current one.
  60588. * @returns the new cloned vector
  60589. */
  60590. clone(): Vector4;
  60591. /**
  60592. * Updates the current Vector4 with the given one coordinates.
  60593. * @param source the source vector to copy from
  60594. * @returns the updated Vector4.
  60595. */
  60596. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  60597. /**
  60598. * Updates the current Vector4 coordinates with the given floats.
  60599. * @param x float to copy from
  60600. * @param y float to copy from
  60601. * @param z float to copy from
  60602. * @param w float to copy from
  60603. * @returns the updated Vector4.
  60604. */
  60605. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60606. /**
  60607. * Updates the current Vector4 coordinates with the given floats.
  60608. * @param x float to set from
  60609. * @param y float to set from
  60610. * @param z float to set from
  60611. * @param w float to set from
  60612. * @returns the updated Vector4.
  60613. */
  60614. set(x: number, y: number, z: number, w: number): Vector4;
  60615. /**
  60616. * Copies the given float to the current Vector3 coordinates
  60617. * @param v defines the x, y, z and w coordinates of the operand
  60618. * @returns the current updated Vector3
  60619. */
  60620. setAll(v: number): Vector4;
  60621. /**
  60622. * Returns a new Vector4 set from the starting index of the given array.
  60623. * @param array the array to pull values from
  60624. * @param offset the offset into the array to start at
  60625. * @returns the new vector
  60626. */
  60627. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  60628. /**
  60629. * Updates the given vector "result" from the starting index of the given array.
  60630. * @param array the array to pull values from
  60631. * @param offset the offset into the array to start at
  60632. * @param result the vector to store the result in
  60633. */
  60634. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60635. /**
  60636. * Updates the given vector "result" from the starting index of the given Float32Array.
  60637. * @param array the array to pull values from
  60638. * @param offset the offset into the array to start at
  60639. * @param result the vector to store the result in
  60640. */
  60641. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60642. /**
  60643. * Updates the given vector "result" coordinates from the given floats.
  60644. * @param x float to set from
  60645. * @param y float to set from
  60646. * @param z float to set from
  60647. * @param w float to set from
  60648. * @param result the vector to the floats in
  60649. */
  60650. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60651. /**
  60652. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60653. * @returns the new vector
  60654. */
  60655. static Zero(): Vector4;
  60656. /**
  60657. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60658. * @returns the new vector
  60659. */
  60660. static One(): Vector4;
  60661. /**
  60662. * Returns a new normalized Vector4 from the given one.
  60663. * @param vector the vector to normalize
  60664. * @returns the vector
  60665. */
  60666. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60667. /**
  60668. * Updates the given vector "result" from the normalization of the given one.
  60669. * @param vector the vector to normalize
  60670. * @param result the vector to store the result in
  60671. */
  60672. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60673. /**
  60674. * Returns a vector with the minimum values from the left and right vectors
  60675. * @param left left vector to minimize
  60676. * @param right right vector to minimize
  60677. * @returns a new vector with the minimum of the left and right vector values
  60678. */
  60679. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60680. /**
  60681. * Returns a vector with the maximum values from the left and right vectors
  60682. * @param left left vector to maximize
  60683. * @param right right vector to maximize
  60684. * @returns a new vector with the maximum of the left and right vector values
  60685. */
  60686. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60687. /**
  60688. * Returns the distance (float) between the vectors "value1" and "value2".
  60689. * @param value1 value to calulate the distance between
  60690. * @param value2 value to calulate the distance between
  60691. * @return the distance between the two vectors
  60692. */
  60693. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60694. /**
  60695. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60696. * @param value1 value to calulate the distance between
  60697. * @param value2 value to calulate the distance between
  60698. * @return the distance between the two vectors squared
  60699. */
  60700. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60701. /**
  60702. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60703. * @param value1 value to calulate the center between
  60704. * @param value2 value to calulate the center between
  60705. * @return the center between the two vectors
  60706. */
  60707. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60708. /**
  60709. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60710. * This methods computes transformed normalized direction vectors only.
  60711. * @param vector the vector to transform
  60712. * @param transformation the transformation matrix to apply
  60713. * @returns the new vector
  60714. */
  60715. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60716. /**
  60717. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60718. * This methods computes transformed normalized direction vectors only.
  60719. * @param vector the vector to transform
  60720. * @param transformation the transformation matrix to apply
  60721. * @param result the vector to store the result in
  60722. */
  60723. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60724. /**
  60725. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60726. * This methods computes transformed normalized direction vectors only.
  60727. * @param x value to transform
  60728. * @param y value to transform
  60729. * @param z value to transform
  60730. * @param w value to transform
  60731. * @param transformation the transformation matrix to apply
  60732. * @param result the vector to store the results in
  60733. */
  60734. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60735. /**
  60736. * Creates a new Vector4 from a Vector3
  60737. * @param source defines the source data
  60738. * @param w defines the 4th component (default is 0)
  60739. * @returns a new Vector4
  60740. */
  60741. static FromVector3(source: Vector3, w?: number): Vector4;
  60742. }
  60743. /**
  60744. * Interface for the size containing width and height
  60745. */
  60746. export interface ISize {
  60747. /**
  60748. * Width
  60749. */
  60750. width: number;
  60751. /**
  60752. * Heighht
  60753. */
  60754. height: number;
  60755. }
  60756. /**
  60757. * Size containing widht and height
  60758. */
  60759. export class Size implements ISize {
  60760. /**
  60761. * Width
  60762. */
  60763. width: number;
  60764. /**
  60765. * Height
  60766. */
  60767. height: number;
  60768. /**
  60769. * Creates a Size object from the given width and height (floats).
  60770. * @param width width of the new size
  60771. * @param height height of the new size
  60772. */
  60773. constructor(width: number, height: number);
  60774. /**
  60775. * Returns a string with the Size width and height
  60776. * @returns a string with the Size width and height
  60777. */
  60778. toString(): string;
  60779. /**
  60780. * "Size"
  60781. * @returns the string "Size"
  60782. */
  60783. getClassName(): string;
  60784. /**
  60785. * Returns the Size hash code.
  60786. * @returns a hash code for a unique width and height
  60787. */
  60788. getHashCode(): number;
  60789. /**
  60790. * Updates the current size from the given one.
  60791. * @param src the given size
  60792. */
  60793. copyFrom(src: Size): void;
  60794. /**
  60795. * Updates in place the current Size from the given floats.
  60796. * @param width width of the new size
  60797. * @param height height of the new size
  60798. * @returns the updated Size.
  60799. */
  60800. copyFromFloats(width: number, height: number): Size;
  60801. /**
  60802. * Updates in place the current Size from the given floats.
  60803. * @param width width to set
  60804. * @param height height to set
  60805. * @returns the updated Size.
  60806. */
  60807. set(width: number, height: number): Size;
  60808. /**
  60809. * Multiplies the width and height by numbers
  60810. * @param w factor to multiple the width by
  60811. * @param h factor to multiple the height by
  60812. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60813. */
  60814. multiplyByFloats(w: number, h: number): Size;
  60815. /**
  60816. * Clones the size
  60817. * @returns a new Size copied from the given one.
  60818. */
  60819. clone(): Size;
  60820. /**
  60821. * True if the current Size and the given one width and height are strictly equal.
  60822. * @param other the other size to compare against
  60823. * @returns True if the current Size and the given one width and height are strictly equal.
  60824. */
  60825. equals(other: Size): boolean;
  60826. /**
  60827. * The surface of the Size : width * height (float).
  60828. */
  60829. readonly surface: number;
  60830. /**
  60831. * Create a new size of zero
  60832. * @returns a new Size set to (0.0, 0.0)
  60833. */
  60834. static Zero(): Size;
  60835. /**
  60836. * Sums the width and height of two sizes
  60837. * @param otherSize size to add to this size
  60838. * @returns a new Size set as the addition result of the current Size and the given one.
  60839. */
  60840. add(otherSize: Size): Size;
  60841. /**
  60842. * Subtracts the width and height of two
  60843. * @param otherSize size to subtract to this size
  60844. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60845. */
  60846. subtract(otherSize: Size): Size;
  60847. /**
  60848. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60849. * @param start starting size to lerp between
  60850. * @param end end size to lerp between
  60851. * @param amount amount to lerp between the start and end values
  60852. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60853. */
  60854. static Lerp(start: Size, end: Size, amount: number): Size;
  60855. }
  60856. /**
  60857. * Class used to store quaternion data
  60858. * @see https://en.wikipedia.org/wiki/Quaternion
  60859. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60860. */
  60861. export class Quaternion {
  60862. /** defines the first component (0 by default) */
  60863. x: number;
  60864. /** defines the second component (0 by default) */
  60865. y: number;
  60866. /** defines the third component (0 by default) */
  60867. z: number;
  60868. /** defines the fourth component (1.0 by default) */
  60869. w: number;
  60870. /**
  60871. * Creates a new Quaternion from the given floats
  60872. * @param x defines the first component (0 by default)
  60873. * @param y defines the second component (0 by default)
  60874. * @param z defines the third component (0 by default)
  60875. * @param w defines the fourth component (1.0 by default)
  60876. */
  60877. constructor(
  60878. /** defines the first component (0 by default) */
  60879. x?: number,
  60880. /** defines the second component (0 by default) */
  60881. y?: number,
  60882. /** defines the third component (0 by default) */
  60883. z?: number,
  60884. /** defines the fourth component (1.0 by default) */
  60885. w?: number);
  60886. /**
  60887. * Gets a string representation for the current quaternion
  60888. * @returns a string with the Quaternion coordinates
  60889. */
  60890. toString(): string;
  60891. /**
  60892. * Gets the class name of the quaternion
  60893. * @returns the string "Quaternion"
  60894. */
  60895. getClassName(): string;
  60896. /**
  60897. * Gets a hash code for this quaternion
  60898. * @returns the quaternion hash code
  60899. */
  60900. getHashCode(): number;
  60901. /**
  60902. * Copy the quaternion to an array
  60903. * @returns a new array populated with 4 elements from the quaternion coordinates
  60904. */
  60905. asArray(): number[];
  60906. /**
  60907. * Check if two quaternions are equals
  60908. * @param otherQuaternion defines the second operand
  60909. * @return true if the current quaternion and the given one coordinates are strictly equals
  60910. */
  60911. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60912. /**
  60913. * Clone the current quaternion
  60914. * @returns a new quaternion copied from the current one
  60915. */
  60916. clone(): Quaternion;
  60917. /**
  60918. * Copy a quaternion to the current one
  60919. * @param other defines the other quaternion
  60920. * @returns the updated current quaternion
  60921. */
  60922. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60923. /**
  60924. * Updates the current quaternion with the given float coordinates
  60925. * @param x defines the x coordinate
  60926. * @param y defines the y coordinate
  60927. * @param z defines the z coordinate
  60928. * @param w defines the w coordinate
  60929. * @returns the updated current quaternion
  60930. */
  60931. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60932. /**
  60933. * Updates the current quaternion from the given float coordinates
  60934. * @param x defines the x coordinate
  60935. * @param y defines the y coordinate
  60936. * @param z defines the z coordinate
  60937. * @param w defines the w coordinate
  60938. * @returns the updated current quaternion
  60939. */
  60940. set(x: number, y: number, z: number, w: number): Quaternion;
  60941. /**
  60942. * Adds two quaternions
  60943. * @param other defines the second operand
  60944. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60945. */
  60946. add(other: DeepImmutable<Quaternion>): Quaternion;
  60947. /**
  60948. * Add a quaternion to the current one
  60949. * @param other defines the quaternion to add
  60950. * @returns the current quaternion
  60951. */
  60952. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60953. /**
  60954. * Subtract two quaternions
  60955. * @param other defines the second operand
  60956. * @returns a new quaternion as the subtraction result of the given one from the current one
  60957. */
  60958. subtract(other: Quaternion): Quaternion;
  60959. /**
  60960. * Multiplies the current quaternion by a scale factor
  60961. * @param value defines the scale factor
  60962. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60963. */
  60964. scale(value: number): Quaternion;
  60965. /**
  60966. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60967. * @param scale defines the scale factor
  60968. * @param result defines the Quaternion object where to store the result
  60969. * @returns the unmodified current quaternion
  60970. */
  60971. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60972. /**
  60973. * Multiplies in place the current quaternion by a scale factor
  60974. * @param value defines the scale factor
  60975. * @returns the current modified quaternion
  60976. */
  60977. scaleInPlace(value: number): Quaternion;
  60978. /**
  60979. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60980. * @param scale defines the scale factor
  60981. * @param result defines the Quaternion object where to store the result
  60982. * @returns the unmodified current quaternion
  60983. */
  60984. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60985. /**
  60986. * Multiplies two quaternions
  60987. * @param q1 defines the second operand
  60988. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60989. */
  60990. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60991. /**
  60992. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60993. * @param q1 defines the second operand
  60994. * @param result defines the target quaternion
  60995. * @returns the current quaternion
  60996. */
  60997. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60998. /**
  60999. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61000. * @param q1 defines the second operand
  61001. * @returns the currentupdated quaternion
  61002. */
  61003. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61004. /**
  61005. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61006. * @param ref defines the target quaternion
  61007. * @returns the current quaternion
  61008. */
  61009. conjugateToRef(ref: Quaternion): Quaternion;
  61010. /**
  61011. * Conjugates in place (1-q) the current quaternion
  61012. * @returns the current updated quaternion
  61013. */
  61014. conjugateInPlace(): Quaternion;
  61015. /**
  61016. * Conjugates in place (1-q) the current quaternion
  61017. * @returns a new quaternion
  61018. */
  61019. conjugate(): Quaternion;
  61020. /**
  61021. * Gets length of current quaternion
  61022. * @returns the quaternion length (float)
  61023. */
  61024. length(): number;
  61025. /**
  61026. * Normalize in place the current quaternion
  61027. * @returns the current updated quaternion
  61028. */
  61029. normalize(): Quaternion;
  61030. /**
  61031. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61032. * @param order is a reserved parameter and is ignore for now
  61033. * @returns a new Vector3 containing the Euler angles
  61034. */
  61035. toEulerAngles(order?: string): Vector3;
  61036. /**
  61037. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61038. * @param result defines the vector which will be filled with the Euler angles
  61039. * @param order is a reserved parameter and is ignore for now
  61040. * @returns the current unchanged quaternion
  61041. */
  61042. toEulerAnglesToRef(result: Vector3): Quaternion;
  61043. /**
  61044. * Updates the given rotation matrix with the current quaternion values
  61045. * @param result defines the target matrix
  61046. * @returns the current unchanged quaternion
  61047. */
  61048. toRotationMatrix(result: Matrix): Quaternion;
  61049. /**
  61050. * Updates the current quaternion from the given rotation matrix values
  61051. * @param matrix defines the source matrix
  61052. * @returns the current updated quaternion
  61053. */
  61054. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61055. /**
  61056. * Creates a new quaternion from a rotation matrix
  61057. * @param matrix defines the source matrix
  61058. * @returns a new quaternion created from the given rotation matrix values
  61059. */
  61060. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61061. /**
  61062. * Updates the given quaternion with the given rotation matrix values
  61063. * @param matrix defines the source matrix
  61064. * @param result defines the target quaternion
  61065. */
  61066. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61067. /**
  61068. * Returns the dot product (float) between the quaternions "left" and "right"
  61069. * @param left defines the left operand
  61070. * @param right defines the right operand
  61071. * @returns the dot product
  61072. */
  61073. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61074. /**
  61075. * Checks if the two quaternions are close to each other
  61076. * @param quat0 defines the first quaternion to check
  61077. * @param quat1 defines the second quaternion to check
  61078. * @returns true if the two quaternions are close to each other
  61079. */
  61080. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61081. /**
  61082. * Creates an empty quaternion
  61083. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61084. */
  61085. static Zero(): Quaternion;
  61086. /**
  61087. * Inverse a given quaternion
  61088. * @param q defines the source quaternion
  61089. * @returns a new quaternion as the inverted current quaternion
  61090. */
  61091. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61092. /**
  61093. * Inverse a given quaternion
  61094. * @param q defines the source quaternion
  61095. * @param result the quaternion the result will be stored in
  61096. * @returns the result quaternion
  61097. */
  61098. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61099. /**
  61100. * Creates an identity quaternion
  61101. * @returns the identity quaternion
  61102. */
  61103. static Identity(): Quaternion;
  61104. /**
  61105. * Gets a boolean indicating if the given quaternion is identity
  61106. * @param quaternion defines the quaternion to check
  61107. * @returns true if the quaternion is identity
  61108. */
  61109. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61110. /**
  61111. * Creates a quaternion from a rotation around an axis
  61112. * @param axis defines the axis to use
  61113. * @param angle defines the angle to use
  61114. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61115. */
  61116. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61117. /**
  61118. * Creates a rotation around an axis and stores it into the given quaternion
  61119. * @param axis defines the axis to use
  61120. * @param angle defines the angle to use
  61121. * @param result defines the target quaternion
  61122. * @returns the target quaternion
  61123. */
  61124. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61125. /**
  61126. * Creates a new quaternion from data stored into an array
  61127. * @param array defines the data source
  61128. * @param offset defines the offset in the source array where the data starts
  61129. * @returns a new quaternion
  61130. */
  61131. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61132. /**
  61133. * Create a quaternion from Euler rotation angles
  61134. * @param x Pitch
  61135. * @param y Yaw
  61136. * @param z Roll
  61137. * @returns the new Quaternion
  61138. */
  61139. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61140. /**
  61141. * Updates a quaternion from Euler rotation angles
  61142. * @param x Pitch
  61143. * @param y Yaw
  61144. * @param z Roll
  61145. * @param result the quaternion to store the result
  61146. * @returns the updated quaternion
  61147. */
  61148. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61149. /**
  61150. * Create a quaternion from Euler rotation vector
  61151. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61152. * @returns the new Quaternion
  61153. */
  61154. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61155. /**
  61156. * Updates a quaternion from Euler rotation vector
  61157. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61158. * @param result the quaternion to store the result
  61159. * @returns the updated quaternion
  61160. */
  61161. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61162. /**
  61163. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61164. * @param yaw defines the rotation around Y axis
  61165. * @param pitch defines the rotation around X axis
  61166. * @param roll defines the rotation around Z axis
  61167. * @returns the new quaternion
  61168. */
  61169. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61170. /**
  61171. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61172. * @param yaw defines the rotation around Y axis
  61173. * @param pitch defines the rotation around X axis
  61174. * @param roll defines the rotation around Z axis
  61175. * @param result defines the target quaternion
  61176. */
  61177. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61178. /**
  61179. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61180. * @param alpha defines the rotation around first axis
  61181. * @param beta defines the rotation around second axis
  61182. * @param gamma defines the rotation around third axis
  61183. * @returns the new quaternion
  61184. */
  61185. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61186. /**
  61187. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61188. * @param alpha defines the rotation around first axis
  61189. * @param beta defines the rotation around second axis
  61190. * @param gamma defines the rotation around third axis
  61191. * @param result defines the target quaternion
  61192. */
  61193. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61194. /**
  61195. * 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)
  61196. * @param axis1 defines the first axis
  61197. * @param axis2 defines the second axis
  61198. * @param axis3 defines the third axis
  61199. * @returns the new quaternion
  61200. */
  61201. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61202. /**
  61203. * 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
  61204. * @param axis1 defines the first axis
  61205. * @param axis2 defines the second axis
  61206. * @param axis3 defines the third axis
  61207. * @param ref defines the target quaternion
  61208. */
  61209. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61210. /**
  61211. * Interpolates between two quaternions
  61212. * @param left defines first quaternion
  61213. * @param right defines second quaternion
  61214. * @param amount defines the gradient to use
  61215. * @returns the new interpolated quaternion
  61216. */
  61217. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61218. /**
  61219. * Interpolates between two quaternions and stores it into a target quaternion
  61220. * @param left defines first quaternion
  61221. * @param right defines second quaternion
  61222. * @param amount defines the gradient to use
  61223. * @param result defines the target quaternion
  61224. */
  61225. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61226. /**
  61227. * Interpolate between two quaternions using Hermite interpolation
  61228. * @param value1 defines first quaternion
  61229. * @param tangent1 defines the incoming tangent
  61230. * @param value2 defines second quaternion
  61231. * @param tangent2 defines the outgoing tangent
  61232. * @param amount defines the target quaternion
  61233. * @returns the new interpolated quaternion
  61234. */
  61235. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61236. }
  61237. /**
  61238. * Class used to store matrix data (4x4)
  61239. */
  61240. export class Matrix {
  61241. private static _updateFlagSeed;
  61242. private static _identityReadOnly;
  61243. private _isIdentity;
  61244. private _isIdentityDirty;
  61245. private _isIdentity3x2;
  61246. private _isIdentity3x2Dirty;
  61247. /**
  61248. * Gets the update flag of the matrix which is an unique number for the matrix.
  61249. * It will be incremented every time the matrix data change.
  61250. * You can use it to speed the comparison between two versions of the same matrix.
  61251. */
  61252. updateFlag: number;
  61253. private readonly _m;
  61254. /**
  61255. * Gets the internal data of the matrix
  61256. */
  61257. readonly m: DeepImmutable<Float32Array>;
  61258. /** @hidden */
  61259. _markAsUpdated(): void;
  61260. /** @hidden */
  61261. private _updateIdentityStatus;
  61262. /**
  61263. * Creates an empty matrix (filled with zeros)
  61264. */
  61265. constructor();
  61266. /**
  61267. * Check if the current matrix is identity
  61268. * @returns true is the matrix is the identity matrix
  61269. */
  61270. isIdentity(): boolean;
  61271. /**
  61272. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61273. * @returns true is the matrix is the identity matrix
  61274. */
  61275. isIdentityAs3x2(): boolean;
  61276. /**
  61277. * Gets the determinant of the matrix
  61278. * @returns the matrix determinant
  61279. */
  61280. determinant(): number;
  61281. /**
  61282. * Returns the matrix as a Float32Array
  61283. * @returns the matrix underlying array
  61284. */
  61285. toArray(): DeepImmutable<Float32Array>;
  61286. /**
  61287. * Returns the matrix as a Float32Array
  61288. * @returns the matrix underlying array.
  61289. */
  61290. asArray(): DeepImmutable<Float32Array>;
  61291. /**
  61292. * Inverts the current matrix in place
  61293. * @returns the current inverted matrix
  61294. */
  61295. invert(): Matrix;
  61296. /**
  61297. * Sets all the matrix elements to zero
  61298. * @returns the current matrix
  61299. */
  61300. reset(): Matrix;
  61301. /**
  61302. * Adds the current matrix with a second one
  61303. * @param other defines the matrix to add
  61304. * @returns a new matrix as the addition of the current matrix and the given one
  61305. */
  61306. add(other: DeepImmutable<Matrix>): Matrix;
  61307. /**
  61308. * Sets the given matrix "result" to the addition of the current matrix and the given one
  61309. * @param other defines the matrix to add
  61310. * @param result defines the target matrix
  61311. * @returns the current matrix
  61312. */
  61313. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61314. /**
  61315. * Adds in place the given matrix to the current matrix
  61316. * @param other defines the second operand
  61317. * @returns the current updated matrix
  61318. */
  61319. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  61320. /**
  61321. * Sets the given matrix to the current inverted Matrix
  61322. * @param other defines the target matrix
  61323. * @returns the unmodified current matrix
  61324. */
  61325. invertToRef(other: Matrix): Matrix;
  61326. /**
  61327. * add a value at the specified position in the current Matrix
  61328. * @param index the index of the value within the matrix. between 0 and 15.
  61329. * @param value the value to be added
  61330. * @returns the current updated matrix
  61331. */
  61332. addAtIndex(index: number, value: number): Matrix;
  61333. /**
  61334. * mutiply the specified position in the current Matrix by a value
  61335. * @param index the index of the value within the matrix. between 0 and 15.
  61336. * @param value the value to be added
  61337. * @returns the current updated matrix
  61338. */
  61339. multiplyAtIndex(index: number, value: number): Matrix;
  61340. /**
  61341. * Inserts the translation vector (using 3 floats) in the current matrix
  61342. * @param x defines the 1st component of the translation
  61343. * @param y defines the 2nd component of the translation
  61344. * @param z defines the 3rd component of the translation
  61345. * @returns the current updated matrix
  61346. */
  61347. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  61348. /**
  61349. * Inserts the translation vector in the current matrix
  61350. * @param vector3 defines the translation to insert
  61351. * @returns the current updated matrix
  61352. */
  61353. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  61354. /**
  61355. * Gets the translation value of the current matrix
  61356. * @returns a new Vector3 as the extracted translation from the matrix
  61357. */
  61358. getTranslation(): Vector3;
  61359. /**
  61360. * Fill a Vector3 with the extracted translation from the matrix
  61361. * @param result defines the Vector3 where to store the translation
  61362. * @returns the current matrix
  61363. */
  61364. getTranslationToRef(result: Vector3): Matrix;
  61365. /**
  61366. * Remove rotation and scaling part from the matrix
  61367. * @returns the updated matrix
  61368. */
  61369. removeRotationAndScaling(): Matrix;
  61370. /**
  61371. * Multiply two matrices
  61372. * @param other defines the second operand
  61373. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  61374. */
  61375. multiply(other: DeepImmutable<Matrix>): Matrix;
  61376. /**
  61377. * Copy the current matrix from the given one
  61378. * @param other defines the source matrix
  61379. * @returns the current updated matrix
  61380. */
  61381. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  61382. /**
  61383. * Populates the given array from the starting index with the current matrix values
  61384. * @param array defines the target array
  61385. * @param offset defines the offset in the target array where to start storing values
  61386. * @returns the current matrix
  61387. */
  61388. copyToArray(array: Float32Array, offset?: number): Matrix;
  61389. /**
  61390. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  61391. * @param other defines the second operand
  61392. * @param result defines the matrix where to store the multiplication
  61393. * @returns the current matrix
  61394. */
  61395. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61396. /**
  61397. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  61398. * @param other defines the second operand
  61399. * @param result defines the array where to store the multiplication
  61400. * @param offset defines the offset in the target array where to start storing values
  61401. * @returns the current matrix
  61402. */
  61403. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  61404. /**
  61405. * Check equality between this matrix and a second one
  61406. * @param value defines the second matrix to compare
  61407. * @returns true is the current matrix and the given one values are strictly equal
  61408. */
  61409. equals(value: DeepImmutable<Matrix>): boolean;
  61410. /**
  61411. * Clone the current matrix
  61412. * @returns a new matrix from the current matrix
  61413. */
  61414. clone(): Matrix;
  61415. /**
  61416. * Returns the name of the current matrix class
  61417. * @returns the string "Matrix"
  61418. */
  61419. getClassName(): string;
  61420. /**
  61421. * Gets the hash code of the current matrix
  61422. * @returns the hash code
  61423. */
  61424. getHashCode(): number;
  61425. /**
  61426. * Decomposes the current Matrix into a translation, rotation and scaling components
  61427. * @param scale defines the scale vector3 given as a reference to update
  61428. * @param rotation defines the rotation quaternion given as a reference to update
  61429. * @param translation defines the translation vector3 given as a reference to update
  61430. * @returns true if operation was successful
  61431. */
  61432. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  61433. /**
  61434. * Gets specific row of the matrix
  61435. * @param index defines the number of the row to get
  61436. * @returns the index-th row of the current matrix as a new Vector4
  61437. */
  61438. getRow(index: number): Nullable<Vector4>;
  61439. /**
  61440. * Sets the index-th row of the current matrix to the vector4 values
  61441. * @param index defines the number of the row to set
  61442. * @param row defines the target vector4
  61443. * @returns the updated current matrix
  61444. */
  61445. setRow(index: number, row: Vector4): Matrix;
  61446. /**
  61447. * Compute the transpose of the matrix
  61448. * @returns the new transposed matrix
  61449. */
  61450. transpose(): Matrix;
  61451. /**
  61452. * Compute the transpose of the matrix and store it in a given matrix
  61453. * @param result defines the target matrix
  61454. * @returns the current matrix
  61455. */
  61456. transposeToRef(result: Matrix): Matrix;
  61457. /**
  61458. * Sets the index-th row of the current matrix with the given 4 x float values
  61459. * @param index defines the row index
  61460. * @param x defines the x component to set
  61461. * @param y defines the y component to set
  61462. * @param z defines the z component to set
  61463. * @param w defines the w component to set
  61464. * @returns the updated current matrix
  61465. */
  61466. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  61467. /**
  61468. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  61469. * @param scale defines the scale factor
  61470. * @returns a new matrix
  61471. */
  61472. scale(scale: number): Matrix;
  61473. /**
  61474. * Scale the current matrix values by a factor to a given result matrix
  61475. * @param scale defines the scale factor
  61476. * @param result defines the matrix to store the result
  61477. * @returns the current matrix
  61478. */
  61479. scaleToRef(scale: number, result: Matrix): Matrix;
  61480. /**
  61481. * Scale the current matrix values by a factor and add the result to a given matrix
  61482. * @param scale defines the scale factor
  61483. * @param result defines the Matrix to store the result
  61484. * @returns the current matrix
  61485. */
  61486. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  61487. /**
  61488. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  61489. * @param ref matrix to store the result
  61490. */
  61491. toNormalMatrix(ref: Matrix): void;
  61492. /**
  61493. * Gets only rotation part of the current matrix
  61494. * @returns a new matrix sets to the extracted rotation matrix from the current one
  61495. */
  61496. getRotationMatrix(): Matrix;
  61497. /**
  61498. * Extracts the rotation matrix from the current one and sets it as the given "result"
  61499. * @param result defines the target matrix to store data to
  61500. * @returns the current matrix
  61501. */
  61502. getRotationMatrixToRef(result: Matrix): Matrix;
  61503. /**
  61504. * Toggles model matrix from being right handed to left handed in place and vice versa
  61505. */
  61506. toggleModelMatrixHandInPlace(): void;
  61507. /**
  61508. * Toggles projection matrix from being right handed to left handed in place and vice versa
  61509. */
  61510. toggleProjectionMatrixHandInPlace(): void;
  61511. /**
  61512. * Creates a matrix from an array
  61513. * @param array defines the source array
  61514. * @param offset defines an offset in the source array
  61515. * @returns a new Matrix set from the starting index of the given array
  61516. */
  61517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  61518. /**
  61519. * Copy the content of an array into a given matrix
  61520. * @param array defines the source array
  61521. * @param offset defines an offset in the source array
  61522. * @param result defines the target matrix
  61523. */
  61524. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  61525. /**
  61526. * Stores an array into a matrix after having multiplied each component by a given factor
  61527. * @param array defines the source array
  61528. * @param offset defines the offset in the source array
  61529. * @param scale defines the scaling factor
  61530. * @param result defines the target matrix
  61531. */
  61532. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  61533. /**
  61534. * Gets an identity matrix that must not be updated
  61535. */
  61536. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  61537. /**
  61538. * Stores a list of values (16) inside a given matrix
  61539. * @param initialM11 defines 1st value of 1st row
  61540. * @param initialM12 defines 2nd value of 1st row
  61541. * @param initialM13 defines 3rd value of 1st row
  61542. * @param initialM14 defines 4th value of 1st row
  61543. * @param initialM21 defines 1st value of 2nd row
  61544. * @param initialM22 defines 2nd value of 2nd row
  61545. * @param initialM23 defines 3rd value of 2nd row
  61546. * @param initialM24 defines 4th value of 2nd row
  61547. * @param initialM31 defines 1st value of 3rd row
  61548. * @param initialM32 defines 2nd value of 3rd row
  61549. * @param initialM33 defines 3rd value of 3rd row
  61550. * @param initialM34 defines 4th value of 3rd row
  61551. * @param initialM41 defines 1st value of 4th row
  61552. * @param initialM42 defines 2nd value of 4th row
  61553. * @param initialM43 defines 3rd value of 4th row
  61554. * @param initialM44 defines 4th value of 4th row
  61555. * @param result defines the target matrix
  61556. */
  61557. 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;
  61558. /**
  61559. * Creates new matrix from a list of values (16)
  61560. * @param initialM11 defines 1st value of 1st row
  61561. * @param initialM12 defines 2nd value of 1st row
  61562. * @param initialM13 defines 3rd value of 1st row
  61563. * @param initialM14 defines 4th value of 1st row
  61564. * @param initialM21 defines 1st value of 2nd row
  61565. * @param initialM22 defines 2nd value of 2nd row
  61566. * @param initialM23 defines 3rd value of 2nd row
  61567. * @param initialM24 defines 4th value of 2nd row
  61568. * @param initialM31 defines 1st value of 3rd row
  61569. * @param initialM32 defines 2nd value of 3rd row
  61570. * @param initialM33 defines 3rd value of 3rd row
  61571. * @param initialM34 defines 4th value of 3rd row
  61572. * @param initialM41 defines 1st value of 4th row
  61573. * @param initialM42 defines 2nd value of 4th row
  61574. * @param initialM43 defines 3rd value of 4th row
  61575. * @param initialM44 defines 4th value of 4th row
  61576. * @returns the new matrix
  61577. */
  61578. 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;
  61579. /**
  61580. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61581. * @param scale defines the scale vector3
  61582. * @param rotation defines the rotation quaternion
  61583. * @param translation defines the translation vector3
  61584. * @returns a new matrix
  61585. */
  61586. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  61587. /**
  61588. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61589. * @param scale defines the scale vector3
  61590. * @param rotation defines the rotation quaternion
  61591. * @param translation defines the translation vector3
  61592. * @param result defines the target matrix
  61593. */
  61594. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  61595. /**
  61596. * Creates a new identity matrix
  61597. * @returns a new identity matrix
  61598. */
  61599. static Identity(): Matrix;
  61600. /**
  61601. * Creates a new identity matrix and stores the result in a given matrix
  61602. * @param result defines the target matrix
  61603. */
  61604. static IdentityToRef(result: Matrix): void;
  61605. /**
  61606. * Creates a new zero matrix
  61607. * @returns a new zero matrix
  61608. */
  61609. static Zero(): Matrix;
  61610. /**
  61611. * Creates a new rotation matrix for "angle" radians around the X axis
  61612. * @param angle defines the angle (in radians) to use
  61613. * @return the new matrix
  61614. */
  61615. static RotationX(angle: number): Matrix;
  61616. /**
  61617. * Creates a new matrix as the invert of a given matrix
  61618. * @param source defines the source matrix
  61619. * @returns the new matrix
  61620. */
  61621. static Invert(source: DeepImmutable<Matrix>): Matrix;
  61622. /**
  61623. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  61624. * @param angle defines the angle (in radians) to use
  61625. * @param result defines the target matrix
  61626. */
  61627. static RotationXToRef(angle: number, result: Matrix): void;
  61628. /**
  61629. * Creates a new rotation matrix for "angle" radians around the Y axis
  61630. * @param angle defines the angle (in radians) to use
  61631. * @return the new matrix
  61632. */
  61633. static RotationY(angle: number): Matrix;
  61634. /**
  61635. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61636. * @param angle defines the angle (in radians) to use
  61637. * @param result defines the target matrix
  61638. */
  61639. static RotationYToRef(angle: number, result: Matrix): void;
  61640. /**
  61641. * Creates a new rotation matrix for "angle" radians around the Z axis
  61642. * @param angle defines the angle (in radians) to use
  61643. * @return the new matrix
  61644. */
  61645. static RotationZ(angle: number): Matrix;
  61646. /**
  61647. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61648. * @param angle defines the angle (in radians) to use
  61649. * @param result defines the target matrix
  61650. */
  61651. static RotationZToRef(angle: number, result: Matrix): void;
  61652. /**
  61653. * Creates a new rotation matrix for "angle" radians around the given axis
  61654. * @param axis defines the axis to use
  61655. * @param angle defines the angle (in radians) to use
  61656. * @return the new matrix
  61657. */
  61658. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61659. /**
  61660. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61661. * @param axis defines the axis to use
  61662. * @param angle defines the angle (in radians) to use
  61663. * @param result defines the target matrix
  61664. */
  61665. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61666. /**
  61667. * Creates a rotation matrix
  61668. * @param yaw defines the yaw angle in radians (Y axis)
  61669. * @param pitch defines the pitch angle in radians (X axis)
  61670. * @param roll defines the roll angle in radians (X axis)
  61671. * @returns the new rotation matrix
  61672. */
  61673. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61674. /**
  61675. * Creates a rotation matrix and stores it in a given matrix
  61676. * @param yaw defines the yaw angle in radians (Y axis)
  61677. * @param pitch defines the pitch angle in radians (X axis)
  61678. * @param roll defines the roll angle in radians (X axis)
  61679. * @param result defines the target matrix
  61680. */
  61681. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61682. /**
  61683. * Creates a scaling matrix
  61684. * @param x defines the scale factor on X axis
  61685. * @param y defines the scale factor on Y axis
  61686. * @param z defines the scale factor on Z axis
  61687. * @returns the new matrix
  61688. */
  61689. static Scaling(x: number, y: number, z: number): Matrix;
  61690. /**
  61691. * Creates a scaling matrix and stores it in a given matrix
  61692. * @param x defines the scale factor on X axis
  61693. * @param y defines the scale factor on Y axis
  61694. * @param z defines the scale factor on Z axis
  61695. * @param result defines the target matrix
  61696. */
  61697. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61698. /**
  61699. * Creates a translation matrix
  61700. * @param x defines the translation on X axis
  61701. * @param y defines the translation on Y axis
  61702. * @param z defines the translationon Z axis
  61703. * @returns the new matrix
  61704. */
  61705. static Translation(x: number, y: number, z: number): Matrix;
  61706. /**
  61707. * Creates a translation matrix and stores it in a given matrix
  61708. * @param x defines the translation on X axis
  61709. * @param y defines the translation on Y axis
  61710. * @param z defines the translationon Z axis
  61711. * @param result defines the target matrix
  61712. */
  61713. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61714. /**
  61715. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61716. * @param startValue defines the start value
  61717. * @param endValue defines the end value
  61718. * @param gradient defines the gradient factor
  61719. * @returns the new matrix
  61720. */
  61721. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61722. /**
  61723. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61724. * @param startValue defines the start value
  61725. * @param endValue defines the end value
  61726. * @param gradient defines the gradient factor
  61727. * @param result defines the Matrix object where to store data
  61728. */
  61729. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61730. /**
  61731. * Builds a new matrix whose values are computed by:
  61732. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61733. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61734. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61735. * @param startValue defines the first matrix
  61736. * @param endValue defines the second matrix
  61737. * @param gradient defines the gradient between the two matrices
  61738. * @returns the new matrix
  61739. */
  61740. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61741. /**
  61742. * Update a matrix to values which are computed by:
  61743. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61744. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61745. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61746. * @param startValue defines the first matrix
  61747. * @param endValue defines the second matrix
  61748. * @param gradient defines the gradient between the two matrices
  61749. * @param result defines the target matrix
  61750. */
  61751. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61752. /**
  61753. * 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"
  61754. * This function works in left handed mode
  61755. * @param eye defines the final position of the entity
  61756. * @param target defines where the entity should look at
  61757. * @param up defines the up vector for the entity
  61758. * @returns the new matrix
  61759. */
  61760. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61761. /**
  61762. * 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".
  61763. * This function works in left handed mode
  61764. * @param eye defines the final position of the entity
  61765. * @param target defines where the entity should look at
  61766. * @param up defines the up vector for the entity
  61767. * @param result defines the target matrix
  61768. */
  61769. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61770. /**
  61771. * 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"
  61772. * This function works in right handed mode
  61773. * @param eye defines the final position of the entity
  61774. * @param target defines where the entity should look at
  61775. * @param up defines the up vector for the entity
  61776. * @returns the new matrix
  61777. */
  61778. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61779. /**
  61780. * 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".
  61781. * This function works in right handed mode
  61782. * @param eye defines the final position of the entity
  61783. * @param target defines where the entity should look at
  61784. * @param up defines the up vector for the entity
  61785. * @param result defines the target matrix
  61786. */
  61787. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61788. /**
  61789. * Create a left-handed orthographic projection matrix
  61790. * @param width defines the viewport width
  61791. * @param height defines the viewport height
  61792. * @param znear defines the near clip plane
  61793. * @param zfar defines the far clip plane
  61794. * @returns a new matrix as a left-handed orthographic projection matrix
  61795. */
  61796. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61797. /**
  61798. * Store a left-handed orthographic projection to a given matrix
  61799. * @param width defines the viewport width
  61800. * @param height defines the viewport height
  61801. * @param znear defines the near clip plane
  61802. * @param zfar defines the far clip plane
  61803. * @param result defines the target matrix
  61804. */
  61805. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61806. /**
  61807. * Create a left-handed orthographic projection matrix
  61808. * @param left defines the viewport left coordinate
  61809. * @param right defines the viewport right coordinate
  61810. * @param bottom defines the viewport bottom coordinate
  61811. * @param top defines the viewport top coordinate
  61812. * @param znear defines the near clip plane
  61813. * @param zfar defines the far clip plane
  61814. * @returns a new matrix as a left-handed orthographic projection matrix
  61815. */
  61816. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61817. /**
  61818. * Stores a left-handed orthographic projection into a given matrix
  61819. * @param left defines the viewport left coordinate
  61820. * @param right defines the viewport right coordinate
  61821. * @param bottom defines the viewport bottom coordinate
  61822. * @param top defines the viewport top coordinate
  61823. * @param znear defines the near clip plane
  61824. * @param zfar defines the far clip plane
  61825. * @param result defines the target matrix
  61826. */
  61827. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61828. /**
  61829. * Creates a right-handed orthographic projection matrix
  61830. * @param left defines the viewport left coordinate
  61831. * @param right defines the viewport right coordinate
  61832. * @param bottom defines the viewport bottom coordinate
  61833. * @param top defines the viewport top coordinate
  61834. * @param znear defines the near clip plane
  61835. * @param zfar defines the far clip plane
  61836. * @returns a new matrix as a right-handed orthographic projection matrix
  61837. */
  61838. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61839. /**
  61840. * Stores a right-handed orthographic projection into a given matrix
  61841. * @param left defines the viewport left coordinate
  61842. * @param right defines the viewport right coordinate
  61843. * @param bottom defines the viewport bottom coordinate
  61844. * @param top defines the viewport top coordinate
  61845. * @param znear defines the near clip plane
  61846. * @param zfar defines the far clip plane
  61847. * @param result defines the target matrix
  61848. */
  61849. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61850. /**
  61851. * Creates a left-handed perspective projection matrix
  61852. * @param width defines the viewport width
  61853. * @param height defines the viewport height
  61854. * @param znear defines the near clip plane
  61855. * @param zfar defines the far clip plane
  61856. * @returns a new matrix as a left-handed perspective projection matrix
  61857. */
  61858. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61859. /**
  61860. * Creates a left-handed perspective projection matrix
  61861. * @param fov defines the horizontal field of view
  61862. * @param aspect defines the aspect ratio
  61863. * @param znear defines the near clip plane
  61864. * @param zfar defines the far clip plane
  61865. * @returns a new matrix as a left-handed perspective projection matrix
  61866. */
  61867. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61868. /**
  61869. * Stores a left-handed perspective projection into a given matrix
  61870. * @param fov defines the horizontal field of view
  61871. * @param aspect defines the aspect ratio
  61872. * @param znear defines the near clip plane
  61873. * @param zfar defines the far clip plane
  61874. * @param result defines the target matrix
  61875. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61876. */
  61877. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61878. /**
  61879. * Creates a right-handed perspective projection matrix
  61880. * @param fov defines the horizontal field of view
  61881. * @param aspect defines the aspect ratio
  61882. * @param znear defines the near clip plane
  61883. * @param zfar defines the far clip plane
  61884. * @returns a new matrix as a right-handed perspective projection matrix
  61885. */
  61886. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61887. /**
  61888. * Stores a right-handed perspective projection into a given matrix
  61889. * @param fov defines the horizontal field of view
  61890. * @param aspect defines the aspect ratio
  61891. * @param znear defines the near clip plane
  61892. * @param zfar defines the far clip plane
  61893. * @param result defines the target matrix
  61894. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61895. */
  61896. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61897. /**
  61898. * Stores a perspective projection for WebVR info a given matrix
  61899. * @param fov defines the field of view
  61900. * @param znear defines the near clip plane
  61901. * @param zfar defines the far clip plane
  61902. * @param result defines the target matrix
  61903. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61904. */
  61905. static PerspectiveFovWebVRToRef(fov: {
  61906. upDegrees: number;
  61907. downDegrees: number;
  61908. leftDegrees: number;
  61909. rightDegrees: number;
  61910. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61911. /**
  61912. * Computes a complete transformation matrix
  61913. * @param viewport defines the viewport to use
  61914. * @param world defines the world matrix
  61915. * @param view defines the view matrix
  61916. * @param projection defines the projection matrix
  61917. * @param zmin defines the near clip plane
  61918. * @param zmax defines the far clip plane
  61919. * @returns the transformation matrix
  61920. */
  61921. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61922. /**
  61923. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61924. * @param matrix defines the matrix to use
  61925. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61926. */
  61927. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61928. /**
  61929. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61930. * @param matrix defines the matrix to use
  61931. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61932. */
  61933. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61934. /**
  61935. * Compute the transpose of a given matrix
  61936. * @param matrix defines the matrix to transpose
  61937. * @returns the new matrix
  61938. */
  61939. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61940. /**
  61941. * Compute the transpose of a matrix and store it in a target matrix
  61942. * @param matrix defines the matrix to transpose
  61943. * @param result defines the target matrix
  61944. */
  61945. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61946. /**
  61947. * Computes a reflection matrix from a plane
  61948. * @param plane defines the reflection plane
  61949. * @returns a new matrix
  61950. */
  61951. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61952. /**
  61953. * Computes a reflection matrix from a plane
  61954. * @param plane defines the reflection plane
  61955. * @param result defines the target matrix
  61956. */
  61957. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61958. /**
  61959. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61960. * @param xaxis defines the value of the 1st axis
  61961. * @param yaxis defines the value of the 2nd axis
  61962. * @param zaxis defines the value of the 3rd axis
  61963. * @param result defines the target matrix
  61964. */
  61965. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61966. /**
  61967. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61968. * @param quat defines the quaternion to use
  61969. * @param result defines the target matrix
  61970. */
  61971. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61972. }
  61973. /**
  61974. * Represens a plane by the equation ax + by + cz + d = 0
  61975. */
  61976. export class Plane {
  61977. /**
  61978. * Normal of the plane (a,b,c)
  61979. */
  61980. normal: Vector3;
  61981. /**
  61982. * d component of the plane
  61983. */
  61984. d: number;
  61985. /**
  61986. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61987. * @param a a component of the plane
  61988. * @param b b component of the plane
  61989. * @param c c component of the plane
  61990. * @param d d component of the plane
  61991. */
  61992. constructor(a: number, b: number, c: number, d: number);
  61993. /**
  61994. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61995. */
  61996. asArray(): number[];
  61997. /**
  61998. * @returns a new plane copied from the current Plane.
  61999. */
  62000. clone(): Plane;
  62001. /**
  62002. * @returns the string "Plane".
  62003. */
  62004. getClassName(): string;
  62005. /**
  62006. * @returns the Plane hash code.
  62007. */
  62008. getHashCode(): number;
  62009. /**
  62010. * Normalize the current Plane in place.
  62011. * @returns the updated Plane.
  62012. */
  62013. normalize(): Plane;
  62014. /**
  62015. * Applies a transformation the plane and returns the result
  62016. * @param transformation the transformation matrix to be applied to the plane
  62017. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62018. */
  62019. transform(transformation: DeepImmutable<Matrix>): Plane;
  62020. /**
  62021. * Calcualtte the dot product between the point and the plane normal
  62022. * @param point point to calculate the dot product with
  62023. * @returns the dot product (float) of the point coordinates and the plane normal.
  62024. */
  62025. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62026. /**
  62027. * Updates the current Plane from the plane defined by the three given points.
  62028. * @param point1 one of the points used to contruct the plane
  62029. * @param point2 one of the points used to contruct the plane
  62030. * @param point3 one of the points used to contruct the plane
  62031. * @returns the updated Plane.
  62032. */
  62033. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62034. /**
  62035. * Checks if the plane is facing a given direction
  62036. * @param direction the direction to check if the plane is facing
  62037. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62038. * @returns True is the vector "direction" is the same side than the plane normal.
  62039. */
  62040. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  62041. /**
  62042. * Calculates the distance to a point
  62043. * @param point point to calculate distance to
  62044. * @returns the signed distance (float) from the given point to the Plane.
  62045. */
  62046. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  62047. /**
  62048. * Creates a plane from an array
  62049. * @param array the array to create a plane from
  62050. * @returns a new Plane from the given array.
  62051. */
  62052. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62053. /**
  62054. * Creates a plane from three points
  62055. * @param point1 point used to create the plane
  62056. * @param point2 point used to create the plane
  62057. * @param point3 point used to create the plane
  62058. * @returns a new Plane defined by the three given points.
  62059. */
  62060. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62061. /**
  62062. * Creates a plane from an origin point and a normal
  62063. * @param origin origin of the plane to be constructed
  62064. * @param normal normal of the plane to be constructed
  62065. * @returns a new Plane the normal vector to this plane at the given origin point.
  62066. * Note : the vector "normal" is updated because normalized.
  62067. */
  62068. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62069. /**
  62070. * Calculates the distance from a plane and a point
  62071. * @param origin origin of the plane to be constructed
  62072. * @param normal normal of the plane to be constructed
  62073. * @param point point to calculate distance to
  62074. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62075. */
  62076. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62077. }
  62078. /**
  62079. * Class used to represent a viewport on screen
  62080. */
  62081. export class Viewport {
  62082. /** viewport left coordinate */
  62083. x: number;
  62084. /** viewport top coordinate */
  62085. y: number;
  62086. /**viewport width */
  62087. width: number;
  62088. /** viewport height */
  62089. height: number;
  62090. /**
  62091. * Creates a Viewport object located at (x, y) and sized (width, height)
  62092. * @param x defines viewport left coordinate
  62093. * @param y defines viewport top coordinate
  62094. * @param width defines the viewport width
  62095. * @param height defines the viewport height
  62096. */
  62097. constructor(
  62098. /** viewport left coordinate */
  62099. x: number,
  62100. /** viewport top coordinate */
  62101. y: number,
  62102. /**viewport width */
  62103. width: number,
  62104. /** viewport height */
  62105. height: number);
  62106. /**
  62107. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62108. * @param renderWidth defines the rendering width
  62109. * @param renderHeight defines the rendering height
  62110. * @returns a new Viewport
  62111. */
  62112. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62113. /**
  62114. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62115. * @param renderWidth defines the rendering width
  62116. * @param renderHeight defines the rendering height
  62117. * @param ref defines the target viewport
  62118. * @returns the current viewport
  62119. */
  62120. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62121. /**
  62122. * Returns a new Viewport copied from the current one
  62123. * @returns a new Viewport
  62124. */
  62125. clone(): Viewport;
  62126. }
  62127. /**
  62128. * Reprasents a camera frustum
  62129. */
  62130. export class Frustum {
  62131. /**
  62132. * Gets the planes representing the frustum
  62133. * @param transform matrix to be applied to the returned planes
  62134. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62135. */
  62136. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62137. /**
  62138. * Gets the near frustum plane transformed by the transform matrix
  62139. * @param transform transformation matrix to be applied to the resulting frustum plane
  62140. * @param frustumPlane the resuling frustum plane
  62141. */
  62142. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62143. /**
  62144. * Gets the far frustum plane transformed by the transform matrix
  62145. * @param transform transformation matrix to be applied to the resulting frustum plane
  62146. * @param frustumPlane the resuling frustum plane
  62147. */
  62148. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62149. /**
  62150. * Gets the left frustum plane transformed by the transform matrix
  62151. * @param transform transformation matrix to be applied to the resulting frustum plane
  62152. * @param frustumPlane the resuling frustum plane
  62153. */
  62154. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62155. /**
  62156. * Gets the right frustum plane transformed by the transform matrix
  62157. * @param transform transformation matrix to be applied to the resulting frustum plane
  62158. * @param frustumPlane the resuling frustum plane
  62159. */
  62160. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62161. /**
  62162. * Gets the top frustum plane transformed by the transform matrix
  62163. * @param transform transformation matrix to be applied to the resulting frustum plane
  62164. * @param frustumPlane the resuling frustum plane
  62165. */
  62166. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62167. /**
  62168. * Gets the bottom frustum plane transformed by the transform matrix
  62169. * @param transform transformation matrix to be applied to the resulting frustum plane
  62170. * @param frustumPlane the resuling frustum plane
  62171. */
  62172. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62173. /**
  62174. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62175. * @param transform transformation matrix to be applied to the resulting frustum planes
  62176. * @param frustumPlanes the resuling frustum planes
  62177. */
  62178. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62179. }
  62180. /** Defines supported spaces */
  62181. export enum Space {
  62182. /** Local (object) space */
  62183. LOCAL = 0,
  62184. /** World space */
  62185. WORLD = 1,
  62186. /** Bone space */
  62187. BONE = 2
  62188. }
  62189. /** Defines the 3 main axes */
  62190. export class Axis {
  62191. /** X axis */
  62192. static X: Vector3;
  62193. /** Y axis */
  62194. static Y: Vector3;
  62195. /** Z axis */
  62196. static Z: Vector3;
  62197. }
  62198. /** Class used to represent a Bezier curve */
  62199. export class BezierCurve {
  62200. /**
  62201. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62202. * @param t defines the time
  62203. * @param x1 defines the left coordinate on X axis
  62204. * @param y1 defines the left coordinate on Y axis
  62205. * @param x2 defines the right coordinate on X axis
  62206. * @param y2 defines the right coordinate on Y axis
  62207. * @returns the interpolated value
  62208. */
  62209. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62210. }
  62211. /**
  62212. * Defines potential orientation for back face culling
  62213. */
  62214. export enum Orientation {
  62215. /**
  62216. * Clockwise
  62217. */
  62218. CW = 0,
  62219. /** Counter clockwise */
  62220. CCW = 1
  62221. }
  62222. /**
  62223. * Defines angle representation
  62224. */
  62225. export class Angle {
  62226. private _radians;
  62227. /**
  62228. * Creates an Angle object of "radians" radians (float).
  62229. * @param radians the angle in radians
  62230. */
  62231. constructor(radians: number);
  62232. /**
  62233. * Get value in degrees
  62234. * @returns the Angle value in degrees (float)
  62235. */
  62236. degrees(): number;
  62237. /**
  62238. * Get value in radians
  62239. * @returns the Angle value in radians (float)
  62240. */
  62241. radians(): number;
  62242. /**
  62243. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62244. * @param a defines first vector
  62245. * @param b defines second vector
  62246. * @returns a new Angle
  62247. */
  62248. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62249. /**
  62250. * Gets a new Angle object from the given float in radians
  62251. * @param radians defines the angle value in radians
  62252. * @returns a new Angle
  62253. */
  62254. static FromRadians(radians: number): Angle;
  62255. /**
  62256. * Gets a new Angle object from the given float in degrees
  62257. * @param degrees defines the angle value in degrees
  62258. * @returns a new Angle
  62259. */
  62260. static FromDegrees(degrees: number): Angle;
  62261. }
  62262. /**
  62263. * This represents an arc in a 2d space.
  62264. */
  62265. export class Arc2 {
  62266. /** Defines the start point of the arc */
  62267. startPoint: Vector2;
  62268. /** Defines the mid point of the arc */
  62269. midPoint: Vector2;
  62270. /** Defines the end point of the arc */
  62271. endPoint: Vector2;
  62272. /**
  62273. * Defines the center point of the arc.
  62274. */
  62275. centerPoint: Vector2;
  62276. /**
  62277. * Defines the radius of the arc.
  62278. */
  62279. radius: number;
  62280. /**
  62281. * Defines the angle of the arc (from mid point to end point).
  62282. */
  62283. angle: Angle;
  62284. /**
  62285. * Defines the start angle of the arc (from start point to middle point).
  62286. */
  62287. startAngle: Angle;
  62288. /**
  62289. * Defines the orientation of the arc (clock wise/counter clock wise).
  62290. */
  62291. orientation: Orientation;
  62292. /**
  62293. * Creates an Arc object from the three given points : start, middle and end.
  62294. * @param startPoint Defines the start point of the arc
  62295. * @param midPoint Defines the midlle point of the arc
  62296. * @param endPoint Defines the end point of the arc
  62297. */
  62298. constructor(
  62299. /** Defines the start point of the arc */
  62300. startPoint: Vector2,
  62301. /** Defines the mid point of the arc */
  62302. midPoint: Vector2,
  62303. /** Defines the end point of the arc */
  62304. endPoint: Vector2);
  62305. }
  62306. /**
  62307. * Represents a 2D path made up of multiple 2D points
  62308. */
  62309. export class Path2 {
  62310. private _points;
  62311. private _length;
  62312. /**
  62313. * If the path start and end point are the same
  62314. */
  62315. closed: boolean;
  62316. /**
  62317. * Creates a Path2 object from the starting 2D coordinates x and y.
  62318. * @param x the starting points x value
  62319. * @param y the starting points y value
  62320. */
  62321. constructor(x: number, y: number);
  62322. /**
  62323. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  62324. * @param x the added points x value
  62325. * @param y the added points y value
  62326. * @returns the updated Path2.
  62327. */
  62328. addLineTo(x: number, y: number): Path2;
  62329. /**
  62330. * 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.
  62331. * @param midX middle point x value
  62332. * @param midY middle point y value
  62333. * @param endX end point x value
  62334. * @param endY end point y value
  62335. * @param numberOfSegments (default: 36)
  62336. * @returns the updated Path2.
  62337. */
  62338. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  62339. /**
  62340. * Closes the Path2.
  62341. * @returns the Path2.
  62342. */
  62343. close(): Path2;
  62344. /**
  62345. * Gets the sum of the distance between each sequential point in the path
  62346. * @returns the Path2 total length (float).
  62347. */
  62348. length(): number;
  62349. /**
  62350. * Gets the points which construct the path
  62351. * @returns the Path2 internal array of points.
  62352. */
  62353. getPoints(): Vector2[];
  62354. /**
  62355. * Retreives the point at the distance aways from the starting point
  62356. * @param normalizedLengthPosition the length along the path to retreive the point from
  62357. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  62358. */
  62359. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  62360. /**
  62361. * Creates a new path starting from an x and y position
  62362. * @param x starting x value
  62363. * @param y starting y value
  62364. * @returns a new Path2 starting at the coordinates (x, y).
  62365. */
  62366. static StartingAt(x: number, y: number): Path2;
  62367. }
  62368. /**
  62369. * Represents a 3D path made up of multiple 3D points
  62370. */
  62371. export class Path3D {
  62372. /**
  62373. * an array of Vector3, the curve axis of the Path3D
  62374. */
  62375. path: Vector3[];
  62376. private _curve;
  62377. private _distances;
  62378. private _tangents;
  62379. private _normals;
  62380. private _binormals;
  62381. private _raw;
  62382. /**
  62383. * new Path3D(path, normal, raw)
  62384. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  62385. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  62386. * @param path an array of Vector3, the curve axis of the Path3D
  62387. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  62388. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  62389. */
  62390. constructor(
  62391. /**
  62392. * an array of Vector3, the curve axis of the Path3D
  62393. */
  62394. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  62395. /**
  62396. * Returns the Path3D array of successive Vector3 designing its curve.
  62397. * @returns the Path3D array of successive Vector3 designing its curve.
  62398. */
  62399. getCurve(): Vector3[];
  62400. /**
  62401. * Returns an array populated with tangent vectors on each Path3D curve point.
  62402. * @returns an array populated with tangent vectors on each Path3D curve point.
  62403. */
  62404. getTangents(): Vector3[];
  62405. /**
  62406. * Returns an array populated with normal vectors on each Path3D curve point.
  62407. * @returns an array populated with normal vectors on each Path3D curve point.
  62408. */
  62409. getNormals(): Vector3[];
  62410. /**
  62411. * Returns an array populated with binormal vectors on each Path3D curve point.
  62412. * @returns an array populated with binormal vectors on each Path3D curve point.
  62413. */
  62414. getBinormals(): Vector3[];
  62415. /**
  62416. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  62417. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  62418. */
  62419. getDistances(): number[];
  62420. /**
  62421. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  62422. * @param path path which all values are copied into the curves points
  62423. * @param firstNormal which should be projected onto the curve
  62424. * @returns the same object updated.
  62425. */
  62426. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  62427. private _compute;
  62428. private _getFirstNonNullVector;
  62429. private _getLastNonNullVector;
  62430. private _normalVector;
  62431. }
  62432. /**
  62433. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62434. * A Curve3 is designed from a series of successive Vector3.
  62435. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  62436. */
  62437. export class Curve3 {
  62438. private _points;
  62439. private _length;
  62440. /**
  62441. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  62442. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  62443. * @param v1 (Vector3) the control point
  62444. * @param v2 (Vector3) the end point of the Quadratic Bezier
  62445. * @param nbPoints (integer) the wanted number of points in the curve
  62446. * @returns the created Curve3
  62447. */
  62448. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62449. /**
  62450. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  62451. * @param v0 (Vector3) the origin point of the Cubic Bezier
  62452. * @param v1 (Vector3) the first control point
  62453. * @param v2 (Vector3) the second control point
  62454. * @param v3 (Vector3) the end point of the Cubic Bezier
  62455. * @param nbPoints (integer) the wanted number of points in the curve
  62456. * @returns the created Curve3
  62457. */
  62458. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62459. /**
  62460. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  62461. * @param p1 (Vector3) the origin point of the Hermite Spline
  62462. * @param t1 (Vector3) the tangent vector at the origin point
  62463. * @param p2 (Vector3) the end point of the Hermite Spline
  62464. * @param t2 (Vector3) the tangent vector at the end point
  62465. * @param nbPoints (integer) the wanted number of points in the curve
  62466. * @returns the created Curve3
  62467. */
  62468. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62469. /**
  62470. * Returns a Curve3 object along a CatmullRom Spline curve :
  62471. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  62472. * @param nbPoints (integer) the wanted number of points between each curve control points
  62473. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  62474. * @returns the created Curve3
  62475. */
  62476. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  62477. /**
  62478. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62479. * A Curve3 is designed from a series of successive Vector3.
  62480. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  62481. * @param points points which make up the curve
  62482. */
  62483. constructor(points: Vector3[]);
  62484. /**
  62485. * @returns the Curve3 stored array of successive Vector3
  62486. */
  62487. getPoints(): Vector3[];
  62488. /**
  62489. * @returns the computed length (float) of the curve.
  62490. */
  62491. length(): number;
  62492. /**
  62493. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  62494. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  62495. * curveA and curveB keep unchanged.
  62496. * @param curve the curve to continue from this curve
  62497. * @returns the newly constructed curve
  62498. */
  62499. continue(curve: DeepImmutable<Curve3>): Curve3;
  62500. private _computeLength;
  62501. }
  62502. /**
  62503. * Contains position and normal vectors for a vertex
  62504. */
  62505. export class PositionNormalVertex {
  62506. /** the position of the vertex (defaut: 0,0,0) */
  62507. position: Vector3;
  62508. /** the normal of the vertex (defaut: 0,1,0) */
  62509. normal: Vector3;
  62510. /**
  62511. * Creates a PositionNormalVertex
  62512. * @param position the position of the vertex (defaut: 0,0,0)
  62513. * @param normal the normal of the vertex (defaut: 0,1,0)
  62514. */
  62515. constructor(
  62516. /** the position of the vertex (defaut: 0,0,0) */
  62517. position?: Vector3,
  62518. /** the normal of the vertex (defaut: 0,1,0) */
  62519. normal?: Vector3);
  62520. /**
  62521. * Clones the PositionNormalVertex
  62522. * @returns the cloned PositionNormalVertex
  62523. */
  62524. clone(): PositionNormalVertex;
  62525. }
  62526. /**
  62527. * Contains position, normal and uv vectors for a vertex
  62528. */
  62529. export class PositionNormalTextureVertex {
  62530. /** the position of the vertex (defaut: 0,0,0) */
  62531. position: Vector3;
  62532. /** the normal of the vertex (defaut: 0,1,0) */
  62533. normal: Vector3;
  62534. /** the uv of the vertex (default: 0,0) */
  62535. uv: Vector2;
  62536. /**
  62537. * Creates a PositionNormalTextureVertex
  62538. * @param position the position of the vertex (defaut: 0,0,0)
  62539. * @param normal the normal of the vertex (defaut: 0,1,0)
  62540. * @param uv the uv of the vertex (default: 0,0)
  62541. */
  62542. constructor(
  62543. /** the position of the vertex (defaut: 0,0,0) */
  62544. position?: Vector3,
  62545. /** the normal of the vertex (defaut: 0,1,0) */
  62546. normal?: Vector3,
  62547. /** the uv of the vertex (default: 0,0) */
  62548. uv?: Vector2);
  62549. /**
  62550. * Clones the PositionNormalTextureVertex
  62551. * @returns the cloned PositionNormalTextureVertex
  62552. */
  62553. clone(): PositionNormalTextureVertex;
  62554. }
  62555. /**
  62556. * @hidden
  62557. */
  62558. export class Tmp {
  62559. static Color3: Color3[];
  62560. static Color4: Color4[];
  62561. static Vector2: Vector2[];
  62562. static Vector3: Vector3[];
  62563. static Vector4: Vector4[];
  62564. static Quaternion: Quaternion[];
  62565. static Matrix: Matrix[];
  62566. }
  62567. }
  62568. declare module BABYLON {
  62569. /**
  62570. * Class used to enable access to offline support
  62571. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62572. */
  62573. export interface IOfflineProvider {
  62574. /**
  62575. * Gets a boolean indicating if scene must be saved in the database
  62576. */
  62577. enableSceneOffline: boolean;
  62578. /**
  62579. * Gets a boolean indicating if textures must be saved in the database
  62580. */
  62581. enableTexturesOffline: boolean;
  62582. /**
  62583. * Open the offline support and make it available
  62584. * @param successCallback defines the callback to call on success
  62585. * @param errorCallback defines the callback to call on error
  62586. */
  62587. open(successCallback: () => void, errorCallback: () => void): void;
  62588. /**
  62589. * Loads an image from the offline support
  62590. * @param url defines the url to load from
  62591. * @param image defines the target DOM image
  62592. */
  62593. loadImage(url: string, image: HTMLImageElement): void;
  62594. /**
  62595. * Loads a file from offline support
  62596. * @param url defines the URL to load from
  62597. * @param sceneLoaded defines a callback to call on success
  62598. * @param progressCallBack defines a callback to call when progress changed
  62599. * @param errorCallback defines a callback to call on error
  62600. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62601. */
  62602. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62603. }
  62604. }
  62605. declare module BABYLON {
  62606. /**
  62607. * A class serves as a medium between the observable and its observers
  62608. */
  62609. export class EventState {
  62610. /**
  62611. * Create a new EventState
  62612. * @param mask defines the mask associated with this state
  62613. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62614. * @param target defines the original target of the state
  62615. * @param currentTarget defines the current target of the state
  62616. */
  62617. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62618. /**
  62619. * Initialize the current event state
  62620. * @param mask defines the mask associated with this state
  62621. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62622. * @param target defines the original target of the state
  62623. * @param currentTarget defines the current target of the state
  62624. * @returns the current event state
  62625. */
  62626. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  62627. /**
  62628. * An Observer can set this property to true to prevent subsequent observers of being notified
  62629. */
  62630. skipNextObservers: boolean;
  62631. /**
  62632. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62633. */
  62634. mask: number;
  62635. /**
  62636. * The object that originally notified the event
  62637. */
  62638. target?: any;
  62639. /**
  62640. * The current object in the bubbling phase
  62641. */
  62642. currentTarget?: any;
  62643. /**
  62644. * This will be populated with the return value of the last function that was executed.
  62645. * If it is the first function in the callback chain it will be the event data.
  62646. */
  62647. lastReturnValue?: any;
  62648. }
  62649. /**
  62650. * Represent an Observer registered to a given Observable object.
  62651. */
  62652. export class Observer<T> {
  62653. /**
  62654. * Defines the callback to call when the observer is notified
  62655. */
  62656. callback: (eventData: T, eventState: EventState) => void;
  62657. /**
  62658. * Defines the mask of the observer (used to filter notifications)
  62659. */
  62660. mask: number;
  62661. /**
  62662. * Defines the current scope used to restore the JS context
  62663. */
  62664. scope: any;
  62665. /** @hidden */
  62666. _willBeUnregistered: boolean;
  62667. /**
  62668. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62669. */
  62670. unregisterOnNextCall: boolean;
  62671. /**
  62672. * Creates a new observer
  62673. * @param callback defines the callback to call when the observer is notified
  62674. * @param mask defines the mask of the observer (used to filter notifications)
  62675. * @param scope defines the current scope used to restore the JS context
  62676. */
  62677. constructor(
  62678. /**
  62679. * Defines the callback to call when the observer is notified
  62680. */
  62681. callback: (eventData: T, eventState: EventState) => void,
  62682. /**
  62683. * Defines the mask of the observer (used to filter notifications)
  62684. */
  62685. mask: number,
  62686. /**
  62687. * Defines the current scope used to restore the JS context
  62688. */
  62689. scope?: any);
  62690. }
  62691. /**
  62692. * Represent a list of observers registered to multiple Observables object.
  62693. */
  62694. export class MultiObserver<T> {
  62695. private _observers;
  62696. private _observables;
  62697. /**
  62698. * Release associated resources
  62699. */
  62700. dispose(): void;
  62701. /**
  62702. * Raise a callback when one of the observable will notify
  62703. * @param observables defines a list of observables to watch
  62704. * @param callback defines the callback to call on notification
  62705. * @param mask defines the mask used to filter notifications
  62706. * @param scope defines the current scope used to restore the JS context
  62707. * @returns the new MultiObserver
  62708. */
  62709. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62710. }
  62711. /**
  62712. * The Observable class is a simple implementation of the Observable pattern.
  62713. *
  62714. * 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.
  62715. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62716. * 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).
  62717. * 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.
  62718. */
  62719. export class Observable<T> {
  62720. private _observers;
  62721. private _eventState;
  62722. private _onObserverAdded;
  62723. /**
  62724. * Creates a new observable
  62725. * @param onObserverAdded defines a callback to call when a new observer is added
  62726. */
  62727. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62728. /**
  62729. * Create a new Observer with the specified callback
  62730. * @param callback the callback that will be executed for that Observer
  62731. * @param mask the mask used to filter observers
  62732. * @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.
  62733. * @param scope optional scope for the callback to be called from
  62734. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62735. * @returns the new observer created for the callback
  62736. */
  62737. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62738. /**
  62739. * Create a new Observer with the specified callback and unregisters after the next notification
  62740. * @param callback the callback that will be executed for that Observer
  62741. * @returns the new observer created for the callback
  62742. */
  62743. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62744. /**
  62745. * Remove an Observer from the Observable object
  62746. * @param observer the instance of the Observer to remove
  62747. * @returns false if it doesn't belong to this Observable
  62748. */
  62749. remove(observer: Nullable<Observer<T>>): boolean;
  62750. /**
  62751. * Remove a callback from the Observable object
  62752. * @param callback the callback to remove
  62753. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62754. * @returns false if it doesn't belong to this Observable
  62755. */
  62756. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62757. private _deferUnregister;
  62758. private _remove;
  62759. /**
  62760. * Moves the observable to the top of the observer list making it get called first when notified
  62761. * @param observer the observer to move
  62762. */
  62763. makeObserverTopPriority(observer: Observer<T>): void;
  62764. /**
  62765. * Moves the observable to the bottom of the observer list making it get called last when notified
  62766. * @param observer the observer to move
  62767. */
  62768. makeObserverBottomPriority(observer: Observer<T>): void;
  62769. /**
  62770. * Notify all Observers by calling their respective callback with the given data
  62771. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62772. * @param eventData defines the data to send to all observers
  62773. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62774. * @param target defines the original target of the state
  62775. * @param currentTarget defines the current target of the state
  62776. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62777. */
  62778. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62779. /**
  62780. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62781. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62782. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62783. * and it is crucial that all callbacks will be executed.
  62784. * The order of the callbacks is kept, callbacks are not executed parallel.
  62785. *
  62786. * @param eventData The data to be sent to each callback
  62787. * @param mask is used to filter observers defaults to -1
  62788. * @param target defines the callback target (see EventState)
  62789. * @param currentTarget defines he current object in the bubbling phase
  62790. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62791. */
  62792. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62793. /**
  62794. * Notify a specific observer
  62795. * @param observer defines the observer to notify
  62796. * @param eventData defines the data to be sent to each callback
  62797. * @param mask is used to filter observers defaults to -1
  62798. */
  62799. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62800. /**
  62801. * Gets a boolean indicating if the observable has at least one observer
  62802. * @returns true is the Observable has at least one Observer registered
  62803. */
  62804. hasObservers(): boolean;
  62805. /**
  62806. * Clear the list of observers
  62807. */
  62808. clear(): void;
  62809. /**
  62810. * Clone the current observable
  62811. * @returns a new observable
  62812. */
  62813. clone(): Observable<T>;
  62814. /**
  62815. * Does this observable handles observer registered with a given mask
  62816. * @param mask defines the mask to be tested
  62817. * @return whether or not one observer registered with the given mask is handeled
  62818. **/
  62819. hasSpecificMask(mask?: number): boolean;
  62820. }
  62821. }
  62822. declare module BABYLON {
  62823. /**
  62824. * Class used to help managing file picking and drag'n'drop
  62825. * File Storage
  62826. */
  62827. export class FilesInputStore {
  62828. /**
  62829. * List of files ready to be loaded
  62830. */
  62831. static FilesToLoad: {
  62832. [key: string]: File;
  62833. };
  62834. }
  62835. }
  62836. declare module BABYLON {
  62837. /** Defines the cross module used constants to avoid circular dependncies */
  62838. export class Constants {
  62839. /** Defines that alpha blending is disabled */
  62840. static readonly ALPHA_DISABLE: number;
  62841. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62842. static readonly ALPHA_ADD: number;
  62843. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62844. static readonly ALPHA_COMBINE: number;
  62845. /** Defines that alpha blending to DEST - SRC * DEST */
  62846. static readonly ALPHA_SUBTRACT: number;
  62847. /** Defines that alpha blending to SRC * DEST */
  62848. static readonly ALPHA_MULTIPLY: number;
  62849. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62850. static readonly ALPHA_MAXIMIZED: number;
  62851. /** Defines that alpha blending to SRC + DEST */
  62852. static readonly ALPHA_ONEONE: number;
  62853. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62854. static readonly ALPHA_PREMULTIPLIED: number;
  62855. /**
  62856. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62857. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62858. */
  62859. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62860. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62861. static readonly ALPHA_INTERPOLATE: number;
  62862. /**
  62863. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62864. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62865. */
  62866. static readonly ALPHA_SCREENMODE: number;
  62867. /** Defines that the ressource is not delayed*/
  62868. static readonly DELAYLOADSTATE_NONE: number;
  62869. /** Defines that the ressource was successfully delay loaded */
  62870. static readonly DELAYLOADSTATE_LOADED: number;
  62871. /** Defines that the ressource is currently delay loading */
  62872. static readonly DELAYLOADSTATE_LOADING: number;
  62873. /** Defines that the ressource is delayed and has not started loading */
  62874. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62875. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62876. static readonly NEVER: number;
  62877. /** 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 */
  62878. static readonly ALWAYS: number;
  62879. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62880. static readonly LESS: number;
  62881. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62882. static readonly EQUAL: number;
  62883. /** 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 */
  62884. static readonly LEQUAL: number;
  62885. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62886. static readonly GREATER: number;
  62887. /** 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 */
  62888. static readonly GEQUAL: number;
  62889. /** 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 */
  62890. static readonly NOTEQUAL: number;
  62891. /** Passed to stencilOperation to specify that stencil value must be kept */
  62892. static readonly KEEP: number;
  62893. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62894. static readonly REPLACE: number;
  62895. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62896. static readonly INCR: number;
  62897. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62898. static readonly DECR: number;
  62899. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62900. static readonly INVERT: number;
  62901. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62902. static readonly INCR_WRAP: number;
  62903. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62904. static readonly DECR_WRAP: number;
  62905. /** Texture is not repeating outside of 0..1 UVs */
  62906. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62907. /** Texture is repeating outside of 0..1 UVs */
  62908. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62909. /** Texture is repeating and mirrored */
  62910. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62911. /** ALPHA */
  62912. static readonly TEXTUREFORMAT_ALPHA: number;
  62913. /** LUMINANCE */
  62914. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62915. /** LUMINANCE_ALPHA */
  62916. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62917. /** RGB */
  62918. static readonly TEXTUREFORMAT_RGB: number;
  62919. /** RGBA */
  62920. static readonly TEXTUREFORMAT_RGBA: number;
  62921. /** RED */
  62922. static readonly TEXTUREFORMAT_RED: number;
  62923. /** RED (2nd reference) */
  62924. static readonly TEXTUREFORMAT_R: number;
  62925. /** RG */
  62926. static readonly TEXTUREFORMAT_RG: number;
  62927. /** RED_INTEGER */
  62928. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62929. /** RED_INTEGER (2nd reference) */
  62930. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62931. /** RG_INTEGER */
  62932. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62933. /** RGB_INTEGER */
  62934. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62935. /** RGBA_INTEGER */
  62936. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62937. /** UNSIGNED_BYTE */
  62938. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62939. /** UNSIGNED_BYTE (2nd reference) */
  62940. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62941. /** FLOAT */
  62942. static readonly TEXTURETYPE_FLOAT: number;
  62943. /** HALF_FLOAT */
  62944. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62945. /** BYTE */
  62946. static readonly TEXTURETYPE_BYTE: number;
  62947. /** SHORT */
  62948. static readonly TEXTURETYPE_SHORT: number;
  62949. /** UNSIGNED_SHORT */
  62950. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62951. /** INT */
  62952. static readonly TEXTURETYPE_INT: number;
  62953. /** UNSIGNED_INT */
  62954. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62955. /** UNSIGNED_SHORT_4_4_4_4 */
  62956. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62957. /** UNSIGNED_SHORT_5_5_5_1 */
  62958. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62959. /** UNSIGNED_SHORT_5_6_5 */
  62960. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62961. /** UNSIGNED_INT_2_10_10_10_REV */
  62962. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62963. /** UNSIGNED_INT_24_8 */
  62964. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62965. /** UNSIGNED_INT_10F_11F_11F_REV */
  62966. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62967. /** UNSIGNED_INT_5_9_9_9_REV */
  62968. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62969. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62970. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62971. /** nearest is mag = nearest and min = nearest and mip = linear */
  62972. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62973. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62974. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62975. /** Trilinear is mag = linear and min = linear and mip = linear */
  62976. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62977. /** nearest is mag = nearest and min = nearest and mip = linear */
  62978. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62979. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62980. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62981. /** Trilinear is mag = linear and min = linear and mip = linear */
  62982. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62983. /** mag = nearest and min = nearest and mip = nearest */
  62984. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62985. /** mag = nearest and min = linear and mip = nearest */
  62986. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62987. /** mag = nearest and min = linear and mip = linear */
  62988. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62989. /** mag = nearest and min = linear and mip = none */
  62990. static readonly TEXTURE_NEAREST_LINEAR: number;
  62991. /** mag = nearest and min = nearest and mip = none */
  62992. static readonly TEXTURE_NEAREST_NEAREST: number;
  62993. /** mag = linear and min = nearest and mip = nearest */
  62994. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62995. /** mag = linear and min = nearest and mip = linear */
  62996. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62997. /** mag = linear and min = linear and mip = none */
  62998. static readonly TEXTURE_LINEAR_LINEAR: number;
  62999. /** mag = linear and min = nearest and mip = none */
  63000. static readonly TEXTURE_LINEAR_NEAREST: number;
  63001. /** Explicit coordinates mode */
  63002. static readonly TEXTURE_EXPLICIT_MODE: number;
  63003. /** Spherical coordinates mode */
  63004. static readonly TEXTURE_SPHERICAL_MODE: number;
  63005. /** Planar coordinates mode */
  63006. static readonly TEXTURE_PLANAR_MODE: number;
  63007. /** Cubic coordinates mode */
  63008. static readonly TEXTURE_CUBIC_MODE: number;
  63009. /** Projection coordinates mode */
  63010. static readonly TEXTURE_PROJECTION_MODE: number;
  63011. /** Skybox coordinates mode */
  63012. static readonly TEXTURE_SKYBOX_MODE: number;
  63013. /** Inverse Cubic coordinates mode */
  63014. static readonly TEXTURE_INVCUBIC_MODE: number;
  63015. /** Equirectangular coordinates mode */
  63016. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63017. /** Equirectangular Fixed coordinates mode */
  63018. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63019. /** Equirectangular Fixed Mirrored coordinates mode */
  63020. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63021. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63022. static readonly SCALEMODE_FLOOR: number;
  63023. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63024. static readonly SCALEMODE_NEAREST: number;
  63025. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63026. static readonly SCALEMODE_CEILING: number;
  63027. /**
  63028. * The dirty texture flag value
  63029. */
  63030. static readonly MATERIAL_TextureDirtyFlag: number;
  63031. /**
  63032. * The dirty light flag value
  63033. */
  63034. static readonly MATERIAL_LightDirtyFlag: number;
  63035. /**
  63036. * The dirty fresnel flag value
  63037. */
  63038. static readonly MATERIAL_FresnelDirtyFlag: number;
  63039. /**
  63040. * The dirty attribute flag value
  63041. */
  63042. static readonly MATERIAL_AttributesDirtyFlag: number;
  63043. /**
  63044. * The dirty misc flag value
  63045. */
  63046. static readonly MATERIAL_MiscDirtyFlag: number;
  63047. /**
  63048. * The all dirty flag value
  63049. */
  63050. static readonly MATERIAL_AllDirtyFlag: number;
  63051. /**
  63052. * Returns the triangle fill mode
  63053. */
  63054. static readonly MATERIAL_TriangleFillMode: number;
  63055. /**
  63056. * Returns the wireframe mode
  63057. */
  63058. static readonly MATERIAL_WireFrameFillMode: number;
  63059. /**
  63060. * Returns the point fill mode
  63061. */
  63062. static readonly MATERIAL_PointFillMode: number;
  63063. /**
  63064. * Returns the point list draw mode
  63065. */
  63066. static readonly MATERIAL_PointListDrawMode: number;
  63067. /**
  63068. * Returns the line list draw mode
  63069. */
  63070. static readonly MATERIAL_LineListDrawMode: number;
  63071. /**
  63072. * Returns the line loop draw mode
  63073. */
  63074. static readonly MATERIAL_LineLoopDrawMode: number;
  63075. /**
  63076. * Returns the line strip draw mode
  63077. */
  63078. static readonly MATERIAL_LineStripDrawMode: number;
  63079. /**
  63080. * Returns the triangle strip draw mode
  63081. */
  63082. static readonly MATERIAL_TriangleStripDrawMode: number;
  63083. /**
  63084. * Returns the triangle fan draw mode
  63085. */
  63086. static readonly MATERIAL_TriangleFanDrawMode: number;
  63087. /**
  63088. * Stores the clock-wise side orientation
  63089. */
  63090. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63091. /**
  63092. * Stores the counter clock-wise side orientation
  63093. */
  63094. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63095. /**
  63096. * Nothing
  63097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63098. */
  63099. static readonly ACTION_NothingTrigger: number;
  63100. /**
  63101. * On pick
  63102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63103. */
  63104. static readonly ACTION_OnPickTrigger: number;
  63105. /**
  63106. * On left pick
  63107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63108. */
  63109. static readonly ACTION_OnLeftPickTrigger: number;
  63110. /**
  63111. * On right pick
  63112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63113. */
  63114. static readonly ACTION_OnRightPickTrigger: number;
  63115. /**
  63116. * On center pick
  63117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63118. */
  63119. static readonly ACTION_OnCenterPickTrigger: number;
  63120. /**
  63121. * On pick down
  63122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63123. */
  63124. static readonly ACTION_OnPickDownTrigger: number;
  63125. /**
  63126. * On double pick
  63127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63128. */
  63129. static readonly ACTION_OnDoublePickTrigger: number;
  63130. /**
  63131. * On pick up
  63132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63133. */
  63134. static readonly ACTION_OnPickUpTrigger: number;
  63135. /**
  63136. * On pick out.
  63137. * This trigger will only be raised if you also declared a OnPickDown
  63138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63139. */
  63140. static readonly ACTION_OnPickOutTrigger: number;
  63141. /**
  63142. * On long press
  63143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63144. */
  63145. static readonly ACTION_OnLongPressTrigger: number;
  63146. /**
  63147. * On pointer over
  63148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63149. */
  63150. static readonly ACTION_OnPointerOverTrigger: number;
  63151. /**
  63152. * On pointer out
  63153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63154. */
  63155. static readonly ACTION_OnPointerOutTrigger: number;
  63156. /**
  63157. * On every frame
  63158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63159. */
  63160. static readonly ACTION_OnEveryFrameTrigger: number;
  63161. /**
  63162. * On intersection enter
  63163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63164. */
  63165. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63166. /**
  63167. * On intersection exit
  63168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63169. */
  63170. static readonly ACTION_OnIntersectionExitTrigger: number;
  63171. /**
  63172. * On key down
  63173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63174. */
  63175. static readonly ACTION_OnKeyDownTrigger: number;
  63176. /**
  63177. * On key up
  63178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63179. */
  63180. static readonly ACTION_OnKeyUpTrigger: number;
  63181. /**
  63182. * Billboard mode will only apply to Y axis
  63183. */
  63184. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63185. /**
  63186. * Billboard mode will apply to all axes
  63187. */
  63188. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63189. /**
  63190. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63191. */
  63192. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63193. /**
  63194. * Gets or sets base Assets URL
  63195. */
  63196. static readonly PARTICLES_BaseAssetsUrl: string;
  63197. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63198. * Test order :
  63199. * Is the bounding sphere outside the frustum ?
  63200. * If not, are the bounding box vertices outside the frustum ?
  63201. * It not, then the cullable object is in the frustum.
  63202. */
  63203. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63204. /** Culling strategy : Bounding Sphere Only.
  63205. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63206. * It's also less accurate than the standard because some not visible objects can still be selected.
  63207. * Test : is the bounding sphere outside the frustum ?
  63208. * If not, then the cullable object is in the frustum.
  63209. */
  63210. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63211. /** Culling strategy : Optimistic Inclusion.
  63212. * This in an inclusion test first, then the standard exclusion test.
  63213. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63214. * 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.
  63215. * Anyway, it's as accurate as the standard strategy.
  63216. * Test :
  63217. * Is the cullable object bounding sphere center in the frustum ?
  63218. * If not, apply the default culling strategy.
  63219. */
  63220. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63221. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63222. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63223. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63224. * 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.
  63225. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63226. * Test :
  63227. * Is the cullable object bounding sphere center in the frustum ?
  63228. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63229. */
  63230. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63231. /**
  63232. * No logging while loading
  63233. */
  63234. static readonly SCENELOADER_NO_LOGGING: number;
  63235. /**
  63236. * Minimal logging while loading
  63237. */
  63238. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63239. /**
  63240. * Summary logging while loading
  63241. */
  63242. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63243. /**
  63244. * Detailled logging while loading
  63245. */
  63246. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63247. }
  63248. }
  63249. declare module BABYLON {
  63250. /**
  63251. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63252. * Babylon.js
  63253. */
  63254. export class DomManagement {
  63255. /**
  63256. * Checks if the window object exists
  63257. * @returns true if the window object exists
  63258. */
  63259. static IsWindowObjectExist(): boolean;
  63260. /**
  63261. * Extracts text content from a DOM element hierarchy
  63262. * @param element defines the root element
  63263. * @returns a string
  63264. */
  63265. static GetDOMTextContent(element: HTMLElement): string;
  63266. }
  63267. }
  63268. declare module BABYLON {
  63269. /**
  63270. * Logger used througouht the application to allow configuration of
  63271. * the log level required for the messages.
  63272. */
  63273. export class Logger {
  63274. /**
  63275. * No log
  63276. */
  63277. static readonly NoneLogLevel: number;
  63278. /**
  63279. * Only message logs
  63280. */
  63281. static readonly MessageLogLevel: number;
  63282. /**
  63283. * Only warning logs
  63284. */
  63285. static readonly WarningLogLevel: number;
  63286. /**
  63287. * Only error logs
  63288. */
  63289. static readonly ErrorLogLevel: number;
  63290. /**
  63291. * All logs
  63292. */
  63293. static readonly AllLogLevel: number;
  63294. private static _LogCache;
  63295. /**
  63296. * Gets a value indicating the number of loading errors
  63297. * @ignorenaming
  63298. */
  63299. static errorsCount: number;
  63300. /**
  63301. * Callback called when a new log is added
  63302. */
  63303. static OnNewCacheEntry: (entry: string) => void;
  63304. private static _AddLogEntry;
  63305. private static _FormatMessage;
  63306. private static _LogDisabled;
  63307. private static _LogEnabled;
  63308. private static _WarnDisabled;
  63309. private static _WarnEnabled;
  63310. private static _ErrorDisabled;
  63311. private static _ErrorEnabled;
  63312. /**
  63313. * Log a message to the console
  63314. */
  63315. static Log: (message: string) => void;
  63316. /**
  63317. * Write a warning message to the console
  63318. */
  63319. static Warn: (message: string) => void;
  63320. /**
  63321. * Write an error message to the console
  63322. */
  63323. static Error: (message: string) => void;
  63324. /**
  63325. * Gets current log cache (list of logs)
  63326. */
  63327. static readonly LogCache: string;
  63328. /**
  63329. * Clears the log cache
  63330. */
  63331. static ClearLogCache(): void;
  63332. /**
  63333. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  63334. */
  63335. static LogLevels: number;
  63336. }
  63337. }
  63338. declare module BABYLON {
  63339. /** @hidden */
  63340. export class _TypeStore {
  63341. /** @hidden */
  63342. static RegisteredTypes: {
  63343. [key: string]: Object;
  63344. };
  63345. /** @hidden */
  63346. static GetClass(fqdn: string): any;
  63347. }
  63348. }
  63349. declare module BABYLON {
  63350. /**
  63351. * Class containing a set of static utilities functions for deep copy.
  63352. */
  63353. export class DeepCopier {
  63354. /**
  63355. * Tries to copy an object by duplicating every property
  63356. * @param source defines the source object
  63357. * @param destination defines the target object
  63358. * @param doNotCopyList defines a list of properties to avoid
  63359. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  63360. */
  63361. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  63362. }
  63363. }
  63364. declare module BABYLON {
  63365. /**
  63366. * Class containing a set of static utilities functions for precision date
  63367. */
  63368. export class PrecisionDate {
  63369. /**
  63370. * Gets either window.performance.now() if supported or Date.now() else
  63371. */
  63372. static readonly Now: number;
  63373. }
  63374. }
  63375. declare module BABYLON {
  63376. /** @hidden */
  63377. export class _DevTools {
  63378. static WarnImport(name: string): string;
  63379. }
  63380. }
  63381. declare module BABYLON {
  63382. /**
  63383. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  63384. */
  63385. export class WebRequest {
  63386. private _xhr;
  63387. /**
  63388. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  63389. * i.e. when loading files, where the server/service expects an Authorization header
  63390. */
  63391. static CustomRequestHeaders: {
  63392. [key: string]: string;
  63393. };
  63394. /**
  63395. * Add callback functions in this array to update all the requests before they get sent to the network
  63396. */
  63397. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  63398. private _injectCustomRequestHeaders;
  63399. /**
  63400. * Gets or sets a function to be called when loading progress changes
  63401. */
  63402. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  63403. /**
  63404. * Returns client's state
  63405. */
  63406. readonly readyState: number;
  63407. /**
  63408. * Returns client's status
  63409. */
  63410. readonly status: number;
  63411. /**
  63412. * Returns client's status as a text
  63413. */
  63414. readonly statusText: string;
  63415. /**
  63416. * Returns client's response
  63417. */
  63418. readonly response: any;
  63419. /**
  63420. * Returns client's response url
  63421. */
  63422. readonly responseURL: string;
  63423. /**
  63424. * Returns client's response as text
  63425. */
  63426. readonly responseText: string;
  63427. /**
  63428. * Gets or sets the expected response type
  63429. */
  63430. responseType: XMLHttpRequestResponseType;
  63431. /** @hidden */
  63432. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  63433. /** @hidden */
  63434. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  63435. /**
  63436. * Cancels any network activity
  63437. */
  63438. abort(): void;
  63439. /**
  63440. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  63441. * @param body defines an optional request body
  63442. */
  63443. send(body?: Document | BodyInit | null): void;
  63444. /**
  63445. * Sets the request method, request URL
  63446. * @param method defines the method to use (GET, POST, etc..)
  63447. * @param url defines the url to connect with
  63448. */
  63449. open(method: string, url: string): void;
  63450. }
  63451. }
  63452. declare module BABYLON {
  63453. /**
  63454. * Class used to evalaute queries containing `and` and `or` operators
  63455. */
  63456. export class AndOrNotEvaluator {
  63457. /**
  63458. * Evaluate a query
  63459. * @param query defines the query to evaluate
  63460. * @param evaluateCallback defines the callback used to filter result
  63461. * @returns true if the query matches
  63462. */
  63463. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  63464. private static _HandleParenthesisContent;
  63465. private static _SimplifyNegation;
  63466. }
  63467. }
  63468. declare module BABYLON {
  63469. /**
  63470. * Class used to store custom tags
  63471. */
  63472. export class Tags {
  63473. /**
  63474. * Adds support for tags on the given object
  63475. * @param obj defines the object to use
  63476. */
  63477. static EnableFor(obj: any): void;
  63478. /**
  63479. * Removes tags support
  63480. * @param obj defines the object to use
  63481. */
  63482. static DisableFor(obj: any): void;
  63483. /**
  63484. * Gets a boolean indicating if the given object has tags
  63485. * @param obj defines the object to use
  63486. * @returns a boolean
  63487. */
  63488. static HasTags(obj: any): boolean;
  63489. /**
  63490. * Gets the tags available on a given object
  63491. * @param obj defines the object to use
  63492. * @param asString defines if the tags must be returned as a string instead of an array of strings
  63493. * @returns the tags
  63494. */
  63495. static GetTags(obj: any, asString?: boolean): any;
  63496. /**
  63497. * Adds tags to an object
  63498. * @param obj defines the object to use
  63499. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  63500. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  63501. */
  63502. static AddTagsTo(obj: any, tagsString: string): void;
  63503. /**
  63504. * @hidden
  63505. */
  63506. static _AddTagTo(obj: any, tag: string): void;
  63507. /**
  63508. * Removes specific tags from a specific object
  63509. * @param obj defines the object to use
  63510. * @param tagsString defines the tags to remove
  63511. */
  63512. static RemoveTagsFrom(obj: any, tagsString: string): void;
  63513. /**
  63514. * @hidden
  63515. */
  63516. static _RemoveTagFrom(obj: any, tag: string): void;
  63517. /**
  63518. * Defines if tags hosted on an object match a given query
  63519. * @param obj defines the object to use
  63520. * @param tagsQuery defines the tag query
  63521. * @returns a boolean
  63522. */
  63523. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  63524. }
  63525. }
  63526. declare module BABYLON {
  63527. /**
  63528. * Manages the defines for the Material
  63529. */
  63530. export class MaterialDefines {
  63531. private _keys;
  63532. private _isDirty;
  63533. /** @hidden */
  63534. _renderId: number;
  63535. /** @hidden */
  63536. _areLightsDirty: boolean;
  63537. /** @hidden */
  63538. _areAttributesDirty: boolean;
  63539. /** @hidden */
  63540. _areTexturesDirty: boolean;
  63541. /** @hidden */
  63542. _areFresnelDirty: boolean;
  63543. /** @hidden */
  63544. _areMiscDirty: boolean;
  63545. /** @hidden */
  63546. _areImageProcessingDirty: boolean;
  63547. /** @hidden */
  63548. _normals: boolean;
  63549. /** @hidden */
  63550. _uvs: boolean;
  63551. /** @hidden */
  63552. _needNormals: boolean;
  63553. /** @hidden */
  63554. _needUVs: boolean;
  63555. /**
  63556. * Specifies if the material needs to be re-calculated
  63557. */
  63558. readonly isDirty: boolean;
  63559. /**
  63560. * Marks the material to indicate that it has been re-calculated
  63561. */
  63562. markAsProcessed(): void;
  63563. /**
  63564. * Marks the material to indicate that it needs to be re-calculated
  63565. */
  63566. markAsUnprocessed(): void;
  63567. /**
  63568. * Marks the material to indicate all of its defines need to be re-calculated
  63569. */
  63570. markAllAsDirty(): void;
  63571. /**
  63572. * Marks the material to indicate that image processing needs to be re-calculated
  63573. */
  63574. markAsImageProcessingDirty(): void;
  63575. /**
  63576. * Marks the material to indicate the lights need to be re-calculated
  63577. */
  63578. markAsLightDirty(): void;
  63579. /**
  63580. * Marks the attribute state as changed
  63581. */
  63582. markAsAttributesDirty(): void;
  63583. /**
  63584. * Marks the texture state as changed
  63585. */
  63586. markAsTexturesDirty(): void;
  63587. /**
  63588. * Marks the fresnel state as changed
  63589. */
  63590. markAsFresnelDirty(): void;
  63591. /**
  63592. * Marks the misc state as changed
  63593. */
  63594. markAsMiscDirty(): void;
  63595. /**
  63596. * Rebuilds the material defines
  63597. */
  63598. rebuild(): void;
  63599. /**
  63600. * Specifies if two material defines are equal
  63601. * @param other - A material define instance to compare to
  63602. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63603. */
  63604. isEqual(other: MaterialDefines): boolean;
  63605. /**
  63606. * Clones this instance's defines to another instance
  63607. * @param other - material defines to clone values to
  63608. */
  63609. cloneTo(other: MaterialDefines): void;
  63610. /**
  63611. * Resets the material define values
  63612. */
  63613. reset(): void;
  63614. /**
  63615. * Converts the material define values to a string
  63616. * @returns - String of material define information
  63617. */
  63618. toString(): string;
  63619. }
  63620. }
  63621. declare module BABYLON {
  63622. /**
  63623. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63624. */
  63625. export class PerformanceMonitor {
  63626. private _enabled;
  63627. private _rollingFrameTime;
  63628. private _lastFrameTimeMs;
  63629. /**
  63630. * constructor
  63631. * @param frameSampleSize The number of samples required to saturate the sliding window
  63632. */
  63633. constructor(frameSampleSize?: number);
  63634. /**
  63635. * Samples current frame
  63636. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63637. */
  63638. sampleFrame(timeMs?: number): void;
  63639. /**
  63640. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63641. */
  63642. readonly averageFrameTime: number;
  63643. /**
  63644. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63645. */
  63646. readonly averageFrameTimeVariance: number;
  63647. /**
  63648. * Returns the frame time of the most recent frame
  63649. */
  63650. readonly instantaneousFrameTime: number;
  63651. /**
  63652. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63653. */
  63654. readonly averageFPS: number;
  63655. /**
  63656. * Returns the average framerate in frames per second using the most recent frame time
  63657. */
  63658. readonly instantaneousFPS: number;
  63659. /**
  63660. * Returns true if enough samples have been taken to completely fill the sliding window
  63661. */
  63662. readonly isSaturated: boolean;
  63663. /**
  63664. * Enables contributions to the sliding window sample set
  63665. */
  63666. enable(): void;
  63667. /**
  63668. * Disables contributions to the sliding window sample set
  63669. * Samples will not be interpolated over the disabled period
  63670. */
  63671. disable(): void;
  63672. /**
  63673. * Returns true if sampling is enabled
  63674. */
  63675. readonly isEnabled: boolean;
  63676. /**
  63677. * Resets performance monitor
  63678. */
  63679. reset(): void;
  63680. }
  63681. /**
  63682. * RollingAverage
  63683. *
  63684. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63685. */
  63686. export class RollingAverage {
  63687. /**
  63688. * Current average
  63689. */
  63690. average: number;
  63691. /**
  63692. * Current variance
  63693. */
  63694. variance: number;
  63695. protected _samples: Array<number>;
  63696. protected _sampleCount: number;
  63697. protected _pos: number;
  63698. protected _m2: number;
  63699. /**
  63700. * constructor
  63701. * @param length The number of samples required to saturate the sliding window
  63702. */
  63703. constructor(length: number);
  63704. /**
  63705. * Adds a sample to the sample set
  63706. * @param v The sample value
  63707. */
  63708. add(v: number): void;
  63709. /**
  63710. * Returns previously added values or null if outside of history or outside the sliding window domain
  63711. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63712. * @return Value previously recorded with add() or null if outside of range
  63713. */
  63714. history(i: number): number;
  63715. /**
  63716. * Returns true if enough samples have been taken to completely fill the sliding window
  63717. * @return true if sample-set saturated
  63718. */
  63719. isSaturated(): boolean;
  63720. /**
  63721. * Resets the rolling average (equivalent to 0 samples taken so far)
  63722. */
  63723. reset(): void;
  63724. /**
  63725. * Wraps a value around the sample range boundaries
  63726. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63727. * @return Wrapped position in sample range
  63728. */
  63729. protected _wrapPosition(i: number): number;
  63730. }
  63731. }
  63732. declare module BABYLON {
  63733. /**
  63734. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63735. * The underlying implementation relies on an associative array to ensure the best performances.
  63736. * The value can be anything including 'null' but except 'undefined'
  63737. */
  63738. export class StringDictionary<T> {
  63739. /**
  63740. * This will clear this dictionary and copy the content from the 'source' one.
  63741. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63742. * @param source the dictionary to take the content from and copy to this dictionary
  63743. */
  63744. copyFrom(source: StringDictionary<T>): void;
  63745. /**
  63746. * Get a value based from its key
  63747. * @param key the given key to get the matching value from
  63748. * @return the value if found, otherwise undefined is returned
  63749. */
  63750. get(key: string): T | undefined;
  63751. /**
  63752. * Get a value from its key or add it if it doesn't exist.
  63753. * This method will ensure you that a given key/data will be present in the dictionary.
  63754. * @param key the given key to get the matching value from
  63755. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63756. * The factory will only be invoked if there's no data for the given key.
  63757. * @return the value corresponding to the key.
  63758. */
  63759. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63760. /**
  63761. * Get a value from its key if present in the dictionary otherwise add it
  63762. * @param key the key to get the value from
  63763. * @param val if there's no such key/value pair in the dictionary add it with this value
  63764. * @return the value corresponding to the key
  63765. */
  63766. getOrAdd(key: string, val: T): T;
  63767. /**
  63768. * Check if there's a given key in the dictionary
  63769. * @param key the key to check for
  63770. * @return true if the key is present, false otherwise
  63771. */
  63772. contains(key: string): boolean;
  63773. /**
  63774. * Add a new key and its corresponding value
  63775. * @param key the key to add
  63776. * @param value the value corresponding to the key
  63777. * @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
  63778. */
  63779. add(key: string, value: T): boolean;
  63780. /**
  63781. * Update a specific value associated to a key
  63782. * @param key defines the key to use
  63783. * @param value defines the value to store
  63784. * @returns true if the value was updated (or false if the key was not found)
  63785. */
  63786. set(key: string, value: T): boolean;
  63787. /**
  63788. * Get the element of the given key and remove it from the dictionary
  63789. * @param key defines the key to search
  63790. * @returns the value associated with the key or null if not found
  63791. */
  63792. getAndRemove(key: string): Nullable<T>;
  63793. /**
  63794. * Remove a key/value from the dictionary.
  63795. * @param key the key to remove
  63796. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63797. */
  63798. remove(key: string): boolean;
  63799. /**
  63800. * Clear the whole content of the dictionary
  63801. */
  63802. clear(): void;
  63803. /**
  63804. * Gets the current count
  63805. */
  63806. readonly count: number;
  63807. /**
  63808. * Execute a callback on each key/val of the dictionary.
  63809. * Note that you can remove any element in this dictionary in the callback implementation
  63810. * @param callback the callback to execute on a given key/value pair
  63811. */
  63812. forEach(callback: (key: string, val: T) => void): void;
  63813. /**
  63814. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63815. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63816. * Note that you can remove any element in this dictionary in the callback implementation
  63817. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63818. * @returns the first item
  63819. */
  63820. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63821. private _count;
  63822. private _data;
  63823. }
  63824. }
  63825. declare module BABYLON {
  63826. /**
  63827. * Helper class that provides a small promise polyfill
  63828. */
  63829. export class PromisePolyfill {
  63830. /**
  63831. * Static function used to check if the polyfill is required
  63832. * If this is the case then the function will inject the polyfill to window.Promise
  63833. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63834. */
  63835. static Apply(force?: boolean): void;
  63836. }
  63837. }
  63838. declare module BABYLON {
  63839. /**
  63840. * Class used to store data that will be store in GPU memory
  63841. */
  63842. export class Buffer {
  63843. private _engine;
  63844. private _buffer;
  63845. /** @hidden */
  63846. _data: Nullable<DataArray>;
  63847. private _updatable;
  63848. private _instanced;
  63849. /**
  63850. * Gets the byte stride.
  63851. */
  63852. readonly byteStride: number;
  63853. /**
  63854. * Constructor
  63855. * @param engine the engine
  63856. * @param data the data to use for this buffer
  63857. * @param updatable whether the data is updatable
  63858. * @param stride the stride (optional)
  63859. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63860. * @param instanced whether the buffer is instanced (optional)
  63861. * @param useBytes set to true if the stride in in bytes (optional)
  63862. */
  63863. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63864. /**
  63865. * Create a new VertexBuffer based on the current buffer
  63866. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63867. * @param offset defines offset in the buffer (0 by default)
  63868. * @param size defines the size in floats of attributes (position is 3 for instance)
  63869. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63870. * @param instanced defines if the vertex buffer contains indexed data
  63871. * @param useBytes defines if the offset and stride are in bytes
  63872. * @returns the new vertex buffer
  63873. */
  63874. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63875. /**
  63876. * Gets a boolean indicating if the Buffer is updatable?
  63877. * @returns true if the buffer is updatable
  63878. */
  63879. isUpdatable(): boolean;
  63880. /**
  63881. * Gets current buffer's data
  63882. * @returns a DataArray or null
  63883. */
  63884. getData(): Nullable<DataArray>;
  63885. /**
  63886. * Gets underlying native buffer
  63887. * @returns underlying native buffer
  63888. */
  63889. getBuffer(): Nullable<WebGLBuffer>;
  63890. /**
  63891. * Gets the stride in float32 units (i.e. byte stride / 4).
  63892. * May not be an integer if the byte stride is not divisible by 4.
  63893. * DEPRECATED. Use byteStride instead.
  63894. * @returns the stride in float32 units
  63895. */
  63896. getStrideSize(): number;
  63897. /**
  63898. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63899. * @param data defines the data to store
  63900. */
  63901. create(data?: Nullable<DataArray>): void;
  63902. /** @hidden */
  63903. _rebuild(): void;
  63904. /**
  63905. * Update current buffer data
  63906. * @param data defines the data to store
  63907. */
  63908. update(data: DataArray): void;
  63909. /**
  63910. * Updates the data directly.
  63911. * @param data the new data
  63912. * @param offset the new offset
  63913. * @param vertexCount the vertex count (optional)
  63914. * @param useBytes set to true if the offset is in bytes
  63915. */
  63916. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63917. /**
  63918. * Release all resources
  63919. */
  63920. dispose(): void;
  63921. }
  63922. /**
  63923. * Specialized buffer used to store vertex data
  63924. */
  63925. export class VertexBuffer {
  63926. /** @hidden */
  63927. _buffer: Buffer;
  63928. private _kind;
  63929. private _size;
  63930. private _ownsBuffer;
  63931. private _instanced;
  63932. private _instanceDivisor;
  63933. /**
  63934. * The byte type.
  63935. */
  63936. static readonly BYTE: number;
  63937. /**
  63938. * The unsigned byte type.
  63939. */
  63940. static readonly UNSIGNED_BYTE: number;
  63941. /**
  63942. * The short type.
  63943. */
  63944. static readonly SHORT: number;
  63945. /**
  63946. * The unsigned short type.
  63947. */
  63948. static readonly UNSIGNED_SHORT: number;
  63949. /**
  63950. * The integer type.
  63951. */
  63952. static readonly INT: number;
  63953. /**
  63954. * The unsigned integer type.
  63955. */
  63956. static readonly UNSIGNED_INT: number;
  63957. /**
  63958. * The float type.
  63959. */
  63960. static readonly FLOAT: number;
  63961. /**
  63962. * Gets or sets the instance divisor when in instanced mode
  63963. */
  63964. instanceDivisor: number;
  63965. /**
  63966. * Gets the byte stride.
  63967. */
  63968. readonly byteStride: number;
  63969. /**
  63970. * Gets the byte offset.
  63971. */
  63972. readonly byteOffset: number;
  63973. /**
  63974. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63975. */
  63976. readonly normalized: boolean;
  63977. /**
  63978. * Gets the data type of each component in the array.
  63979. */
  63980. readonly type: number;
  63981. /**
  63982. * Constructor
  63983. * @param engine the engine
  63984. * @param data the data to use for this vertex buffer
  63985. * @param kind the vertex buffer kind
  63986. * @param updatable whether the data is updatable
  63987. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63988. * @param stride the stride (optional)
  63989. * @param instanced whether the buffer is instanced (optional)
  63990. * @param offset the offset of the data (optional)
  63991. * @param size the number of components (optional)
  63992. * @param type the type of the component (optional)
  63993. * @param normalized whether the data contains normalized data (optional)
  63994. * @param useBytes set to true if stride and offset are in bytes (optional)
  63995. */
  63996. 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);
  63997. /** @hidden */
  63998. _rebuild(): void;
  63999. /**
  64000. * Returns the kind of the VertexBuffer (string)
  64001. * @returns a string
  64002. */
  64003. getKind(): string;
  64004. /**
  64005. * Gets a boolean indicating if the VertexBuffer is updatable?
  64006. * @returns true if the buffer is updatable
  64007. */
  64008. isUpdatable(): boolean;
  64009. /**
  64010. * Gets current buffer's data
  64011. * @returns a DataArray or null
  64012. */
  64013. getData(): Nullable<DataArray>;
  64014. /**
  64015. * Gets underlying native buffer
  64016. * @returns underlying native buffer
  64017. */
  64018. getBuffer(): Nullable<WebGLBuffer>;
  64019. /**
  64020. * Gets the stride in float32 units (i.e. byte stride / 4).
  64021. * May not be an integer if the byte stride is not divisible by 4.
  64022. * DEPRECATED. Use byteStride instead.
  64023. * @returns the stride in float32 units
  64024. */
  64025. getStrideSize(): number;
  64026. /**
  64027. * Returns the offset as a multiple of the type byte length.
  64028. * DEPRECATED. Use byteOffset instead.
  64029. * @returns the offset in bytes
  64030. */
  64031. getOffset(): number;
  64032. /**
  64033. * Returns the number of components per vertex attribute (integer)
  64034. * @returns the size in float
  64035. */
  64036. getSize(): number;
  64037. /**
  64038. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64039. * @returns true if this buffer is instanced
  64040. */
  64041. getIsInstanced(): boolean;
  64042. /**
  64043. * Returns the instancing divisor, zero for non-instanced (integer).
  64044. * @returns a number
  64045. */
  64046. getInstanceDivisor(): number;
  64047. /**
  64048. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64049. * @param data defines the data to store
  64050. */
  64051. create(data?: DataArray): void;
  64052. /**
  64053. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64054. * This function will create a new buffer if the current one is not updatable
  64055. * @param data defines the data to store
  64056. */
  64057. update(data: DataArray): void;
  64058. /**
  64059. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64060. * Returns the directly updated WebGLBuffer.
  64061. * @param data the new data
  64062. * @param offset the new offset
  64063. * @param useBytes set to true if the offset is in bytes
  64064. */
  64065. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64066. /**
  64067. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64068. */
  64069. dispose(): void;
  64070. /**
  64071. * Enumerates each value of this vertex buffer as numbers.
  64072. * @param count the number of values to enumerate
  64073. * @param callback the callback function called for each value
  64074. */
  64075. forEach(count: number, callback: (value: number, index: number) => void): void;
  64076. /**
  64077. * Positions
  64078. */
  64079. static readonly PositionKind: string;
  64080. /**
  64081. * Normals
  64082. */
  64083. static readonly NormalKind: string;
  64084. /**
  64085. * Tangents
  64086. */
  64087. static readonly TangentKind: string;
  64088. /**
  64089. * Texture coordinates
  64090. */
  64091. static readonly UVKind: string;
  64092. /**
  64093. * Texture coordinates 2
  64094. */
  64095. static readonly UV2Kind: string;
  64096. /**
  64097. * Texture coordinates 3
  64098. */
  64099. static readonly UV3Kind: string;
  64100. /**
  64101. * Texture coordinates 4
  64102. */
  64103. static readonly UV4Kind: string;
  64104. /**
  64105. * Texture coordinates 5
  64106. */
  64107. static readonly UV5Kind: string;
  64108. /**
  64109. * Texture coordinates 6
  64110. */
  64111. static readonly UV6Kind: string;
  64112. /**
  64113. * Colors
  64114. */
  64115. static readonly ColorKind: string;
  64116. /**
  64117. * Matrix indices (for bones)
  64118. */
  64119. static readonly MatricesIndicesKind: string;
  64120. /**
  64121. * Matrix weights (for bones)
  64122. */
  64123. static readonly MatricesWeightsKind: string;
  64124. /**
  64125. * Additional matrix indices (for bones)
  64126. */
  64127. static readonly MatricesIndicesExtraKind: string;
  64128. /**
  64129. * Additional matrix weights (for bones)
  64130. */
  64131. static readonly MatricesWeightsExtraKind: string;
  64132. /**
  64133. * Deduces the stride given a kind.
  64134. * @param kind The kind string to deduce
  64135. * @returns The deduced stride
  64136. */
  64137. static DeduceStride(kind: string): number;
  64138. /**
  64139. * Gets the byte length of the given type.
  64140. * @param type the type
  64141. * @returns the number of bytes
  64142. */
  64143. static GetTypeByteLength(type: number): number;
  64144. /**
  64145. * Enumerates each value of the given parameters as numbers.
  64146. * @param data the data to enumerate
  64147. * @param byteOffset the byte offset of the data
  64148. * @param byteStride the byte stride of the data
  64149. * @param componentCount the number of components per element
  64150. * @param componentType the type of the component
  64151. * @param count the total number of components
  64152. * @param normalized whether the data is normalized
  64153. * @param callback the callback function called for each value
  64154. */
  64155. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64156. private static _GetFloatValue;
  64157. }
  64158. }
  64159. declare module BABYLON {
  64160. /**
  64161. * Class representing spherical polynomial coefficients to the 3rd degree
  64162. */
  64163. export class SphericalPolynomial {
  64164. /**
  64165. * The x coefficients of the spherical polynomial
  64166. */
  64167. x: Vector3;
  64168. /**
  64169. * The y coefficients of the spherical polynomial
  64170. */
  64171. y: Vector3;
  64172. /**
  64173. * The z coefficients of the spherical polynomial
  64174. */
  64175. z: Vector3;
  64176. /**
  64177. * The xx coefficients of the spherical polynomial
  64178. */
  64179. xx: Vector3;
  64180. /**
  64181. * The yy coefficients of the spherical polynomial
  64182. */
  64183. yy: Vector3;
  64184. /**
  64185. * The zz coefficients of the spherical polynomial
  64186. */
  64187. zz: Vector3;
  64188. /**
  64189. * The xy coefficients of the spherical polynomial
  64190. */
  64191. xy: Vector3;
  64192. /**
  64193. * The yz coefficients of the spherical polynomial
  64194. */
  64195. yz: Vector3;
  64196. /**
  64197. * The zx coefficients of the spherical polynomial
  64198. */
  64199. zx: Vector3;
  64200. /**
  64201. * Adds an ambient color to the spherical polynomial
  64202. * @param color the color to add
  64203. */
  64204. addAmbient(color: Color3): void;
  64205. /**
  64206. * Scales the spherical polynomial by the given amount
  64207. * @param scale the amount to scale
  64208. */
  64209. scale(scale: number): void;
  64210. /**
  64211. * Gets the spherical polynomial from harmonics
  64212. * @param harmonics the spherical harmonics
  64213. * @returns the spherical polynomial
  64214. */
  64215. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64216. /**
  64217. * Constructs a spherical polynomial from an array.
  64218. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64219. * @returns the spherical polynomial
  64220. */
  64221. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64222. }
  64223. /**
  64224. * Class representing spherical harmonics coefficients to the 3rd degree
  64225. */
  64226. export class SphericalHarmonics {
  64227. /**
  64228. * The l0,0 coefficients of the spherical harmonics
  64229. */
  64230. l00: Vector3;
  64231. /**
  64232. * The l1,-1 coefficients of the spherical harmonics
  64233. */
  64234. l1_1: Vector3;
  64235. /**
  64236. * The l1,0 coefficients of the spherical harmonics
  64237. */
  64238. l10: Vector3;
  64239. /**
  64240. * The l1,1 coefficients of the spherical harmonics
  64241. */
  64242. l11: Vector3;
  64243. /**
  64244. * The l2,-2 coefficients of the spherical harmonics
  64245. */
  64246. l2_2: Vector3;
  64247. /**
  64248. * The l2,-1 coefficients of the spherical harmonics
  64249. */
  64250. l2_1: Vector3;
  64251. /**
  64252. * The l2,0 coefficients of the spherical harmonics
  64253. */
  64254. l20: Vector3;
  64255. /**
  64256. * The l2,1 coefficients of the spherical harmonics
  64257. */
  64258. l21: Vector3;
  64259. /**
  64260. * The l2,2 coefficients of the spherical harmonics
  64261. */
  64262. lL22: Vector3;
  64263. /**
  64264. * Adds a light to the spherical harmonics
  64265. * @param direction the direction of the light
  64266. * @param color the color of the light
  64267. * @param deltaSolidAngle the delta solid angle of the light
  64268. */
  64269. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64270. /**
  64271. * Scales the spherical harmonics by the given amount
  64272. * @param scale the amount to scale
  64273. */
  64274. scale(scale: number): void;
  64275. /**
  64276. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64277. *
  64278. * ```
  64279. * E_lm = A_l * L_lm
  64280. * ```
  64281. *
  64282. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64283. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64284. * the scaling factors are given in equation 9.
  64285. */
  64286. convertIncidentRadianceToIrradiance(): void;
  64287. /**
  64288. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64289. *
  64290. * ```
  64291. * L = (1/pi) * E * rho
  64292. * ```
  64293. *
  64294. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64295. */
  64296. convertIrradianceToLambertianRadiance(): void;
  64297. /**
  64298. * Gets the spherical harmonics from polynomial
  64299. * @param polynomial the spherical polynomial
  64300. * @returns the spherical harmonics
  64301. */
  64302. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  64303. /**
  64304. * Constructs a spherical harmonics from an array.
  64305. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  64306. * @returns the spherical harmonics
  64307. */
  64308. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  64309. }
  64310. }
  64311. declare module BABYLON {
  64312. /**
  64313. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  64314. */
  64315. export interface CubeMapInfo {
  64316. /**
  64317. * The pixel array for the front face.
  64318. * This is stored in format, left to right, up to down format.
  64319. */
  64320. front: Nullable<ArrayBufferView>;
  64321. /**
  64322. * The pixel array for the back face.
  64323. * This is stored in format, left to right, up to down format.
  64324. */
  64325. back: Nullable<ArrayBufferView>;
  64326. /**
  64327. * The pixel array for the left face.
  64328. * This is stored in format, left to right, up to down format.
  64329. */
  64330. left: Nullable<ArrayBufferView>;
  64331. /**
  64332. * The pixel array for the right face.
  64333. * This is stored in format, left to right, up to down format.
  64334. */
  64335. right: Nullable<ArrayBufferView>;
  64336. /**
  64337. * The pixel array for the up face.
  64338. * This is stored in format, left to right, up to down format.
  64339. */
  64340. up: Nullable<ArrayBufferView>;
  64341. /**
  64342. * The pixel array for the down face.
  64343. * This is stored in format, left to right, up to down format.
  64344. */
  64345. down: Nullable<ArrayBufferView>;
  64346. /**
  64347. * The size of the cubemap stored.
  64348. *
  64349. * Each faces will be size * size pixels.
  64350. */
  64351. size: number;
  64352. /**
  64353. * The format of the texture.
  64354. *
  64355. * RGBA, RGB.
  64356. */
  64357. format: number;
  64358. /**
  64359. * The type of the texture data.
  64360. *
  64361. * UNSIGNED_INT, FLOAT.
  64362. */
  64363. type: number;
  64364. /**
  64365. * Specifies whether the texture is in gamma space.
  64366. */
  64367. gammaSpace: boolean;
  64368. }
  64369. /**
  64370. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  64371. */
  64372. export class PanoramaToCubeMapTools {
  64373. private static FACE_FRONT;
  64374. private static FACE_BACK;
  64375. private static FACE_RIGHT;
  64376. private static FACE_LEFT;
  64377. private static FACE_DOWN;
  64378. private static FACE_UP;
  64379. /**
  64380. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  64381. *
  64382. * @param float32Array The source data.
  64383. * @param inputWidth The width of the input panorama.
  64384. * @param inputHeight The height of the input panorama.
  64385. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  64386. * @return The cubemap data
  64387. */
  64388. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  64389. private static CreateCubemapTexture;
  64390. private static CalcProjectionSpherical;
  64391. }
  64392. }
  64393. declare module BABYLON {
  64394. /**
  64395. * Helper class dealing with the extraction of spherical polynomial dataArray
  64396. * from a cube map.
  64397. */
  64398. export class CubeMapToSphericalPolynomialTools {
  64399. private static FileFaces;
  64400. /**
  64401. * Converts a texture to the according Spherical Polynomial data.
  64402. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64403. *
  64404. * @param texture The texture to extract the information from.
  64405. * @return The Spherical Polynomial data.
  64406. */
  64407. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  64408. /**
  64409. * Converts a cubemap to the according Spherical Polynomial data.
  64410. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64411. *
  64412. * @param cubeInfo The Cube map to extract the information from.
  64413. * @return The Spherical Polynomial data.
  64414. */
  64415. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  64416. }
  64417. }
  64418. declare module BABYLON {
  64419. /**
  64420. * The engine store class is responsible to hold all the instances of Engine and Scene created
  64421. * during the life time of the application.
  64422. */
  64423. export class EngineStore {
  64424. /** Gets the list of created engines */
  64425. static Instances: Engine[];
  64426. /**
  64427. * Gets the latest created engine
  64428. */
  64429. static readonly LastCreatedEngine: Nullable<Engine>;
  64430. /**
  64431. * Gets the latest created scene
  64432. */
  64433. static readonly LastCreatedScene: Nullable<Scene>;
  64434. }
  64435. }
  64436. declare module BABYLON {
  64437. /**
  64438. * Define options used to create a render target texture
  64439. */
  64440. export class RenderTargetCreationOptions {
  64441. /**
  64442. * Specifies is mipmaps must be generated
  64443. */
  64444. generateMipMaps?: boolean;
  64445. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  64446. generateDepthBuffer?: boolean;
  64447. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  64448. generateStencilBuffer?: boolean;
  64449. /** Defines texture type (int by default) */
  64450. type?: number;
  64451. /** Defines sampling mode (trilinear by default) */
  64452. samplingMode?: number;
  64453. /** Defines format (RGBA by default) */
  64454. format?: number;
  64455. }
  64456. }
  64457. declare module BABYLON {
  64458. /**
  64459. * @hidden
  64460. **/
  64461. export class _AlphaState {
  64462. private _isAlphaBlendDirty;
  64463. private _isBlendFunctionParametersDirty;
  64464. private _isBlendEquationParametersDirty;
  64465. private _isBlendConstantsDirty;
  64466. private _alphaBlend;
  64467. private _blendFunctionParameters;
  64468. private _blendEquationParameters;
  64469. private _blendConstants;
  64470. /**
  64471. * Initializes the state.
  64472. */
  64473. constructor();
  64474. readonly isDirty: boolean;
  64475. alphaBlend: boolean;
  64476. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  64477. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  64478. setAlphaEquationParameters(rgb: number, alpha: number): void;
  64479. reset(): void;
  64480. apply(gl: WebGLRenderingContext): void;
  64481. }
  64482. }
  64483. declare module BABYLON {
  64484. /**
  64485. * @hidden
  64486. **/
  64487. export class _DepthCullingState {
  64488. private _isDepthTestDirty;
  64489. private _isDepthMaskDirty;
  64490. private _isDepthFuncDirty;
  64491. private _isCullFaceDirty;
  64492. private _isCullDirty;
  64493. private _isZOffsetDirty;
  64494. private _isFrontFaceDirty;
  64495. private _depthTest;
  64496. private _depthMask;
  64497. private _depthFunc;
  64498. private _cull;
  64499. private _cullFace;
  64500. private _zOffset;
  64501. private _frontFace;
  64502. /**
  64503. * Initializes the state.
  64504. */
  64505. constructor();
  64506. readonly isDirty: boolean;
  64507. zOffset: number;
  64508. cullFace: Nullable<number>;
  64509. cull: Nullable<boolean>;
  64510. depthFunc: Nullable<number>;
  64511. depthMask: boolean;
  64512. depthTest: boolean;
  64513. frontFace: Nullable<number>;
  64514. reset(): void;
  64515. apply(gl: WebGLRenderingContext): void;
  64516. }
  64517. }
  64518. declare module BABYLON {
  64519. /**
  64520. * @hidden
  64521. **/
  64522. export class _StencilState {
  64523. /** 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 */
  64524. static readonly ALWAYS: number;
  64525. /** Passed to stencilOperation to specify that stencil value must be kept */
  64526. static readonly KEEP: number;
  64527. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64528. static readonly REPLACE: number;
  64529. private _isStencilTestDirty;
  64530. private _isStencilMaskDirty;
  64531. private _isStencilFuncDirty;
  64532. private _isStencilOpDirty;
  64533. private _stencilTest;
  64534. private _stencilMask;
  64535. private _stencilFunc;
  64536. private _stencilFuncRef;
  64537. private _stencilFuncMask;
  64538. private _stencilOpStencilFail;
  64539. private _stencilOpDepthFail;
  64540. private _stencilOpStencilDepthPass;
  64541. readonly isDirty: boolean;
  64542. stencilFunc: number;
  64543. stencilFuncRef: number;
  64544. stencilFuncMask: number;
  64545. stencilOpStencilFail: number;
  64546. stencilOpDepthFail: number;
  64547. stencilOpStencilDepthPass: number;
  64548. stencilMask: number;
  64549. stencilTest: boolean;
  64550. constructor();
  64551. reset(): void;
  64552. apply(gl: WebGLRenderingContext): void;
  64553. }
  64554. }
  64555. declare module BABYLON {
  64556. /**
  64557. * @hidden
  64558. **/
  64559. export class _TimeToken {
  64560. _startTimeQuery: Nullable<WebGLQuery>;
  64561. _endTimeQuery: Nullable<WebGLQuery>;
  64562. _timeElapsedQuery: Nullable<WebGLQuery>;
  64563. _timeElapsedQueryEnded: boolean;
  64564. }
  64565. }
  64566. declare module BABYLON {
  64567. /**
  64568. * Internal interface used to track InternalTexture already bound to the GL context
  64569. */
  64570. export interface IInternalTextureTracker {
  64571. /**
  64572. * Gets or set the previous tracker in the list
  64573. */
  64574. previous: Nullable<IInternalTextureTracker>;
  64575. /**
  64576. * Gets or set the next tracker in the list
  64577. */
  64578. next: Nullable<IInternalTextureTracker>;
  64579. }
  64580. /**
  64581. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  64582. */
  64583. export class DummyInternalTextureTracker {
  64584. /**
  64585. * Gets or set the previous tracker in the list
  64586. */
  64587. previous: Nullable<IInternalTextureTracker>;
  64588. /**
  64589. * Gets or set the next tracker in the list
  64590. */
  64591. next: Nullable<IInternalTextureTracker>;
  64592. }
  64593. }
  64594. declare module BABYLON {
  64595. /**
  64596. * Class used to store data associated with WebGL texture data for the engine
  64597. * This class should not be used directly
  64598. */
  64599. export class InternalTexture implements IInternalTextureTracker {
  64600. /** hidden */
  64601. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  64602. /**
  64603. * The source of the texture data is unknown
  64604. */
  64605. static DATASOURCE_UNKNOWN: number;
  64606. /**
  64607. * Texture data comes from an URL
  64608. */
  64609. static DATASOURCE_URL: number;
  64610. /**
  64611. * Texture data is only used for temporary storage
  64612. */
  64613. static DATASOURCE_TEMP: number;
  64614. /**
  64615. * Texture data comes from raw data (ArrayBuffer)
  64616. */
  64617. static DATASOURCE_RAW: number;
  64618. /**
  64619. * Texture content is dynamic (video or dynamic texture)
  64620. */
  64621. static DATASOURCE_DYNAMIC: number;
  64622. /**
  64623. * Texture content is generated by rendering to it
  64624. */
  64625. static DATASOURCE_RENDERTARGET: number;
  64626. /**
  64627. * Texture content is part of a multi render target process
  64628. */
  64629. static DATASOURCE_MULTIRENDERTARGET: number;
  64630. /**
  64631. * Texture data comes from a cube data file
  64632. */
  64633. static DATASOURCE_CUBE: number;
  64634. /**
  64635. * Texture data comes from a raw cube data
  64636. */
  64637. static DATASOURCE_CUBERAW: number;
  64638. /**
  64639. * Texture data come from a prefiltered cube data file
  64640. */
  64641. static DATASOURCE_CUBEPREFILTERED: number;
  64642. /**
  64643. * Texture content is raw 3D data
  64644. */
  64645. static DATASOURCE_RAW3D: number;
  64646. /**
  64647. * Texture content is a depth texture
  64648. */
  64649. static DATASOURCE_DEPTHTEXTURE: number;
  64650. /**
  64651. * Texture data comes from a raw cube data encoded with RGBD
  64652. */
  64653. static DATASOURCE_CUBERAW_RGBD: number;
  64654. /**
  64655. * Defines if the texture is ready
  64656. */
  64657. isReady: boolean;
  64658. /**
  64659. * Defines if the texture is a cube texture
  64660. */
  64661. isCube: boolean;
  64662. /**
  64663. * Defines if the texture contains 3D data
  64664. */
  64665. is3D: boolean;
  64666. /**
  64667. * Gets the URL used to load this texture
  64668. */
  64669. url: string;
  64670. /**
  64671. * Gets the sampling mode of the texture
  64672. */
  64673. samplingMode: number;
  64674. /**
  64675. * Gets a boolean indicating if the texture needs mipmaps generation
  64676. */
  64677. generateMipMaps: boolean;
  64678. /**
  64679. * Gets the number of samples used by the texture (WebGL2+ only)
  64680. */
  64681. samples: number;
  64682. /**
  64683. * Gets the type of the texture (int, float...)
  64684. */
  64685. type: number;
  64686. /**
  64687. * Gets the format of the texture (RGB, RGBA...)
  64688. */
  64689. format: number;
  64690. /**
  64691. * Observable called when the texture is loaded
  64692. */
  64693. onLoadedObservable: Observable<InternalTexture>;
  64694. /**
  64695. * Gets the width of the texture
  64696. */
  64697. width: number;
  64698. /**
  64699. * Gets the height of the texture
  64700. */
  64701. height: number;
  64702. /**
  64703. * Gets the depth of the texture
  64704. */
  64705. depth: number;
  64706. /**
  64707. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64708. */
  64709. baseWidth: number;
  64710. /**
  64711. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64712. */
  64713. baseHeight: number;
  64714. /**
  64715. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64716. */
  64717. baseDepth: number;
  64718. /**
  64719. * Gets a boolean indicating if the texture is inverted on Y axis
  64720. */
  64721. invertY: boolean;
  64722. /**
  64723. * Gets or set the previous tracker in the list
  64724. */
  64725. previous: Nullable<IInternalTextureTracker>;
  64726. /**
  64727. * Gets or set the next tracker in the list
  64728. */
  64729. next: Nullable<IInternalTextureTracker>;
  64730. /** @hidden */
  64731. _invertVScale: boolean;
  64732. /** @hidden */
  64733. _initialSlot: number;
  64734. /** @hidden */
  64735. _designatedSlot: number;
  64736. /** @hidden */
  64737. _dataSource: number;
  64738. /** @hidden */
  64739. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64740. /** @hidden */
  64741. _bufferView: Nullable<ArrayBufferView>;
  64742. /** @hidden */
  64743. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64744. /** @hidden */
  64745. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64746. /** @hidden */
  64747. _size: number;
  64748. /** @hidden */
  64749. _extension: string;
  64750. /** @hidden */
  64751. _files: Nullable<string[]>;
  64752. /** @hidden */
  64753. _workingCanvas: HTMLCanvasElement;
  64754. /** @hidden */
  64755. _workingContext: CanvasRenderingContext2D;
  64756. /** @hidden */
  64757. _framebuffer: Nullable<WebGLFramebuffer>;
  64758. /** @hidden */
  64759. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64760. /** @hidden */
  64761. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64762. /** @hidden */
  64763. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64764. /** @hidden */
  64765. _attachments: Nullable<number[]>;
  64766. /** @hidden */
  64767. _cachedCoordinatesMode: Nullable<number>;
  64768. /** @hidden */
  64769. _cachedWrapU: Nullable<number>;
  64770. /** @hidden */
  64771. _cachedWrapV: Nullable<number>;
  64772. /** @hidden */
  64773. _cachedWrapR: Nullable<number>;
  64774. /** @hidden */
  64775. _cachedAnisotropicFilteringLevel: Nullable<number>;
  64776. /** @hidden */
  64777. _isDisabled: boolean;
  64778. /** @hidden */
  64779. _compression: Nullable<string>;
  64780. /** @hidden */
  64781. _generateStencilBuffer: boolean;
  64782. /** @hidden */
  64783. _generateDepthBuffer: boolean;
  64784. /** @hidden */
  64785. _comparisonFunction: number;
  64786. /** @hidden */
  64787. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  64788. /** @hidden */
  64789. _lodGenerationScale: number;
  64790. /** @hidden */
  64791. _lodGenerationOffset: number;
  64792. /** @hidden */
  64793. _lodTextureHigh: BaseTexture;
  64794. /** @hidden */
  64795. _lodTextureMid: BaseTexture;
  64796. /** @hidden */
  64797. _lodTextureLow: BaseTexture;
  64798. /** @hidden */
  64799. _isRGBD: boolean;
  64800. /** @hidden */
  64801. _webGLTexture: Nullable<WebGLTexture>;
  64802. /** @hidden */
  64803. _references: number;
  64804. private _engine;
  64805. /**
  64806. * Gets the Engine the texture belongs to.
  64807. * @returns The babylon engine
  64808. */
  64809. getEngine(): Engine;
  64810. /**
  64811. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64812. */
  64813. readonly dataSource: number;
  64814. /**
  64815. * Creates a new InternalTexture
  64816. * @param engine defines the engine to use
  64817. * @param dataSource defines the type of data that will be used
  64818. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64819. */
  64820. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64821. /**
  64822. * Increments the number of references (ie. the number of Texture that point to it)
  64823. */
  64824. incrementReferences(): void;
  64825. /**
  64826. * Change the size of the texture (not the size of the content)
  64827. * @param width defines the new width
  64828. * @param height defines the new height
  64829. * @param depth defines the new depth (1 by default)
  64830. */
  64831. updateSize(width: int, height: int, depth?: int): void;
  64832. /** @hidden */
  64833. _rebuild(): void;
  64834. /** @hidden */
  64835. _swapAndDie(target: InternalTexture): void;
  64836. /**
  64837. * Dispose the current allocated resources
  64838. */
  64839. dispose(): void;
  64840. }
  64841. }
  64842. declare module BABYLON {
  64843. /**
  64844. * This represents the main contract an easing function should follow.
  64845. * Easing functions are used throughout the animation system.
  64846. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64847. */
  64848. export interface IEasingFunction {
  64849. /**
  64850. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64851. * of the easing function.
  64852. * The link below provides some of the most common examples of easing functions.
  64853. * @see https://easings.net/
  64854. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64855. * @returns the corresponding value on the curve defined by the easing function
  64856. */
  64857. ease(gradient: number): number;
  64858. }
  64859. /**
  64860. * Base class used for every default easing function.
  64861. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64862. */
  64863. export class EasingFunction implements IEasingFunction {
  64864. /**
  64865. * Interpolation follows the mathematical formula associated with the easing function.
  64866. */
  64867. static readonly EASINGMODE_EASEIN: number;
  64868. /**
  64869. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64870. */
  64871. static readonly EASINGMODE_EASEOUT: number;
  64872. /**
  64873. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64874. */
  64875. static readonly EASINGMODE_EASEINOUT: number;
  64876. private _easingMode;
  64877. /**
  64878. * Sets the easing mode of the current function.
  64879. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64880. */
  64881. setEasingMode(easingMode: number): void;
  64882. /**
  64883. * Gets the current easing mode.
  64884. * @returns the easing mode
  64885. */
  64886. getEasingMode(): number;
  64887. /**
  64888. * @hidden
  64889. */
  64890. easeInCore(gradient: number): number;
  64891. /**
  64892. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64893. * of the easing function.
  64894. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64895. * @returns the corresponding value on the curve defined by the easing function
  64896. */
  64897. ease(gradient: number): number;
  64898. }
  64899. /**
  64900. * Easing function with a circle shape (see link below).
  64901. * @see https://easings.net/#easeInCirc
  64902. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64903. */
  64904. export class CircleEase extends EasingFunction implements IEasingFunction {
  64905. /** @hidden */
  64906. easeInCore(gradient: number): number;
  64907. }
  64908. /**
  64909. * Easing function with a ease back shape (see link below).
  64910. * @see https://easings.net/#easeInBack
  64911. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64912. */
  64913. export class BackEase extends EasingFunction implements IEasingFunction {
  64914. /** Defines the amplitude of the function */
  64915. amplitude: number;
  64916. /**
  64917. * Instantiates a back ease easing
  64918. * @see https://easings.net/#easeInBack
  64919. * @param amplitude Defines the amplitude of the function
  64920. */
  64921. constructor(
  64922. /** Defines the amplitude of the function */
  64923. amplitude?: number);
  64924. /** @hidden */
  64925. easeInCore(gradient: number): number;
  64926. }
  64927. /**
  64928. * Easing function with a bouncing shape (see link below).
  64929. * @see https://easings.net/#easeInBounce
  64930. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64931. */
  64932. export class BounceEase extends EasingFunction implements IEasingFunction {
  64933. /** Defines the number of bounces */
  64934. bounces: number;
  64935. /** Defines the amplitude of the bounce */
  64936. bounciness: number;
  64937. /**
  64938. * Instantiates a bounce easing
  64939. * @see https://easings.net/#easeInBounce
  64940. * @param bounces Defines the number of bounces
  64941. * @param bounciness Defines the amplitude of the bounce
  64942. */
  64943. constructor(
  64944. /** Defines the number of bounces */
  64945. bounces?: number,
  64946. /** Defines the amplitude of the bounce */
  64947. bounciness?: number);
  64948. /** @hidden */
  64949. easeInCore(gradient: number): number;
  64950. }
  64951. /**
  64952. * Easing function with a power of 3 shape (see link below).
  64953. * @see https://easings.net/#easeInCubic
  64954. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64955. */
  64956. export class CubicEase extends EasingFunction implements IEasingFunction {
  64957. /** @hidden */
  64958. easeInCore(gradient: number): number;
  64959. }
  64960. /**
  64961. * Easing function with an elastic shape (see link below).
  64962. * @see https://easings.net/#easeInElastic
  64963. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64964. */
  64965. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64966. /** Defines the number of oscillations*/
  64967. oscillations: number;
  64968. /** Defines the amplitude of the oscillations*/
  64969. springiness: number;
  64970. /**
  64971. * Instantiates an elastic easing function
  64972. * @see https://easings.net/#easeInElastic
  64973. * @param oscillations Defines the number of oscillations
  64974. * @param springiness Defines the amplitude of the oscillations
  64975. */
  64976. constructor(
  64977. /** Defines the number of oscillations*/
  64978. oscillations?: number,
  64979. /** Defines the amplitude of the oscillations*/
  64980. springiness?: number);
  64981. /** @hidden */
  64982. easeInCore(gradient: number): number;
  64983. }
  64984. /**
  64985. * Easing function with an exponential shape (see link below).
  64986. * @see https://easings.net/#easeInExpo
  64987. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64988. */
  64989. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64990. /** Defines the exponent of the function */
  64991. exponent: number;
  64992. /**
  64993. * Instantiates an exponential easing function
  64994. * @see https://easings.net/#easeInExpo
  64995. * @param exponent Defines the exponent of the function
  64996. */
  64997. constructor(
  64998. /** Defines the exponent of the function */
  64999. exponent?: number);
  65000. /** @hidden */
  65001. easeInCore(gradient: number): number;
  65002. }
  65003. /**
  65004. * Easing function with a power shape (see link below).
  65005. * @see https://easings.net/#easeInQuad
  65006. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65007. */
  65008. export class PowerEase extends EasingFunction implements IEasingFunction {
  65009. /** Defines the power of the function */
  65010. power: number;
  65011. /**
  65012. * Instantiates an power base easing function
  65013. * @see https://easings.net/#easeInQuad
  65014. * @param power Defines the power of the function
  65015. */
  65016. constructor(
  65017. /** Defines the power of the function */
  65018. power?: number);
  65019. /** @hidden */
  65020. easeInCore(gradient: number): number;
  65021. }
  65022. /**
  65023. * Easing function with a power of 2 shape (see link below).
  65024. * @see https://easings.net/#easeInQuad
  65025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65026. */
  65027. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65028. /** @hidden */
  65029. easeInCore(gradient: number): number;
  65030. }
  65031. /**
  65032. * Easing function with a power of 4 shape (see link below).
  65033. * @see https://easings.net/#easeInQuart
  65034. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65035. */
  65036. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65037. /** @hidden */
  65038. easeInCore(gradient: number): number;
  65039. }
  65040. /**
  65041. * Easing function with a power of 5 shape (see link below).
  65042. * @see https://easings.net/#easeInQuint
  65043. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65044. */
  65045. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65046. /** @hidden */
  65047. easeInCore(gradient: number): number;
  65048. }
  65049. /**
  65050. * Easing function with a sin shape (see link below).
  65051. * @see https://easings.net/#easeInSine
  65052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65053. */
  65054. export class SineEase extends EasingFunction implements IEasingFunction {
  65055. /** @hidden */
  65056. easeInCore(gradient: number): number;
  65057. }
  65058. /**
  65059. * Easing function with a bezier shape (see link below).
  65060. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65061. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65062. */
  65063. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65064. /** Defines the x component of the start tangent in the bezier curve */
  65065. x1: number;
  65066. /** Defines the y component of the start tangent in the bezier curve */
  65067. y1: number;
  65068. /** Defines the x component of the end tangent in the bezier curve */
  65069. x2: number;
  65070. /** Defines the y component of the end tangent in the bezier curve */
  65071. y2: number;
  65072. /**
  65073. * Instantiates a bezier function
  65074. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65075. * @param x1 Defines the x component of the start tangent in the bezier curve
  65076. * @param y1 Defines the y component of the start tangent in the bezier curve
  65077. * @param x2 Defines the x component of the end tangent in the bezier curve
  65078. * @param y2 Defines the y component of the end tangent in the bezier curve
  65079. */
  65080. constructor(
  65081. /** Defines the x component of the start tangent in the bezier curve */
  65082. x1?: number,
  65083. /** Defines the y component of the start tangent in the bezier curve */
  65084. y1?: number,
  65085. /** Defines the x component of the end tangent in the bezier curve */
  65086. x2?: number,
  65087. /** Defines the y component of the end tangent in the bezier curve */
  65088. y2?: number);
  65089. /** @hidden */
  65090. easeInCore(gradient: number): number;
  65091. }
  65092. }
  65093. declare module BABYLON {
  65094. /**
  65095. * Defines an interface which represents an animation key frame
  65096. */
  65097. export interface IAnimationKey {
  65098. /**
  65099. * Frame of the key frame
  65100. */
  65101. frame: number;
  65102. /**
  65103. * Value at the specifies key frame
  65104. */
  65105. value: any;
  65106. /**
  65107. * The input tangent for the cubic hermite spline
  65108. */
  65109. inTangent?: any;
  65110. /**
  65111. * The output tangent for the cubic hermite spline
  65112. */
  65113. outTangent?: any;
  65114. /**
  65115. * The animation interpolation type
  65116. */
  65117. interpolation?: AnimationKeyInterpolation;
  65118. }
  65119. /**
  65120. * Enum for the animation key frame interpolation type
  65121. */
  65122. export enum AnimationKeyInterpolation {
  65123. /**
  65124. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65125. */
  65126. STEP = 1
  65127. }
  65128. }
  65129. declare module BABYLON {
  65130. /**
  65131. * Represents the range of an animation
  65132. */
  65133. export class AnimationRange {
  65134. /**The name of the animation range**/
  65135. name: string;
  65136. /**The starting frame of the animation */
  65137. from: number;
  65138. /**The ending frame of the animation*/
  65139. to: number;
  65140. /**
  65141. * Initializes the range of an animation
  65142. * @param name The name of the animation range
  65143. * @param from The starting frame of the animation
  65144. * @param to The ending frame of the animation
  65145. */
  65146. constructor(
  65147. /**The name of the animation range**/
  65148. name: string,
  65149. /**The starting frame of the animation */
  65150. from: number,
  65151. /**The ending frame of the animation*/
  65152. to: number);
  65153. /**
  65154. * Makes a copy of the animation range
  65155. * @returns A copy of the animation range
  65156. */
  65157. clone(): AnimationRange;
  65158. }
  65159. }
  65160. declare module BABYLON {
  65161. /**
  65162. * Composed of a frame, and an action function
  65163. */
  65164. export class AnimationEvent {
  65165. /** The frame for which the event is triggered **/
  65166. frame: number;
  65167. /** The event to perform when triggered **/
  65168. action: (currentFrame: number) => void;
  65169. /** Specifies if the event should be triggered only once**/
  65170. onlyOnce?: boolean | undefined;
  65171. /**
  65172. * Specifies if the animation event is done
  65173. */
  65174. isDone: boolean;
  65175. /**
  65176. * Initializes the animation event
  65177. * @param frame The frame for which the event is triggered
  65178. * @param action The event to perform when triggered
  65179. * @param onlyOnce Specifies if the event should be triggered only once
  65180. */
  65181. constructor(
  65182. /** The frame for which the event is triggered **/
  65183. frame: number,
  65184. /** The event to perform when triggered **/
  65185. action: (currentFrame: number) => void,
  65186. /** Specifies if the event should be triggered only once**/
  65187. onlyOnce?: boolean | undefined);
  65188. /** @hidden */
  65189. _clone(): AnimationEvent;
  65190. }
  65191. }
  65192. declare module BABYLON {
  65193. /**
  65194. * Interface used to define a behavior
  65195. */
  65196. export interface Behavior<T> {
  65197. /** gets or sets behavior's name */
  65198. name: string;
  65199. /**
  65200. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65201. */
  65202. init(): void;
  65203. /**
  65204. * Called when the behavior is attached to a target
  65205. * @param target defines the target where the behavior is attached to
  65206. */
  65207. attach(target: T): void;
  65208. /**
  65209. * Called when the behavior is detached from its target
  65210. */
  65211. detach(): void;
  65212. }
  65213. /**
  65214. * Interface implemented by classes supporting behaviors
  65215. */
  65216. export interface IBehaviorAware<T> {
  65217. /**
  65218. * Attach a behavior
  65219. * @param behavior defines the behavior to attach
  65220. * @returns the current host
  65221. */
  65222. addBehavior(behavior: Behavior<T>): T;
  65223. /**
  65224. * Remove a behavior from the current object
  65225. * @param behavior defines the behavior to detach
  65226. * @returns the current host
  65227. */
  65228. removeBehavior(behavior: Behavior<T>): T;
  65229. /**
  65230. * Gets a behavior using its name to search
  65231. * @param name defines the name to search
  65232. * @returns the behavior or null if not found
  65233. */
  65234. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65235. }
  65236. }
  65237. declare module BABYLON {
  65238. /**
  65239. * @hidden
  65240. */
  65241. export class IntersectionInfo {
  65242. bu: Nullable<number>;
  65243. bv: Nullable<number>;
  65244. distance: number;
  65245. faceId: number;
  65246. subMeshId: number;
  65247. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65248. }
  65249. }
  65250. declare module BABYLON {
  65251. /**
  65252. * Class used to store bounding sphere information
  65253. */
  65254. export class BoundingSphere {
  65255. /**
  65256. * Gets the center of the bounding sphere in local space
  65257. */
  65258. readonly center: Vector3;
  65259. /**
  65260. * Radius of the bounding sphere in local space
  65261. */
  65262. radius: number;
  65263. /**
  65264. * Gets the center of the bounding sphere in world space
  65265. */
  65266. readonly centerWorld: Vector3;
  65267. /**
  65268. * Radius of the bounding sphere in world space
  65269. */
  65270. radiusWorld: number;
  65271. /**
  65272. * Gets the minimum vector in local space
  65273. */
  65274. readonly minimum: Vector3;
  65275. /**
  65276. * Gets the maximum vector in local space
  65277. */
  65278. readonly maximum: Vector3;
  65279. private _worldMatrix;
  65280. private static readonly TmpVector3;
  65281. /**
  65282. * Creates a new bounding sphere
  65283. * @param min defines the minimum vector (in local space)
  65284. * @param max defines the maximum vector (in local space)
  65285. * @param worldMatrix defines the new world matrix
  65286. */
  65287. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65288. /**
  65289. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65290. * @param min defines the new minimum vector (in local space)
  65291. * @param max defines the new maximum vector (in local space)
  65292. * @param worldMatrix defines the new world matrix
  65293. */
  65294. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65295. /**
  65296. * Scale the current bounding sphere by applying a scale factor
  65297. * @param factor defines the scale factor to apply
  65298. * @returns the current bounding box
  65299. */
  65300. scale(factor: number): BoundingSphere;
  65301. /**
  65302. * Gets the world matrix of the bounding box
  65303. * @returns a matrix
  65304. */
  65305. getWorldMatrix(): DeepImmutable<Matrix>;
  65306. /** @hidden */
  65307. _update(worldMatrix: DeepImmutable<Matrix>): void;
  65308. /**
  65309. * Tests if the bounding sphere is intersecting the frustum planes
  65310. * @param frustumPlanes defines the frustum planes to test
  65311. * @returns true if there is an intersection
  65312. */
  65313. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65314. /**
  65315. * Tests if the bounding sphere center is in between the frustum planes.
  65316. * Used for optimistic fast inclusion.
  65317. * @param frustumPlanes defines the frustum planes to test
  65318. * @returns true if the sphere center is in between the frustum planes
  65319. */
  65320. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65321. /**
  65322. * Tests if a point is inside the bounding sphere
  65323. * @param point defines the point to test
  65324. * @returns true if the point is inside the bounding sphere
  65325. */
  65326. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65327. /**
  65328. * Checks if two sphere intersct
  65329. * @param sphere0 sphere 0
  65330. * @param sphere1 sphere 1
  65331. * @returns true if the speres intersect
  65332. */
  65333. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  65334. }
  65335. }
  65336. declare module BABYLON {
  65337. /**
  65338. * Class used to store bounding box information
  65339. */
  65340. export class BoundingBox implements ICullable {
  65341. /**
  65342. * Gets the 8 vectors representing the bounding box in local space
  65343. */
  65344. readonly vectors: Vector3[];
  65345. /**
  65346. * Gets the center of the bounding box in local space
  65347. */
  65348. readonly center: Vector3;
  65349. /**
  65350. * Gets the center of the bounding box in world space
  65351. */
  65352. readonly centerWorld: Vector3;
  65353. /**
  65354. * Gets the extend size in local space
  65355. */
  65356. readonly extendSize: Vector3;
  65357. /**
  65358. * Gets the extend size in world space
  65359. */
  65360. readonly extendSizeWorld: Vector3;
  65361. /**
  65362. * Gets the OBB (object bounding box) directions
  65363. */
  65364. readonly directions: Vector3[];
  65365. /**
  65366. * Gets the 8 vectors representing the bounding box in world space
  65367. */
  65368. readonly vectorsWorld: Vector3[];
  65369. /**
  65370. * Gets the minimum vector in world space
  65371. */
  65372. readonly minimumWorld: Vector3;
  65373. /**
  65374. * Gets the maximum vector in world space
  65375. */
  65376. readonly maximumWorld: Vector3;
  65377. /**
  65378. * Gets the minimum vector in local space
  65379. */
  65380. readonly minimum: Vector3;
  65381. /**
  65382. * Gets the maximum vector in local space
  65383. */
  65384. readonly maximum: Vector3;
  65385. private _worldMatrix;
  65386. private static readonly TmpVector3;
  65387. /**
  65388. * @hidden
  65389. */
  65390. _tag: number;
  65391. /**
  65392. * Creates a new bounding box
  65393. * @param min defines the minimum vector (in local space)
  65394. * @param max defines the maximum vector (in local space)
  65395. * @param worldMatrix defines the new world matrix
  65396. */
  65397. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65398. /**
  65399. * Recreates the entire bounding box from scratch as if we call the constructor in place
  65400. * @param min defines the new minimum vector (in local space)
  65401. * @param max defines the new maximum vector (in local space)
  65402. * @param worldMatrix defines the new world matrix
  65403. */
  65404. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65405. /**
  65406. * Scale the current bounding box by applying a scale factor
  65407. * @param factor defines the scale factor to apply
  65408. * @returns the current bounding box
  65409. */
  65410. scale(factor: number): BoundingBox;
  65411. /**
  65412. * Gets the world matrix of the bounding box
  65413. * @returns a matrix
  65414. */
  65415. getWorldMatrix(): DeepImmutable<Matrix>;
  65416. /** @hidden */
  65417. _update(world: DeepImmutable<Matrix>): void;
  65418. /**
  65419. * Tests if the bounding box is intersecting the frustum planes
  65420. * @param frustumPlanes defines the frustum planes to test
  65421. * @returns true if there is an intersection
  65422. */
  65423. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65424. /**
  65425. * Tests if the bounding box is entirely inside the frustum planes
  65426. * @param frustumPlanes defines the frustum planes to test
  65427. * @returns true if there is an inclusion
  65428. */
  65429. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65430. /**
  65431. * Tests if a point is inside the bounding box
  65432. * @param point defines the point to test
  65433. * @returns true if the point is inside the bounding box
  65434. */
  65435. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65436. /**
  65437. * Tests if the bounding box intersects with a bounding sphere
  65438. * @param sphere defines the sphere to test
  65439. * @returns true if there is an intersection
  65440. */
  65441. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  65442. /**
  65443. * Tests if the bounding box intersects with a box defined by a min and max vectors
  65444. * @param min defines the min vector to use
  65445. * @param max defines the max vector to use
  65446. * @returns true if there is an intersection
  65447. */
  65448. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  65449. /**
  65450. * Tests if two bounding boxes are intersections
  65451. * @param box0 defines the first box to test
  65452. * @param box1 defines the second box to test
  65453. * @returns true if there is an intersection
  65454. */
  65455. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  65456. /**
  65457. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  65458. * @param minPoint defines the minimum vector of the bounding box
  65459. * @param maxPoint defines the maximum vector of the bounding box
  65460. * @param sphereCenter defines the sphere center
  65461. * @param sphereRadius defines the sphere radius
  65462. * @returns true if there is an intersection
  65463. */
  65464. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  65465. /**
  65466. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  65467. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65468. * @param frustumPlanes defines the frustum planes to test
  65469. * @return true if there is an inclusion
  65470. */
  65471. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65472. /**
  65473. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  65474. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65475. * @param frustumPlanes defines the frustum planes to test
  65476. * @return true if there is an intersection
  65477. */
  65478. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65479. }
  65480. }
  65481. declare module BABYLON {
  65482. /** @hidden */
  65483. export class Collider {
  65484. /** Define if a collision was found */
  65485. collisionFound: boolean;
  65486. /**
  65487. * Define last intersection point in local space
  65488. */
  65489. intersectionPoint: Vector3;
  65490. /**
  65491. * Define last collided mesh
  65492. */
  65493. collidedMesh: Nullable<AbstractMesh>;
  65494. private _collisionPoint;
  65495. private _planeIntersectionPoint;
  65496. private _tempVector;
  65497. private _tempVector2;
  65498. private _tempVector3;
  65499. private _tempVector4;
  65500. private _edge;
  65501. private _baseToVertex;
  65502. private _destinationPoint;
  65503. private _slidePlaneNormal;
  65504. private _displacementVector;
  65505. /** @hidden */
  65506. _radius: Vector3;
  65507. /** @hidden */
  65508. _retry: number;
  65509. private _velocity;
  65510. private _basePoint;
  65511. private _epsilon;
  65512. /** @hidden */
  65513. _velocityWorldLength: number;
  65514. /** @hidden */
  65515. _basePointWorld: Vector3;
  65516. private _velocityWorld;
  65517. private _normalizedVelocity;
  65518. /** @hidden */
  65519. _initialVelocity: Vector3;
  65520. /** @hidden */
  65521. _initialPosition: Vector3;
  65522. private _nearestDistance;
  65523. private _collisionMask;
  65524. collisionMask: number;
  65525. /**
  65526. * Gets the plane normal used to compute the sliding response (in local space)
  65527. */
  65528. readonly slidePlaneNormal: Vector3;
  65529. /** @hidden */
  65530. _initialize(source: Vector3, dir: Vector3, e: number): void;
  65531. /** @hidden */
  65532. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  65533. /** @hidden */
  65534. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  65535. /** @hidden */
  65536. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  65537. /** @hidden */
  65538. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  65539. /** @hidden */
  65540. _getResponse(pos: Vector3, vel: Vector3): void;
  65541. }
  65542. }
  65543. declare module BABYLON {
  65544. /**
  65545. * Interface for cullable objects
  65546. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  65547. */
  65548. export interface ICullable {
  65549. /**
  65550. * Checks if the object or part of the object is in the frustum
  65551. * @param frustumPlanes Camera near/planes
  65552. * @returns true if the object is in frustum otherwise false
  65553. */
  65554. isInFrustum(frustumPlanes: Plane[]): boolean;
  65555. /**
  65556. * Checks if a cullable object (mesh...) is in the camera frustum
  65557. * Unlike isInFrustum this cheks the full bounding box
  65558. * @param frustumPlanes Camera near/planes
  65559. * @returns true if the object is in frustum otherwise false
  65560. */
  65561. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  65562. }
  65563. /**
  65564. * Info for a bounding data of a mesh
  65565. */
  65566. export class BoundingInfo implements ICullable {
  65567. /**
  65568. * Bounding box for the mesh
  65569. */
  65570. readonly boundingBox: BoundingBox;
  65571. /**
  65572. * Bounding sphere for the mesh
  65573. */
  65574. readonly boundingSphere: BoundingSphere;
  65575. private _isLocked;
  65576. private static readonly TmpVector3;
  65577. /**
  65578. * Constructs bounding info
  65579. * @param minimum min vector of the bounding box/sphere
  65580. * @param maximum max vector of the bounding box/sphere
  65581. * @param worldMatrix defines the new world matrix
  65582. */
  65583. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65584. /**
  65585. * Recreates the entire bounding info from scratch as if we call the constructor in place
  65586. * @param min defines the new minimum vector (in local space)
  65587. * @param max defines the new maximum vector (in local space)
  65588. * @param worldMatrix defines the new world matrix
  65589. */
  65590. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65591. /**
  65592. * min vector of the bounding box/sphere
  65593. */
  65594. readonly minimum: Vector3;
  65595. /**
  65596. * max vector of the bounding box/sphere
  65597. */
  65598. readonly maximum: Vector3;
  65599. /**
  65600. * If the info is locked and won't be updated to avoid perf overhead
  65601. */
  65602. isLocked: boolean;
  65603. /**
  65604. * Updates the bounding sphere and box
  65605. * @param world world matrix to be used to update
  65606. */
  65607. update(world: DeepImmutable<Matrix>): void;
  65608. /**
  65609. * Recreate the bounding info to be centered around a specific point given a specific extend.
  65610. * @param center New center of the bounding info
  65611. * @param extend New extend of the bounding info
  65612. * @returns the current bounding info
  65613. */
  65614. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  65615. /**
  65616. * Scale the current bounding info by applying a scale factor
  65617. * @param factor defines the scale factor to apply
  65618. * @returns the current bounding info
  65619. */
  65620. scale(factor: number): BoundingInfo;
  65621. /**
  65622. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  65623. * @param frustumPlanes defines the frustum to test
  65624. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  65625. * @returns true if the bounding info is in the frustum planes
  65626. */
  65627. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  65628. /**
  65629. * Gets the world distance between the min and max points of the bounding box
  65630. */
  65631. readonly diagonalLength: number;
  65632. /**
  65633. * Checks if a cullable object (mesh...) is in the camera frustum
  65634. * Unlike isInFrustum this cheks the full bounding box
  65635. * @param frustumPlanes Camera near/planes
  65636. * @returns true if the object is in frustum otherwise false
  65637. */
  65638. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65639. /** @hidden */
  65640. _checkCollision(collider: Collider): boolean;
  65641. /**
  65642. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65643. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65644. * @param point the point to check intersection with
  65645. * @returns if the point intersects
  65646. */
  65647. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65648. /**
  65649. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65650. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65651. * @param boundingInfo the bounding info to check intersection with
  65652. * @param precise if the intersection should be done using OBB
  65653. * @returns if the bounding info intersects
  65654. */
  65655. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65656. }
  65657. }
  65658. declare module BABYLON {
  65659. /**
  65660. * Defines an array and its length.
  65661. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65662. */
  65663. export interface ISmartArrayLike<T> {
  65664. /**
  65665. * The data of the array.
  65666. */
  65667. data: Array<T>;
  65668. /**
  65669. * The active length of the array.
  65670. */
  65671. length: number;
  65672. }
  65673. /**
  65674. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65675. */
  65676. export class SmartArray<T> implements ISmartArrayLike<T> {
  65677. /**
  65678. * The full set of data from the array.
  65679. */
  65680. data: Array<T>;
  65681. /**
  65682. * The active length of the array.
  65683. */
  65684. length: number;
  65685. protected _id: number;
  65686. /**
  65687. * Instantiates a Smart Array.
  65688. * @param capacity defines the default capacity of the array.
  65689. */
  65690. constructor(capacity: number);
  65691. /**
  65692. * Pushes a value at the end of the active data.
  65693. * @param value defines the object to push in the array.
  65694. */
  65695. push(value: T): void;
  65696. /**
  65697. * Iterates over the active data and apply the lambda to them.
  65698. * @param func defines the action to apply on each value.
  65699. */
  65700. forEach(func: (content: T) => void): void;
  65701. /**
  65702. * Sorts the full sets of data.
  65703. * @param compareFn defines the comparison function to apply.
  65704. */
  65705. sort(compareFn: (a: T, b: T) => number): void;
  65706. /**
  65707. * Resets the active data to an empty array.
  65708. */
  65709. reset(): void;
  65710. /**
  65711. * Releases all the data from the array as well as the array.
  65712. */
  65713. dispose(): void;
  65714. /**
  65715. * Concats the active data with a given array.
  65716. * @param array defines the data to concatenate with.
  65717. */
  65718. concat(array: any): void;
  65719. /**
  65720. * Returns the position of a value in the active data.
  65721. * @param value defines the value to find the index for
  65722. * @returns the index if found in the active data otherwise -1
  65723. */
  65724. indexOf(value: T): number;
  65725. /**
  65726. * Returns whether an element is part of the active data.
  65727. * @param value defines the value to look for
  65728. * @returns true if found in the active data otherwise false
  65729. */
  65730. contains(value: T): boolean;
  65731. private static _GlobalId;
  65732. }
  65733. /**
  65734. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65735. * The data in this array can only be present once
  65736. */
  65737. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65738. private _duplicateId;
  65739. /**
  65740. * Pushes a value at the end of the active data.
  65741. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65742. * @param value defines the object to push in the array.
  65743. */
  65744. push(value: T): void;
  65745. /**
  65746. * Pushes a value at the end of the active data.
  65747. * If the data is already present, it won t be added again
  65748. * @param value defines the object to push in the array.
  65749. * @returns true if added false if it was already present
  65750. */
  65751. pushNoDuplicate(value: T): boolean;
  65752. /**
  65753. * Resets the active data to an empty array.
  65754. */
  65755. reset(): void;
  65756. /**
  65757. * Concats the active data with a given array.
  65758. * This ensures no dupplicate will be present in the result.
  65759. * @param array defines the data to concatenate with.
  65760. */
  65761. concatWithNoDuplicate(array: any): void;
  65762. }
  65763. }
  65764. declare module BABYLON {
  65765. /**
  65766. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65767. * separate meshes. This can be use to improve performances.
  65768. * @see http://doc.babylonjs.com/how_to/multi_materials
  65769. */
  65770. export class MultiMaterial extends Material {
  65771. private _subMaterials;
  65772. /**
  65773. * Gets or Sets the list of Materials used within the multi material.
  65774. * They need to be ordered according to the submeshes order in the associated mesh
  65775. */
  65776. subMaterials: Nullable<Material>[];
  65777. /**
  65778. * Function used to align with Node.getChildren()
  65779. * @returns the list of Materials used within the multi material
  65780. */
  65781. getChildren(): Nullable<Material>[];
  65782. /**
  65783. * Instantiates a new Multi Material
  65784. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65785. * separate meshes. This can be use to improve performances.
  65786. * @see http://doc.babylonjs.com/how_to/multi_materials
  65787. * @param name Define the name in the scene
  65788. * @param scene Define the scene the material belongs to
  65789. */
  65790. constructor(name: string, scene: Scene);
  65791. private _hookArray;
  65792. /**
  65793. * Get one of the submaterial by its index in the submaterials array
  65794. * @param index The index to look the sub material at
  65795. * @returns The Material if the index has been defined
  65796. */
  65797. getSubMaterial(index: number): Nullable<Material>;
  65798. /**
  65799. * Get the list of active textures for the whole sub materials list.
  65800. * @returns All the textures that will be used during the rendering
  65801. */
  65802. getActiveTextures(): BaseTexture[];
  65803. /**
  65804. * Gets the current class name of the material e.g. "MultiMaterial"
  65805. * Mainly use in serialization.
  65806. * @returns the class name
  65807. */
  65808. getClassName(): string;
  65809. /**
  65810. * Checks if the material is ready to render the requested sub mesh
  65811. * @param mesh Define the mesh the submesh belongs to
  65812. * @param subMesh Define the sub mesh to look readyness for
  65813. * @param useInstances Define whether or not the material is used with instances
  65814. * @returns true if ready, otherwise false
  65815. */
  65816. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65817. /**
  65818. * Clones the current material and its related sub materials
  65819. * @param name Define the name of the newly cloned material
  65820. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65821. * @returns the cloned material
  65822. */
  65823. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65824. /**
  65825. * Serializes the materials into a JSON representation.
  65826. * @returns the JSON representation
  65827. */
  65828. serialize(): any;
  65829. /**
  65830. * Dispose the material and release its associated resources
  65831. * @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)
  65832. * @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)
  65833. * @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)
  65834. */
  65835. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65836. /**
  65837. * Creates a MultiMaterial from parsed MultiMaterial data.
  65838. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65839. * @param scene defines the hosting scene
  65840. * @returns a new MultiMaterial
  65841. */
  65842. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65843. }
  65844. }
  65845. declare module BABYLON {
  65846. /**
  65847. * Class used to represent data loading progression
  65848. */
  65849. export class SceneLoaderFlags {
  65850. private static _ForceFullSceneLoadingForIncremental;
  65851. private static _ShowLoadingScreen;
  65852. private static _CleanBoneMatrixWeights;
  65853. private static _loggingLevel;
  65854. /**
  65855. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65856. */
  65857. static ForceFullSceneLoadingForIncremental: boolean;
  65858. /**
  65859. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65860. */
  65861. static ShowLoadingScreen: boolean;
  65862. /**
  65863. * Defines the current logging level (while loading the scene)
  65864. * @ignorenaming
  65865. */
  65866. static loggingLevel: number;
  65867. /**
  65868. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65869. */
  65870. static CleanBoneMatrixWeights: boolean;
  65871. }
  65872. }
  65873. declare module BABYLON {
  65874. /**
  65875. * 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.
  65876. * @see https://doc.babylonjs.com/how_to/transformnode
  65877. */
  65878. export class TransformNode extends Node {
  65879. /**
  65880. * Object will not rotate to face the camera
  65881. */
  65882. static BILLBOARDMODE_NONE: number;
  65883. /**
  65884. * Object will rotate to face the camera but only on the x axis
  65885. */
  65886. static BILLBOARDMODE_X: number;
  65887. /**
  65888. * Object will rotate to face the camera but only on the y axis
  65889. */
  65890. static BILLBOARDMODE_Y: number;
  65891. /**
  65892. * Object will rotate to face the camera but only on the z axis
  65893. */
  65894. static BILLBOARDMODE_Z: number;
  65895. /**
  65896. * Object will rotate to face the camera
  65897. */
  65898. static BILLBOARDMODE_ALL: number;
  65899. private _forward;
  65900. private _forwardInverted;
  65901. private _up;
  65902. private _right;
  65903. private _rightInverted;
  65904. private _position;
  65905. private _rotation;
  65906. private _rotationQuaternion;
  65907. protected _scaling: Vector3;
  65908. protected _isDirty: boolean;
  65909. private _transformToBoneReferal;
  65910. /**
  65911. * Set the billboard mode. Default is 0.
  65912. *
  65913. * | Value | Type | Description |
  65914. * | --- | --- | --- |
  65915. * | 0 | BILLBOARDMODE_NONE | |
  65916. * | 1 | BILLBOARDMODE_X | |
  65917. * | 2 | BILLBOARDMODE_Y | |
  65918. * | 4 | BILLBOARDMODE_Z | |
  65919. * | 7 | BILLBOARDMODE_ALL | |
  65920. *
  65921. */
  65922. billboardMode: number;
  65923. /**
  65924. * 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
  65925. */
  65926. scalingDeterminant: number;
  65927. /**
  65928. * Sets the distance of the object to max, often used by skybox
  65929. */
  65930. infiniteDistance: boolean;
  65931. /**
  65932. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65933. * By default the system will update normals to compensate
  65934. */
  65935. ignoreNonUniformScaling: boolean;
  65936. /** @hidden */
  65937. _poseMatrix: Matrix;
  65938. /** @hidden */
  65939. _localMatrix: Matrix;
  65940. private _absolutePosition;
  65941. private _pivotMatrix;
  65942. private _pivotMatrixInverse;
  65943. protected _postMultiplyPivotMatrix: boolean;
  65944. private _tempMatrix;
  65945. private _tempMatrix2;
  65946. protected _isWorldMatrixFrozen: boolean;
  65947. /** @hidden */
  65948. _indexInSceneTransformNodesArray: number;
  65949. /**
  65950. * An event triggered after the world matrix is updated
  65951. */
  65952. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65953. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65954. /**
  65955. * Gets a string identifying the name of the class
  65956. * @returns "TransformNode" string
  65957. */
  65958. getClassName(): string;
  65959. /**
  65960. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65961. */
  65962. position: Vector3;
  65963. /**
  65964. * 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)).
  65965. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65966. */
  65967. rotation: Vector3;
  65968. /**
  65969. * 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)).
  65970. */
  65971. scaling: Vector3;
  65972. /**
  65973. * 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).
  65974. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65975. */
  65976. rotationQuaternion: Nullable<Quaternion>;
  65977. /**
  65978. * The forward direction of that transform in world space.
  65979. */
  65980. readonly forward: Vector3;
  65981. /**
  65982. * The up direction of that transform in world space.
  65983. */
  65984. readonly up: Vector3;
  65985. /**
  65986. * The right direction of that transform in world space.
  65987. */
  65988. readonly right: Vector3;
  65989. /**
  65990. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65991. * @param matrix the matrix to copy the pose from
  65992. * @returns this TransformNode.
  65993. */
  65994. updatePoseMatrix(matrix: Matrix): TransformNode;
  65995. /**
  65996. * Returns the mesh Pose matrix.
  65997. * @returns the pose matrix
  65998. */
  65999. getPoseMatrix(): Matrix;
  66000. /** @hidden */
  66001. _isSynchronized(): boolean;
  66002. /** @hidden */
  66003. _initCache(): void;
  66004. /**
  66005. * Flag the transform node as dirty (Forcing it to update everything)
  66006. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66007. * @returns this transform node
  66008. */
  66009. markAsDirty(property: string): TransformNode;
  66010. /**
  66011. * Returns the current mesh absolute position.
  66012. * Returns a Vector3.
  66013. */
  66014. readonly absolutePosition: Vector3;
  66015. /**
  66016. * Sets a new matrix to apply before all other transformation
  66017. * @param matrix defines the transform matrix
  66018. * @returns the current TransformNode
  66019. */
  66020. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66021. /**
  66022. * Sets a new pivot matrix to the current node
  66023. * @param matrix defines the new pivot matrix to use
  66024. * @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
  66025. * @returns the current TransformNode
  66026. */
  66027. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66028. /**
  66029. * Returns the mesh pivot matrix.
  66030. * Default : Identity.
  66031. * @returns the matrix
  66032. */
  66033. getPivotMatrix(): Matrix;
  66034. /**
  66035. * Prevents the World matrix to be computed any longer.
  66036. * @returns the TransformNode.
  66037. */
  66038. freezeWorldMatrix(): TransformNode;
  66039. /**
  66040. * Allows back the World matrix computation.
  66041. * @returns the TransformNode.
  66042. */
  66043. unfreezeWorldMatrix(): this;
  66044. /**
  66045. * True if the World matrix has been frozen.
  66046. */
  66047. readonly isWorldMatrixFrozen: boolean;
  66048. /**
  66049. * Retuns the mesh absolute position in the World.
  66050. * @returns a Vector3.
  66051. */
  66052. getAbsolutePosition(): Vector3;
  66053. /**
  66054. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66055. * @param absolutePosition the absolute position to set
  66056. * @returns the TransformNode.
  66057. */
  66058. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66059. /**
  66060. * Sets the mesh position in its local space.
  66061. * @param vector3 the position to set in localspace
  66062. * @returns the TransformNode.
  66063. */
  66064. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66065. /**
  66066. * Returns the mesh position in the local space from the current World matrix values.
  66067. * @returns a new Vector3.
  66068. */
  66069. getPositionExpressedInLocalSpace(): Vector3;
  66070. /**
  66071. * Translates the mesh along the passed Vector3 in its local space.
  66072. * @param vector3 the distance to translate in localspace
  66073. * @returns the TransformNode.
  66074. */
  66075. locallyTranslate(vector3: Vector3): TransformNode;
  66076. private static _lookAtVectorCache;
  66077. /**
  66078. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66079. * @param targetPoint the position (must be in same space as current mesh) to look at
  66080. * @param yawCor optional yaw (y-axis) correction in radians
  66081. * @param pitchCor optional pitch (x-axis) correction in radians
  66082. * @param rollCor optional roll (z-axis) correction in radians
  66083. * @param space the choosen space of the target
  66084. * @returns the TransformNode.
  66085. */
  66086. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66087. /**
  66088. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66089. * This Vector3 is expressed in the World space.
  66090. * @param localAxis axis to rotate
  66091. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66092. */
  66093. getDirection(localAxis: Vector3): Vector3;
  66094. /**
  66095. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66096. * localAxis is expressed in the mesh local space.
  66097. * result is computed in the Wordl space from the mesh World matrix.
  66098. * @param localAxis axis to rotate
  66099. * @param result the resulting transformnode
  66100. * @returns this TransformNode.
  66101. */
  66102. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66103. /**
  66104. * Sets this transform node rotation to the given local axis.
  66105. * @param localAxis the axis in local space
  66106. * @param yawCor optional yaw (y-axis) correction in radians
  66107. * @param pitchCor optional pitch (x-axis) correction in radians
  66108. * @param rollCor optional roll (z-axis) correction in radians
  66109. * @returns this TransformNode
  66110. */
  66111. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66112. /**
  66113. * Sets a new pivot point to the current node
  66114. * @param point defines the new pivot point to use
  66115. * @param space defines if the point is in world or local space (local by default)
  66116. * @returns the current TransformNode
  66117. */
  66118. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66119. /**
  66120. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66121. * @returns the pivot point
  66122. */
  66123. getPivotPoint(): Vector3;
  66124. /**
  66125. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66126. * @param result the vector3 to store the result
  66127. * @returns this TransformNode.
  66128. */
  66129. getPivotPointToRef(result: Vector3): TransformNode;
  66130. /**
  66131. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66132. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66133. */
  66134. getAbsolutePivotPoint(): Vector3;
  66135. /**
  66136. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66137. * @param result vector3 to store the result
  66138. * @returns this TransformNode.
  66139. */
  66140. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66141. /**
  66142. * Defines the passed node as the parent of the current node.
  66143. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66144. * @see https://doc.babylonjs.com/how_to/parenting
  66145. * @param node the node ot set as the parent
  66146. * @returns this TransformNode.
  66147. */
  66148. setParent(node: Nullable<Node>): TransformNode;
  66149. private _nonUniformScaling;
  66150. /**
  66151. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66152. */
  66153. readonly nonUniformScaling: boolean;
  66154. /** @hidden */
  66155. _updateNonUniformScalingState(value: boolean): boolean;
  66156. /**
  66157. * Attach the current TransformNode to another TransformNode associated with a bone
  66158. * @param bone Bone affecting the TransformNode
  66159. * @param affectedTransformNode TransformNode associated with the bone
  66160. * @returns this object
  66161. */
  66162. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66163. /**
  66164. * Detach the transform node if its associated with a bone
  66165. * @returns this object
  66166. */
  66167. detachFromBone(): TransformNode;
  66168. private static _rotationAxisCache;
  66169. /**
  66170. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66171. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66172. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66173. * The passed axis is also normalized.
  66174. * @param axis the axis to rotate around
  66175. * @param amount the amount to rotate in radians
  66176. * @param space Space to rotate in (Default: local)
  66177. * @returns the TransformNode.
  66178. */
  66179. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66180. /**
  66181. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66182. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66183. * The passed axis is also normalized. .
  66184. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66185. * @param point the point to rotate around
  66186. * @param axis the axis to rotate around
  66187. * @param amount the amount to rotate in radians
  66188. * @returns the TransformNode
  66189. */
  66190. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66191. /**
  66192. * Translates the mesh along the axis vector for the passed distance in the given space.
  66193. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66194. * @param axis the axis to translate in
  66195. * @param distance the distance to translate
  66196. * @param space Space to rotate in (Default: local)
  66197. * @returns the TransformNode.
  66198. */
  66199. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66200. /**
  66201. * Adds a rotation step to the mesh current rotation.
  66202. * x, y, z are Euler angles expressed in radians.
  66203. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66204. * This means this rotation is made in the mesh local space only.
  66205. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66206. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66207. * ```javascript
  66208. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66209. * ```
  66210. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66211. * 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.
  66212. * @param x Rotation to add
  66213. * @param y Rotation to add
  66214. * @param z Rotation to add
  66215. * @returns the TransformNode.
  66216. */
  66217. addRotation(x: number, y: number, z: number): TransformNode;
  66218. /**
  66219. * Computes the world matrix of the node
  66220. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66221. * @returns the world matrix
  66222. */
  66223. computeWorldMatrix(force?: boolean): Matrix;
  66224. protected _afterComputeWorldMatrix(): void;
  66225. /**
  66226. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66227. * @param func callback function to add
  66228. *
  66229. * @returns the TransformNode.
  66230. */
  66231. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66232. /**
  66233. * Removes a registered callback function.
  66234. * @param func callback function to remove
  66235. * @returns the TransformNode.
  66236. */
  66237. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66238. /**
  66239. * Gets the position of the current mesh in camera space
  66240. * @param camera defines the camera to use
  66241. * @returns a position
  66242. */
  66243. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66244. /**
  66245. * Returns the distance from the mesh to the active camera
  66246. * @param camera defines the camera to use
  66247. * @returns the distance
  66248. */
  66249. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66250. /**
  66251. * Clone the current transform node
  66252. * @param name Name of the new clone
  66253. * @param newParent New parent for the clone
  66254. * @param doNotCloneChildren Do not clone children hierarchy
  66255. * @returns the new transform node
  66256. */
  66257. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66258. /**
  66259. * Serializes the objects information.
  66260. * @param currentSerializationObject defines the object to serialize in
  66261. * @returns the serialized object
  66262. */
  66263. serialize(currentSerializationObject?: any): any;
  66264. /**
  66265. * Returns a new TransformNode object parsed from the source provided.
  66266. * @param parsedTransformNode is the source.
  66267. * @param scene the scne the object belongs to
  66268. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66269. * @returns a new TransformNode object parsed from the source provided.
  66270. */
  66271. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66272. /**
  66273. * Get all child-transformNodes of this node
  66274. * @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
  66275. * @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
  66276. * @returns an array of TransformNode
  66277. */
  66278. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66279. /**
  66280. * Releases resources associated with this transform node.
  66281. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66282. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66283. */
  66284. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66285. }
  66286. }
  66287. declare module BABYLON {
  66288. /**
  66289. * Class used to override all child animations of a given target
  66290. */
  66291. export class AnimationPropertiesOverride {
  66292. /**
  66293. * Gets or sets a value indicating if animation blending must be used
  66294. */
  66295. enableBlending: boolean;
  66296. /**
  66297. * Gets or sets the blending speed to use when enableBlending is true
  66298. */
  66299. blendingSpeed: number;
  66300. /**
  66301. * Gets or sets the default loop mode to use
  66302. */
  66303. loopMode: number;
  66304. }
  66305. }
  66306. declare module BABYLON {
  66307. /**
  66308. * Class used to store bone information
  66309. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  66310. */
  66311. export class Bone extends Node {
  66312. /**
  66313. * defines the bone name
  66314. */
  66315. name: string;
  66316. private static _tmpVecs;
  66317. private static _tmpQuat;
  66318. private static _tmpMats;
  66319. /**
  66320. * Gets the list of child bones
  66321. */
  66322. children: Bone[];
  66323. /** Gets the animations associated with this bone */
  66324. animations: Animation[];
  66325. /**
  66326. * Gets or sets bone length
  66327. */
  66328. length: number;
  66329. /**
  66330. * @hidden Internal only
  66331. * Set this value to map this bone to a different index in the transform matrices
  66332. * Set this value to -1 to exclude the bone from the transform matrices
  66333. */
  66334. _index: Nullable<number>;
  66335. private _skeleton;
  66336. private _localMatrix;
  66337. private _restPose;
  66338. private _baseMatrix;
  66339. private _absoluteTransform;
  66340. private _invertedAbsoluteTransform;
  66341. private _parent;
  66342. private _scalingDeterminant;
  66343. private _worldTransform;
  66344. private _localScaling;
  66345. private _localRotation;
  66346. private _localPosition;
  66347. private _needToDecompose;
  66348. private _needToCompose;
  66349. /** @hidden */
  66350. _linkedTransformNode: Nullable<TransformNode>;
  66351. /** @hidden */
  66352. /** @hidden */
  66353. _matrix: Matrix;
  66354. /**
  66355. * Create a new bone
  66356. * @param name defines the bone name
  66357. * @param skeleton defines the parent skeleton
  66358. * @param parentBone defines the parent (can be null if the bone is the root)
  66359. * @param localMatrix defines the local matrix
  66360. * @param restPose defines the rest pose matrix
  66361. * @param baseMatrix defines the base matrix
  66362. * @param index defines index of the bone in the hiearchy
  66363. */
  66364. constructor(
  66365. /**
  66366. * defines the bone name
  66367. */
  66368. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  66369. /**
  66370. * Gets the current object class name.
  66371. * @return the class name
  66372. */
  66373. getClassName(): string;
  66374. /**
  66375. * Gets the parent skeleton
  66376. * @returns a skeleton
  66377. */
  66378. getSkeleton(): Skeleton;
  66379. /**
  66380. * Gets parent bone
  66381. * @returns a bone or null if the bone is the root of the bone hierarchy
  66382. */
  66383. getParent(): Nullable<Bone>;
  66384. /**
  66385. * Returns an array containing the root bones
  66386. * @returns an array containing the root bones
  66387. */
  66388. getChildren(): Array<Bone>;
  66389. /**
  66390. * Sets the parent bone
  66391. * @param parent defines the parent (can be null if the bone is the root)
  66392. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66393. */
  66394. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  66395. /**
  66396. * Gets the local matrix
  66397. * @returns a matrix
  66398. */
  66399. getLocalMatrix(): Matrix;
  66400. /**
  66401. * Gets the base matrix (initial matrix which remains unchanged)
  66402. * @returns a matrix
  66403. */
  66404. getBaseMatrix(): Matrix;
  66405. /**
  66406. * Gets the rest pose matrix
  66407. * @returns a matrix
  66408. */
  66409. getRestPose(): Matrix;
  66410. /**
  66411. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  66412. */
  66413. getWorldMatrix(): Matrix;
  66414. /**
  66415. * Sets the local matrix to rest pose matrix
  66416. */
  66417. returnToRest(): void;
  66418. /**
  66419. * Gets the inverse of the absolute transform matrix.
  66420. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  66421. * @returns a matrix
  66422. */
  66423. getInvertedAbsoluteTransform(): Matrix;
  66424. /**
  66425. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  66426. * @returns a matrix
  66427. */
  66428. getAbsoluteTransform(): Matrix;
  66429. /**
  66430. * Links with the given transform node.
  66431. * The local matrix of this bone is copied from the transform node every frame.
  66432. * @param transformNode defines the transform node to link to
  66433. */
  66434. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  66435. /** Gets or sets current position (in local space) */
  66436. position: Vector3;
  66437. /** Gets or sets current rotation (in local space) */
  66438. rotation: Vector3;
  66439. /** Gets or sets current rotation quaternion (in local space) */
  66440. rotationQuaternion: Quaternion;
  66441. /** Gets or sets current scaling (in local space) */
  66442. scaling: Vector3;
  66443. /**
  66444. * Gets the animation properties override
  66445. */
  66446. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  66447. private _decompose;
  66448. private _compose;
  66449. /**
  66450. * Update the base and local matrices
  66451. * @param matrix defines the new base or local matrix
  66452. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66453. * @param updateLocalMatrix defines if the local matrix should be updated
  66454. */
  66455. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  66456. /** @hidden */
  66457. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  66458. /**
  66459. * Flag the bone as dirty (Forcing it to update everything)
  66460. */
  66461. markAsDirty(): void;
  66462. private _markAsDirtyAndCompose;
  66463. private _markAsDirtyAndDecompose;
  66464. /**
  66465. * Translate the bone in local or world space
  66466. * @param vec The amount to translate the bone
  66467. * @param space The space that the translation is in
  66468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66469. */
  66470. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66471. /**
  66472. * Set the postion of the bone in local or world space
  66473. * @param position The position to set the bone
  66474. * @param space The space that the position is in
  66475. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66476. */
  66477. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66478. /**
  66479. * Set the absolute position of the bone (world space)
  66480. * @param position The position to set the bone
  66481. * @param mesh The mesh that this bone is attached to
  66482. */
  66483. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  66484. /**
  66485. * Scale the bone on the x, y and z axes (in local space)
  66486. * @param x The amount to scale the bone on the x axis
  66487. * @param y The amount to scale the bone on the y axis
  66488. * @param z The amount to scale the bone on the z axis
  66489. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  66490. */
  66491. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  66492. /**
  66493. * Set the bone scaling in local space
  66494. * @param scale defines the scaling vector
  66495. */
  66496. setScale(scale: Vector3): void;
  66497. /**
  66498. * Gets the current scaling in local space
  66499. * @returns the current scaling vector
  66500. */
  66501. getScale(): Vector3;
  66502. /**
  66503. * Gets the current scaling in local space and stores it in a target vector
  66504. * @param result defines the target vector
  66505. */
  66506. getScaleToRef(result: Vector3): void;
  66507. /**
  66508. * Set the yaw, pitch, and roll of the bone in local or world space
  66509. * @param yaw The rotation of the bone on the y axis
  66510. * @param pitch The rotation of the bone on the x axis
  66511. * @param roll The rotation of the bone on the z axis
  66512. * @param space The space that the axes of rotation are in
  66513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66514. */
  66515. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  66516. /**
  66517. * Add a rotation to the bone on an axis in local or world space
  66518. * @param axis The axis to rotate the bone on
  66519. * @param amount The amount to rotate the bone
  66520. * @param space The space that the axis is in
  66521. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66522. */
  66523. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  66524. /**
  66525. * Set the rotation of the bone to a particular axis angle in local or world space
  66526. * @param axis The axis to rotate the bone on
  66527. * @param angle The angle that the bone should be rotated to
  66528. * @param space The space that the axis is in
  66529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66530. */
  66531. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  66532. /**
  66533. * Set the euler rotation of the bone in local of world space
  66534. * @param rotation The euler rotation that the bone should be set to
  66535. * @param space The space that the rotation is in
  66536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66537. */
  66538. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66539. /**
  66540. * Set the quaternion rotation of the bone in local of world space
  66541. * @param quat The quaternion rotation that the bone should be set to
  66542. * @param space The space that the rotation is in
  66543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66544. */
  66545. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  66546. /**
  66547. * Set the rotation matrix of the bone in local of world space
  66548. * @param rotMat The rotation matrix that the bone should be set to
  66549. * @param space The space that the rotation is in
  66550. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66551. */
  66552. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  66553. private _rotateWithMatrix;
  66554. private _getNegativeRotationToRef;
  66555. /**
  66556. * Get the position of the bone in local or world space
  66557. * @param space The space that the returned position is in
  66558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66559. * @returns The position of the bone
  66560. */
  66561. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66562. /**
  66563. * Copy the position of the bone to a vector3 in local or world space
  66564. * @param space The space that the returned position is in
  66565. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66566. * @param result The vector3 to copy the position to
  66567. */
  66568. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  66569. /**
  66570. * Get the absolute position of the bone (world space)
  66571. * @param mesh The mesh that this bone is attached to
  66572. * @returns The absolute position of the bone
  66573. */
  66574. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  66575. /**
  66576. * Copy the absolute position of the bone (world space) to the result param
  66577. * @param mesh The mesh that this bone is attached to
  66578. * @param result The vector3 to copy the absolute position to
  66579. */
  66580. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  66581. /**
  66582. * Compute the absolute transforms of this bone and its children
  66583. */
  66584. computeAbsoluteTransforms(): void;
  66585. /**
  66586. * Get the world direction from an axis that is in the local space of the bone
  66587. * @param localAxis The local direction that is used to compute the world direction
  66588. * @param mesh The mesh that this bone is attached to
  66589. * @returns The world direction
  66590. */
  66591. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66592. /**
  66593. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  66594. * @param localAxis The local direction that is used to compute the world direction
  66595. * @param mesh The mesh that this bone is attached to
  66596. * @param result The vector3 that the world direction will be copied to
  66597. */
  66598. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66599. /**
  66600. * Get the euler rotation of the bone in local or world space
  66601. * @param space The space that the rotation should be in
  66602. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66603. * @returns The euler rotation
  66604. */
  66605. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66606. /**
  66607. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  66608. * @param space The space that the rotation should be in
  66609. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66610. * @param result The vector3 that the rotation should be copied to
  66611. */
  66612. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66613. /**
  66614. * Get the quaternion rotation of the bone in either local or world space
  66615. * @param space The space that the rotation should be in
  66616. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66617. * @returns The quaternion rotation
  66618. */
  66619. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  66620. /**
  66621. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  66622. * @param space The space that the rotation should be in
  66623. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66624. * @param result The quaternion that the rotation should be copied to
  66625. */
  66626. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  66627. /**
  66628. * Get the rotation matrix of the bone in local or world space
  66629. * @param space The space that the rotation should be in
  66630. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66631. * @returns The rotation matrix
  66632. */
  66633. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  66634. /**
  66635. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  66636. * @param space The space that the rotation should be in
  66637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66638. * @param result The quaternion that the rotation should be copied to
  66639. */
  66640. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66641. /**
  66642. * Get the world position of a point that is in the local space of the bone
  66643. * @param position The local position
  66644. * @param mesh The mesh that this bone is attached to
  66645. * @returns The world position
  66646. */
  66647. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66648. /**
  66649. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66650. * @param position The local position
  66651. * @param mesh The mesh that this bone is attached to
  66652. * @param result The vector3 that the world position should be copied to
  66653. */
  66654. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66655. /**
  66656. * Get the local position of a point that is in world space
  66657. * @param position The world position
  66658. * @param mesh The mesh that this bone is attached to
  66659. * @returns The local position
  66660. */
  66661. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66662. /**
  66663. * Get the local position of a point that is in world space and copy it to the result param
  66664. * @param position The world position
  66665. * @param mesh The mesh that this bone is attached to
  66666. * @param result The vector3 that the local position should be copied to
  66667. */
  66668. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66669. }
  66670. }
  66671. declare module BABYLON {
  66672. /**
  66673. * Enum that determines the text-wrapping mode to use.
  66674. */
  66675. export enum InspectableType {
  66676. /**
  66677. * Checkbox for booleans
  66678. */
  66679. Checkbox = 0,
  66680. /**
  66681. * Sliders for numbers
  66682. */
  66683. Slider = 1,
  66684. /**
  66685. * Vector3
  66686. */
  66687. Vector3 = 2,
  66688. /**
  66689. * Quaternions
  66690. */
  66691. Quaternion = 3,
  66692. /**
  66693. * Color3
  66694. */
  66695. Color3 = 4
  66696. }
  66697. /**
  66698. * Interface used to define custom inspectable properties.
  66699. * This interface is used by the inspector to display custom property grids
  66700. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66701. */
  66702. export interface IInspectable {
  66703. /**
  66704. * Gets the label to display
  66705. */
  66706. label: string;
  66707. /**
  66708. * Gets the name of the property to edit
  66709. */
  66710. propertyName: string;
  66711. /**
  66712. * Gets the type of the editor to use
  66713. */
  66714. type: InspectableType;
  66715. /**
  66716. * Gets the minimum value of the property when using in "slider" mode
  66717. */
  66718. min?: number;
  66719. /**
  66720. * Gets the maximum value of the property when using in "slider" mode
  66721. */
  66722. max?: number;
  66723. /**
  66724. * Gets the setp to use when using in "slider" mode
  66725. */
  66726. step?: number;
  66727. }
  66728. }
  66729. declare module BABYLON {
  66730. /**
  66731. * Class for creating a cube texture
  66732. */
  66733. export class CubeTexture extends BaseTexture {
  66734. private _delayedOnLoad;
  66735. /**
  66736. * The url of the texture
  66737. */
  66738. url: string;
  66739. /**
  66740. * Gets or sets the center of the bounding box associated with the cube texture.
  66741. * It must define where the camera used to render the texture was set
  66742. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66743. */
  66744. boundingBoxPosition: Vector3;
  66745. private _boundingBoxSize;
  66746. /**
  66747. * Gets or sets the size of the bounding box associated with the cube texture
  66748. * When defined, the cubemap will switch to local mode
  66749. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66750. * @example https://www.babylonjs-playground.com/#RNASML
  66751. */
  66752. /**
  66753. * Returns the bounding box size
  66754. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66755. */
  66756. boundingBoxSize: Vector3;
  66757. protected _rotationY: number;
  66758. /**
  66759. * Sets texture matrix rotation angle around Y axis in radians.
  66760. */
  66761. /**
  66762. * Gets texture matrix rotation angle around Y axis radians.
  66763. */
  66764. rotationY: number;
  66765. /**
  66766. * Are mip maps generated for this texture or not.
  66767. */
  66768. readonly noMipmap: boolean;
  66769. private _noMipmap;
  66770. private _files;
  66771. private _extensions;
  66772. private _textureMatrix;
  66773. private _format;
  66774. private _createPolynomials;
  66775. /** @hidden */
  66776. _prefiltered: boolean;
  66777. /**
  66778. * Creates a cube texture from an array of image urls
  66779. * @param files defines an array of image urls
  66780. * @param scene defines the hosting scene
  66781. * @param noMipmap specifies if mip maps are not used
  66782. * @returns a cube texture
  66783. */
  66784. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  66785. /**
  66786. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  66787. * @param url defines the url of the prefiltered texture
  66788. * @param scene defines the scene the texture is attached to
  66789. * @param forcedExtension defines the extension of the file if different from the url
  66790. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66791. * @return the prefiltered texture
  66792. */
  66793. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  66794. /**
  66795. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  66796. * as prefiltered data.
  66797. * @param rootUrl defines the url of the texture or the root name of the six images
  66798. * @param scene defines the scene the texture is attached to
  66799. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  66800. * @param noMipmap defines if mipmaps should be created or not
  66801. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  66802. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  66803. * @param onError defines a callback triggered in case of error during load
  66804. * @param format defines the internal format to use for the texture once loaded
  66805. * @param prefiltered defines whether or not the texture is created from prefiltered data
  66806. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  66807. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66808. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66809. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66810. * @return the cube texture
  66811. */
  66812. 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);
  66813. /**
  66814. * Get the current class name of the texture useful for serialization or dynamic coding.
  66815. * @returns "CubeTexture"
  66816. */
  66817. getClassName(): string;
  66818. /**
  66819. * Update the url (and optional buffer) of this texture if url was null during construction.
  66820. * @param url the url of the texture
  66821. * @param forcedExtension defines the extension to use
  66822. * @param onLoad callback called when the texture is loaded (defaults to null)
  66823. */
  66824. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  66825. /**
  66826. * Delays loading of the cube texture
  66827. * @param forcedExtension defines the extension to use
  66828. */
  66829. delayLoad(forcedExtension?: string): void;
  66830. /**
  66831. * Returns the reflection texture matrix
  66832. * @returns the reflection texture matrix
  66833. */
  66834. getReflectionTextureMatrix(): Matrix;
  66835. /**
  66836. * Sets the reflection texture matrix
  66837. * @param value Reflection texture matrix
  66838. */
  66839. setReflectionTextureMatrix(value: Matrix): void;
  66840. /**
  66841. * Parses text to create a cube texture
  66842. * @param parsedTexture define the serialized text to read from
  66843. * @param scene defines the hosting scene
  66844. * @param rootUrl defines the root url of the cube texture
  66845. * @returns a cube texture
  66846. */
  66847. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  66848. /**
  66849. * Makes a clone, or deep copy, of the cube texture
  66850. * @returns a new cube texture
  66851. */
  66852. clone(): CubeTexture;
  66853. }
  66854. }
  66855. declare module BABYLON {
  66856. /** @hidden */
  66857. export var postprocessVertexShader: {
  66858. name: string;
  66859. shader: string;
  66860. };
  66861. }
  66862. declare module BABYLON {
  66863. /**
  66864. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66865. * This is the base of the follow, arc rotate cameras and Free camera
  66866. * @see http://doc.babylonjs.com/features/cameras
  66867. */
  66868. export class TargetCamera extends Camera {
  66869. private static _RigCamTransformMatrix;
  66870. private static _TargetTransformMatrix;
  66871. private static _TargetFocalPoint;
  66872. /**
  66873. * Define the current direction the camera is moving to
  66874. */
  66875. cameraDirection: Vector3;
  66876. /**
  66877. * Define the current rotation the camera is rotating to
  66878. */
  66879. cameraRotation: Vector2;
  66880. /**
  66881. * When set, the up vector of the camera will be updated by the rotation of the camera
  66882. */
  66883. updateUpVectorFromRotation: boolean;
  66884. private _tmpQuaternion;
  66885. /**
  66886. * Define the current rotation of the camera
  66887. */
  66888. rotation: Vector3;
  66889. /**
  66890. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66891. */
  66892. rotationQuaternion: Quaternion;
  66893. /**
  66894. * Define the current speed of the camera
  66895. */
  66896. speed: number;
  66897. /**
  66898. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66899. * around all axis.
  66900. */
  66901. noRotationConstraint: boolean;
  66902. /**
  66903. * Define the current target of the camera as an object or a position.
  66904. */
  66905. lockedTarget: any;
  66906. /** @hidden */
  66907. _currentTarget: Vector3;
  66908. /** @hidden */
  66909. _initialFocalDistance: number;
  66910. /** @hidden */
  66911. _viewMatrix: Matrix;
  66912. /** @hidden */
  66913. _camMatrix: Matrix;
  66914. /** @hidden */
  66915. _cameraTransformMatrix: Matrix;
  66916. /** @hidden */
  66917. _cameraRotationMatrix: Matrix;
  66918. /** @hidden */
  66919. _referencePoint: Vector3;
  66920. /** @hidden */
  66921. _transformedReferencePoint: Vector3;
  66922. protected _globalCurrentTarget: Vector3;
  66923. protected _globalCurrentUpVector: Vector3;
  66924. /** @hidden */
  66925. _reset: () => void;
  66926. private _defaultUp;
  66927. /**
  66928. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66929. * This is the base of the follow, arc rotate cameras and Free camera
  66930. * @see http://doc.babylonjs.com/features/cameras
  66931. * @param name Defines the name of the camera in the scene
  66932. * @param position Defines the start position of the camera in the scene
  66933. * @param scene Defines the scene the camera belongs to
  66934. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66935. */
  66936. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66937. /**
  66938. * Gets the position in front of the camera at a given distance.
  66939. * @param distance The distance from the camera we want the position to be
  66940. * @returns the position
  66941. */
  66942. getFrontPosition(distance: number): Vector3;
  66943. /** @hidden */
  66944. _getLockedTargetPosition(): Nullable<Vector3>;
  66945. private _storedPosition;
  66946. private _storedRotation;
  66947. private _storedRotationQuaternion;
  66948. /**
  66949. * Store current camera state of the camera (fov, position, rotation, etc..)
  66950. * @returns the camera
  66951. */
  66952. storeState(): Camera;
  66953. /**
  66954. * Restored camera state. You must call storeState() first
  66955. * @returns whether it was successful or not
  66956. * @hidden
  66957. */
  66958. _restoreStateValues(): boolean;
  66959. /** @hidden */
  66960. _initCache(): void;
  66961. /** @hidden */
  66962. _updateCache(ignoreParentClass?: boolean): void;
  66963. /** @hidden */
  66964. _isSynchronizedViewMatrix(): boolean;
  66965. /** @hidden */
  66966. _computeLocalCameraSpeed(): number;
  66967. /**
  66968. * Defines the target the camera should look at.
  66969. * This will automatically adapt alpha beta and radius to fit within the new target.
  66970. * @param target Defines the new target as a Vector or a mesh
  66971. */
  66972. setTarget(target: Vector3): void;
  66973. /**
  66974. * Return the current target position of the camera. This value is expressed in local space.
  66975. * @returns the target position
  66976. */
  66977. getTarget(): Vector3;
  66978. /** @hidden */
  66979. _decideIfNeedsToMove(): boolean;
  66980. /** @hidden */
  66981. _updatePosition(): void;
  66982. /** @hidden */
  66983. _checkInputs(): void;
  66984. protected _updateCameraRotationMatrix(): void;
  66985. /**
  66986. * 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)
  66987. * @returns the current camera
  66988. */
  66989. private _rotateUpVectorWithCameraRotationMatrix;
  66990. private _cachedRotationZ;
  66991. private _cachedQuaternionRotationZ;
  66992. /** @hidden */
  66993. _getViewMatrix(): Matrix;
  66994. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66995. /**
  66996. * @hidden
  66997. */
  66998. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66999. /**
  67000. * @hidden
  67001. */
  67002. _updateRigCameras(): void;
  67003. private _getRigCamPositionAndTarget;
  67004. /**
  67005. * Gets the current object class name.
  67006. * @return the class name
  67007. */
  67008. getClassName(): string;
  67009. }
  67010. }
  67011. declare module BABYLON {
  67012. /**
  67013. * @ignore
  67014. * This is a list of all the different input types that are available in the application.
  67015. * Fo instance: ArcRotateCameraGamepadInput...
  67016. */
  67017. export var CameraInputTypes: {};
  67018. /**
  67019. * This is the contract to implement in order to create a new input class.
  67020. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67021. */
  67022. export interface ICameraInput<TCamera extends Camera> {
  67023. /**
  67024. * Defines the camera the input is attached to.
  67025. */
  67026. camera: Nullable<TCamera>;
  67027. /**
  67028. * Gets the class name of the current intput.
  67029. * @returns the class name
  67030. */
  67031. getClassName(): string;
  67032. /**
  67033. * Get the friendly name associated with the input class.
  67034. * @returns the input friendly name
  67035. */
  67036. getSimpleName(): string;
  67037. /**
  67038. * Attach the input controls to a specific dom element to get the input from.
  67039. * @param element Defines the element the controls should be listened from
  67040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67041. */
  67042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67043. /**
  67044. * Detach the current controls from the specified dom element.
  67045. * @param element Defines the element to stop listening the inputs from
  67046. */
  67047. detachControl(element: Nullable<HTMLElement>): void;
  67048. /**
  67049. * Update the current camera state depending on the inputs that have been used this frame.
  67050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67051. */
  67052. checkInputs?: () => void;
  67053. }
  67054. /**
  67055. * Represents a map of input types to input instance or input index to input instance.
  67056. */
  67057. export interface CameraInputsMap<TCamera extends Camera> {
  67058. /**
  67059. * Accessor to the input by input type.
  67060. */
  67061. [name: string]: ICameraInput<TCamera>;
  67062. /**
  67063. * Accessor to the input by input index.
  67064. */
  67065. [idx: number]: ICameraInput<TCamera>;
  67066. }
  67067. /**
  67068. * This represents the input manager used within a camera.
  67069. * It helps dealing with all the different kind of input attached to a camera.
  67070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67071. */
  67072. export class CameraInputsManager<TCamera extends Camera> {
  67073. /**
  67074. * Defines the list of inputs attahed to the camera.
  67075. */
  67076. attached: CameraInputsMap<TCamera>;
  67077. /**
  67078. * Defines the dom element the camera is collecting inputs from.
  67079. * This is null if the controls have not been attached.
  67080. */
  67081. attachedElement: Nullable<HTMLElement>;
  67082. /**
  67083. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67084. */
  67085. noPreventDefault: boolean;
  67086. /**
  67087. * Defined the camera the input manager belongs to.
  67088. */
  67089. camera: TCamera;
  67090. /**
  67091. * Update the current camera state depending on the inputs that have been used this frame.
  67092. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67093. */
  67094. checkInputs: () => void;
  67095. /**
  67096. * Instantiate a new Camera Input Manager.
  67097. * @param camera Defines the camera the input manager blongs to
  67098. */
  67099. constructor(camera: TCamera);
  67100. /**
  67101. * Add an input method to a camera
  67102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67103. * @param input camera input method
  67104. */
  67105. add(input: ICameraInput<TCamera>): void;
  67106. /**
  67107. * Remove a specific input method from a camera
  67108. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67109. * @param inputToRemove camera input method
  67110. */
  67111. remove(inputToRemove: ICameraInput<TCamera>): void;
  67112. /**
  67113. * Remove a specific input type from a camera
  67114. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67115. * @param inputType the type of the input to remove
  67116. */
  67117. removeByType(inputType: string): void;
  67118. private _addCheckInputs;
  67119. /**
  67120. * Attach the input controls to the currently attached dom element to listen the events from.
  67121. * @param input Defines the input to attach
  67122. */
  67123. attachInput(input: ICameraInput<TCamera>): void;
  67124. /**
  67125. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67126. * @param element Defines the dom element to collect the events from
  67127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67128. */
  67129. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67130. /**
  67131. * Detach the current manager inputs controls from a specific dom element.
  67132. * @param element Defines the dom element to collect the events from
  67133. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67134. */
  67135. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67136. /**
  67137. * Rebuild the dynamic inputCheck function from the current list of
  67138. * defined inputs in the manager.
  67139. */
  67140. rebuildInputCheck(): void;
  67141. /**
  67142. * Remove all attached input methods from a camera
  67143. */
  67144. clear(): void;
  67145. /**
  67146. * Serialize the current input manager attached to a camera.
  67147. * This ensures than once parsed,
  67148. * the input associated to the camera will be identical to the current ones
  67149. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67150. */
  67151. serialize(serializedCamera: any): void;
  67152. /**
  67153. * Parses an input manager serialized JSON to restore the previous list of inputs
  67154. * and states associated to a camera.
  67155. * @param parsedCamera Defines the JSON to parse
  67156. */
  67157. parse(parsedCamera: any): void;
  67158. }
  67159. }
  67160. declare module BABYLON {
  67161. /**
  67162. * Gather the list of keyboard event types as constants.
  67163. */
  67164. export class KeyboardEventTypes {
  67165. /**
  67166. * The keydown event is fired when a key becomes active (pressed).
  67167. */
  67168. static readonly KEYDOWN: number;
  67169. /**
  67170. * The keyup event is fired when a key has been released.
  67171. */
  67172. static readonly KEYUP: number;
  67173. }
  67174. /**
  67175. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67176. */
  67177. export class KeyboardInfo {
  67178. /**
  67179. * Defines the type of event (KeyboardEventTypes)
  67180. */
  67181. type: number;
  67182. /**
  67183. * Defines the related dom event
  67184. */
  67185. event: KeyboardEvent;
  67186. /**
  67187. * Instantiates a new keyboard info.
  67188. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67189. * @param type Defines the type of event (KeyboardEventTypes)
  67190. * @param event Defines the related dom event
  67191. */
  67192. constructor(
  67193. /**
  67194. * Defines the type of event (KeyboardEventTypes)
  67195. */
  67196. type: number,
  67197. /**
  67198. * Defines the related dom event
  67199. */
  67200. event: KeyboardEvent);
  67201. }
  67202. /**
  67203. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67204. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67205. */
  67206. export class KeyboardInfoPre extends KeyboardInfo {
  67207. /**
  67208. * Defines the type of event (KeyboardEventTypes)
  67209. */
  67210. type: number;
  67211. /**
  67212. * Defines the related dom event
  67213. */
  67214. event: KeyboardEvent;
  67215. /**
  67216. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67217. */
  67218. skipOnPointerObservable: boolean;
  67219. /**
  67220. * Instantiates a new keyboard pre info.
  67221. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67222. * @param type Defines the type of event (KeyboardEventTypes)
  67223. * @param event Defines the related dom event
  67224. */
  67225. constructor(
  67226. /**
  67227. * Defines the type of event (KeyboardEventTypes)
  67228. */
  67229. type: number,
  67230. /**
  67231. * Defines the related dom event
  67232. */
  67233. event: KeyboardEvent);
  67234. }
  67235. }
  67236. declare module BABYLON {
  67237. /**
  67238. * Manage the keyboard inputs to control the movement of a free camera.
  67239. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67240. */
  67241. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67242. /**
  67243. * Defines the camera the input is attached to.
  67244. */
  67245. camera: FreeCamera;
  67246. /**
  67247. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67248. */
  67249. keysUp: number[];
  67250. /**
  67251. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67252. */
  67253. keysDown: number[];
  67254. /**
  67255. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67256. */
  67257. keysLeft: number[];
  67258. /**
  67259. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67260. */
  67261. keysRight: number[];
  67262. private _keys;
  67263. private _onCanvasBlurObserver;
  67264. private _onKeyboardObserver;
  67265. private _engine;
  67266. private _scene;
  67267. /**
  67268. * Attach the input controls to a specific dom element to get the input from.
  67269. * @param element Defines the element the controls should be listened from
  67270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67271. */
  67272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67273. /**
  67274. * Detach the current controls from the specified dom element.
  67275. * @param element Defines the element to stop listening the inputs from
  67276. */
  67277. detachControl(element: Nullable<HTMLElement>): void;
  67278. /**
  67279. * Update the current camera state depending on the inputs that have been used this frame.
  67280. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67281. */
  67282. checkInputs(): void;
  67283. /**
  67284. * Gets the class name of the current intput.
  67285. * @returns the class name
  67286. */
  67287. getClassName(): string;
  67288. /** @hidden */
  67289. _onLostFocus(): void;
  67290. /**
  67291. * Get the friendly name associated with the input class.
  67292. * @returns the input friendly name
  67293. */
  67294. getSimpleName(): string;
  67295. }
  67296. }
  67297. declare module BABYLON {
  67298. /**
  67299. * Interface describing all the common properties and methods a shadow light needs to implement.
  67300. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  67301. * as well as binding the different shadow properties to the effects.
  67302. */
  67303. export interface IShadowLight extends Light {
  67304. /**
  67305. * The light id in the scene (used in scene.findLighById for instance)
  67306. */
  67307. id: string;
  67308. /**
  67309. * The position the shdow will be casted from.
  67310. */
  67311. position: Vector3;
  67312. /**
  67313. * In 2d mode (needCube being false), the direction used to cast the shadow.
  67314. */
  67315. direction: Vector3;
  67316. /**
  67317. * The transformed position. Position of the light in world space taking parenting in account.
  67318. */
  67319. transformedPosition: Vector3;
  67320. /**
  67321. * The transformed direction. Direction of the light in world space taking parenting in account.
  67322. */
  67323. transformedDirection: Vector3;
  67324. /**
  67325. * The friendly name of the light in the scene.
  67326. */
  67327. name: string;
  67328. /**
  67329. * Defines the shadow projection clipping minimum z value.
  67330. */
  67331. shadowMinZ: number;
  67332. /**
  67333. * Defines the shadow projection clipping maximum z value.
  67334. */
  67335. shadowMaxZ: number;
  67336. /**
  67337. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67338. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67339. */
  67340. computeTransformedInformation(): boolean;
  67341. /**
  67342. * Gets the scene the light belongs to.
  67343. * @returns The scene
  67344. */
  67345. getScene(): Scene;
  67346. /**
  67347. * Callback defining a custom Projection Matrix Builder.
  67348. * This can be used to override the default projection matrix computation.
  67349. */
  67350. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67351. /**
  67352. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67353. * @param matrix The materix to updated with the projection information
  67354. * @param viewMatrix The transform matrix of the light
  67355. * @param renderList The list of mesh to render in the map
  67356. * @returns The current light
  67357. */
  67358. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67359. /**
  67360. * Gets the current depth scale used in ESM.
  67361. * @returns The scale
  67362. */
  67363. getDepthScale(): number;
  67364. /**
  67365. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67366. * @returns true if a cube texture needs to be use
  67367. */
  67368. needCube(): boolean;
  67369. /**
  67370. * Detects if the projection matrix requires to be recomputed this frame.
  67371. * @returns true if it requires to be recomputed otherwise, false.
  67372. */
  67373. needProjectionMatrixCompute(): boolean;
  67374. /**
  67375. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67376. */
  67377. forceProjectionMatrixCompute(): void;
  67378. /**
  67379. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67380. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67381. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67382. */
  67383. getShadowDirection(faceIndex?: number): Vector3;
  67384. /**
  67385. * Gets the minZ used for shadow according to both the scene and the light.
  67386. * @param activeCamera The camera we are returning the min for
  67387. * @returns the depth min z
  67388. */
  67389. getDepthMinZ(activeCamera: Camera): number;
  67390. /**
  67391. * Gets the maxZ used for shadow according to both the scene and the light.
  67392. * @param activeCamera The camera we are returning the max for
  67393. * @returns the depth max z
  67394. */
  67395. getDepthMaxZ(activeCamera: Camera): number;
  67396. }
  67397. /**
  67398. * Base implementation IShadowLight
  67399. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  67400. */
  67401. export abstract class ShadowLight extends Light implements IShadowLight {
  67402. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67403. protected _position: Vector3;
  67404. protected _setPosition(value: Vector3): void;
  67405. /**
  67406. * Sets the position the shadow will be casted from. Also use as the light position for both
  67407. * point and spot lights.
  67408. */
  67409. /**
  67410. * Sets the position the shadow will be casted from. Also use as the light position for both
  67411. * point and spot lights.
  67412. */
  67413. position: Vector3;
  67414. protected _direction: Vector3;
  67415. protected _setDirection(value: Vector3): void;
  67416. /**
  67417. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  67418. * Also use as the light direction on spot and directional lights.
  67419. */
  67420. /**
  67421. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  67422. * Also use as the light direction on spot and directional lights.
  67423. */
  67424. direction: Vector3;
  67425. private _shadowMinZ;
  67426. /**
  67427. * Gets the shadow projection clipping minimum z value.
  67428. */
  67429. /**
  67430. * Sets the shadow projection clipping minimum z value.
  67431. */
  67432. shadowMinZ: number;
  67433. private _shadowMaxZ;
  67434. /**
  67435. * Sets the shadow projection clipping maximum z value.
  67436. */
  67437. /**
  67438. * Gets the shadow projection clipping maximum z value.
  67439. */
  67440. shadowMaxZ: number;
  67441. /**
  67442. * Callback defining a custom Projection Matrix Builder.
  67443. * This can be used to override the default projection matrix computation.
  67444. */
  67445. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67446. /**
  67447. * The transformed position. Position of the light in world space taking parenting in account.
  67448. */
  67449. transformedPosition: Vector3;
  67450. /**
  67451. * The transformed direction. Direction of the light in world space taking parenting in account.
  67452. */
  67453. transformedDirection: Vector3;
  67454. private _needProjectionMatrixCompute;
  67455. /**
  67456. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67457. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67458. */
  67459. computeTransformedInformation(): boolean;
  67460. /**
  67461. * Return the depth scale used for the shadow map.
  67462. * @returns the depth scale.
  67463. */
  67464. getDepthScale(): number;
  67465. /**
  67466. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67467. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67468. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67469. */
  67470. getShadowDirection(faceIndex?: number): Vector3;
  67471. /**
  67472. * Returns the ShadowLight absolute position in the World.
  67473. * @returns the position vector in world space
  67474. */
  67475. getAbsolutePosition(): Vector3;
  67476. /**
  67477. * Sets the ShadowLight direction toward the passed target.
  67478. * @param target The point to target in local space
  67479. * @returns the updated ShadowLight direction
  67480. */
  67481. setDirectionToTarget(target: Vector3): Vector3;
  67482. /**
  67483. * Returns the light rotation in euler definition.
  67484. * @returns the x y z rotation in local space.
  67485. */
  67486. getRotation(): Vector3;
  67487. /**
  67488. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67489. * @returns true if a cube texture needs to be use
  67490. */
  67491. needCube(): boolean;
  67492. /**
  67493. * Detects if the projection matrix requires to be recomputed this frame.
  67494. * @returns true if it requires to be recomputed otherwise, false.
  67495. */
  67496. needProjectionMatrixCompute(): boolean;
  67497. /**
  67498. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67499. */
  67500. forceProjectionMatrixCompute(): void;
  67501. /** @hidden */
  67502. _initCache(): void;
  67503. /** @hidden */
  67504. _isSynchronized(): boolean;
  67505. /**
  67506. * Computes the world matrix of the node
  67507. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67508. * @returns the world matrix
  67509. */
  67510. computeWorldMatrix(force?: boolean): Matrix;
  67511. /**
  67512. * Gets the minZ used for shadow according to both the scene and the light.
  67513. * @param activeCamera The camera we are returning the min for
  67514. * @returns the depth min z
  67515. */
  67516. getDepthMinZ(activeCamera: Camera): number;
  67517. /**
  67518. * Gets the maxZ used for shadow according to both the scene and the light.
  67519. * @param activeCamera The camera we are returning the max for
  67520. * @returns the depth max z
  67521. */
  67522. getDepthMaxZ(activeCamera: Camera): number;
  67523. /**
  67524. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67525. * @param matrix The materix to updated with the projection information
  67526. * @param viewMatrix The transform matrix of the light
  67527. * @param renderList The list of mesh to render in the map
  67528. * @returns The current light
  67529. */
  67530. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67531. }
  67532. }
  67533. declare module BABYLON {
  67534. /**
  67535. * "Static Class" containing the most commonly used helper while dealing with material for
  67536. * rendering purpose.
  67537. *
  67538. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  67539. *
  67540. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  67541. */
  67542. export class MaterialHelper {
  67543. /**
  67544. * Bind the current view position to an effect.
  67545. * @param effect The effect to be bound
  67546. * @param scene The scene the eyes position is used from
  67547. */
  67548. static BindEyePosition(effect: Effect, scene: Scene): void;
  67549. /**
  67550. * Helps preparing the defines values about the UVs in used in the effect.
  67551. * UVs are shared as much as we can accross channels in the shaders.
  67552. * @param texture The texture we are preparing the UVs for
  67553. * @param defines The defines to update
  67554. * @param key The channel key "diffuse", "specular"... used in the shader
  67555. */
  67556. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  67557. /**
  67558. * Binds a texture matrix value to its corrsponding uniform
  67559. * @param texture The texture to bind the matrix for
  67560. * @param uniformBuffer The uniform buffer receivin the data
  67561. * @param key The channel key "diffuse", "specular"... used in the shader
  67562. */
  67563. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  67564. /**
  67565. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  67566. * @param mesh defines the current mesh
  67567. * @param scene defines the current scene
  67568. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  67569. * @param pointsCloud defines if point cloud rendering has to be turned on
  67570. * @param fogEnabled defines if fog has to be turned on
  67571. * @param alphaTest defines if alpha testing has to be turned on
  67572. * @param defines defines the current list of defines
  67573. */
  67574. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  67575. /**
  67576. * Helper used to prepare the list of defines associated with frame values for shader compilation
  67577. * @param scene defines the current scene
  67578. * @param engine defines the current engine
  67579. * @param defines specifies the list of active defines
  67580. * @param useInstances defines if instances have to be turned on
  67581. * @param useClipPlane defines if clip plane have to be turned on
  67582. */
  67583. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  67584. /**
  67585. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67586. * @param mesh The mesh containing the geometry data we will draw
  67587. * @param defines The defines to update
  67588. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67589. * @param useBones Precise whether bones should be used or not (override mesh info)
  67590. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67591. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67592. * @returns false if defines are considered not dirty and have not been checked
  67593. */
  67594. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  67595. /**
  67596. * Prepares the defines related to the light information passed in parameter
  67597. * @param scene The scene we are intending to draw
  67598. * @param mesh The mesh the effect is compiling for
  67599. * @param defines The defines to update
  67600. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67601. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67602. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67603. * @returns true if normals will be required for the rest of the effect
  67604. */
  67605. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  67606. /**
  67607. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67608. * that won t be acctive due to defines being turned off.
  67609. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67610. * @param samplersList The samplers list
  67611. * @param defines The defines helping in the list generation
  67612. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67613. */
  67614. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  67615. /**
  67616. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67617. * @param defines The defines to update while falling back
  67618. * @param fallbacks The authorized effect fallbacks
  67619. * @param maxSimultaneousLights The maximum number of lights allowed
  67620. * @param rank the current rank of the Effect
  67621. * @returns The newly affected rank
  67622. */
  67623. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  67624. /**
  67625. * Prepares the list of attributes required for morph targets according to the effect defines.
  67626. * @param attribs The current list of supported attribs
  67627. * @param mesh The mesh to prepare the morph targets attributes for
  67628. * @param defines The current Defines of the effect
  67629. */
  67630. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  67631. /**
  67632. * Prepares the list of attributes required for bones according to the effect defines.
  67633. * @param attribs The current list of supported attribs
  67634. * @param mesh The mesh to prepare the bones attributes for
  67635. * @param defines The current Defines of the effect
  67636. * @param fallbacks The current efffect fallback strategy
  67637. */
  67638. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  67639. /**
  67640. * Prepares the list of attributes required for instances according to the effect defines.
  67641. * @param attribs The current list of supported attribs
  67642. * @param defines The current Defines of the effect
  67643. */
  67644. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  67645. /**
  67646. * Binds the light shadow information to the effect for the given mesh.
  67647. * @param light The light containing the generator
  67648. * @param scene The scene the lights belongs to
  67649. * @param mesh The mesh we are binding the information to render
  67650. * @param lightIndex The light index in the effect used to render the mesh
  67651. * @param effect The effect we are binding the data to
  67652. */
  67653. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  67654. /**
  67655. * Binds the light information to the effect.
  67656. * @param light The light containing the generator
  67657. * @param effect The effect we are binding the data to
  67658. * @param lightIndex The light index in the effect used to render
  67659. */
  67660. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  67661. /**
  67662. * Binds the lights information from the scene to the effect for the given mesh.
  67663. * @param scene The scene the lights belongs to
  67664. * @param mesh The mesh we are binding the information to render
  67665. * @param effect The effect we are binding the data to
  67666. * @param defines The generated defines for the effect
  67667. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67668. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67669. */
  67670. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  67671. private static _tempFogColor;
  67672. /**
  67673. * Binds the fog information from the scene to the effect for the given mesh.
  67674. * @param scene The scene the lights belongs to
  67675. * @param mesh The mesh we are binding the information to render
  67676. * @param effect The effect we are binding the data to
  67677. * @param linearSpace Defines if the fog effect is applied in linear space
  67678. */
  67679. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  67680. /**
  67681. * Binds the bones information from the mesh to the effect.
  67682. * @param mesh The mesh we are binding the information to render
  67683. * @param effect The effect we are binding the data to
  67684. */
  67685. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  67686. /**
  67687. * Binds the morph targets information from the mesh to the effect.
  67688. * @param abstractMesh The mesh we are binding the information to render
  67689. * @param effect The effect we are binding the data to
  67690. */
  67691. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  67692. /**
  67693. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67694. * @param defines The generated defines used in the effect
  67695. * @param effect The effect we are binding the data to
  67696. * @param scene The scene we are willing to render with logarithmic scale for
  67697. */
  67698. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67699. /**
  67700. * Binds the clip plane information from the scene to the effect.
  67701. * @param scene The scene the clip plane information are extracted from
  67702. * @param effect The effect we are binding the data to
  67703. */
  67704. static BindClipPlane(effect: Effect, scene: Scene): void;
  67705. }
  67706. }
  67707. declare module BABYLON {
  67708. /** @hidden */
  67709. export var kernelBlurVaryingDeclaration: {
  67710. name: string;
  67711. shader: string;
  67712. };
  67713. }
  67714. declare module BABYLON {
  67715. /** @hidden */
  67716. export var kernelBlurFragment: {
  67717. name: string;
  67718. shader: string;
  67719. };
  67720. }
  67721. declare module BABYLON {
  67722. /** @hidden */
  67723. export var kernelBlurFragment2: {
  67724. name: string;
  67725. shader: string;
  67726. };
  67727. }
  67728. declare module BABYLON {
  67729. /** @hidden */
  67730. export var kernelBlurPixelShader: {
  67731. name: string;
  67732. shader: string;
  67733. };
  67734. }
  67735. declare module BABYLON {
  67736. /** @hidden */
  67737. export var kernelBlurVertex: {
  67738. name: string;
  67739. shader: string;
  67740. };
  67741. }
  67742. declare module BABYLON {
  67743. /** @hidden */
  67744. export var kernelBlurVertexShader: {
  67745. name: string;
  67746. shader: string;
  67747. };
  67748. }
  67749. declare module BABYLON {
  67750. /**
  67751. * The Blur Post Process which blurs an image based on a kernel and direction.
  67752. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67753. */
  67754. export class BlurPostProcess extends PostProcess {
  67755. /** The direction in which to blur the image. */
  67756. direction: Vector2;
  67757. private blockCompilation;
  67758. protected _kernel: number;
  67759. protected _idealKernel: number;
  67760. protected _packedFloat: boolean;
  67761. private _staticDefines;
  67762. /**
  67763. * Sets the length in pixels of the blur sample region
  67764. */
  67765. /**
  67766. * Gets the length in pixels of the blur sample region
  67767. */
  67768. kernel: number;
  67769. /**
  67770. * Sets wether or not the blur needs to unpack/repack floats
  67771. */
  67772. /**
  67773. * Gets wether or not the blur is unpacking/repacking floats
  67774. */
  67775. packedFloat: boolean;
  67776. /**
  67777. * Creates a new instance BlurPostProcess
  67778. * @param name The name of the effect.
  67779. * @param direction The direction in which to blur the image.
  67780. * @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.
  67781. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67782. * @param camera The camera to apply the render pass to.
  67783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67784. * @param engine The engine which the post process will be applied. (default: current engine)
  67785. * @param reusable If the post process can be reused on the same frame. (default: false)
  67786. * @param textureType Type of textures used when performing the post process. (default: 0)
  67787. * @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)
  67788. */
  67789. constructor(name: string,
  67790. /** The direction in which to blur the image. */
  67791. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67792. /**
  67793. * Updates the effect with the current post process compile time values and recompiles the shader.
  67794. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67795. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67796. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67797. * @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
  67798. * @param onCompiled Called when the shader has been compiled.
  67799. * @param onError Called if there is an error when compiling a shader.
  67800. */
  67801. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67802. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67803. /**
  67804. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67805. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67806. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67807. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67808. * The gaps between physical kernels are compensated for in the weighting of the samples
  67809. * @param idealKernel Ideal blur kernel.
  67810. * @return Nearest best kernel.
  67811. */
  67812. protected _nearestBestKernel(idealKernel: number): number;
  67813. /**
  67814. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67815. * @param x The point on the Gaussian distribution to sample.
  67816. * @return the value of the Gaussian function at x.
  67817. */
  67818. protected _gaussianWeight(x: number): number;
  67819. /**
  67820. * Generates a string that can be used as a floating point number in GLSL.
  67821. * @param x Value to print.
  67822. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67823. * @return GLSL float string.
  67824. */
  67825. protected _glslFloat(x: number, decimalFigures?: number): string;
  67826. }
  67827. }
  67828. declare module BABYLON {
  67829. /** @hidden */
  67830. export var shadowMapPixelShader: {
  67831. name: string;
  67832. shader: string;
  67833. };
  67834. }
  67835. declare module BABYLON {
  67836. /** @hidden */
  67837. export var bonesDeclaration: {
  67838. name: string;
  67839. shader: string;
  67840. };
  67841. }
  67842. declare module BABYLON {
  67843. /** @hidden */
  67844. export var morphTargetsVertexGlobalDeclaration: {
  67845. name: string;
  67846. shader: string;
  67847. };
  67848. }
  67849. declare module BABYLON {
  67850. /** @hidden */
  67851. export var morphTargetsVertexDeclaration: {
  67852. name: string;
  67853. shader: string;
  67854. };
  67855. }
  67856. declare module BABYLON {
  67857. /** @hidden */
  67858. export var instancesDeclaration: {
  67859. name: string;
  67860. shader: string;
  67861. };
  67862. }
  67863. declare module BABYLON {
  67864. /** @hidden */
  67865. export var helperFunctions: {
  67866. name: string;
  67867. shader: string;
  67868. };
  67869. }
  67870. declare module BABYLON {
  67871. /** @hidden */
  67872. export var morphTargetsVertex: {
  67873. name: string;
  67874. shader: string;
  67875. };
  67876. }
  67877. declare module BABYLON {
  67878. /** @hidden */
  67879. export var instancesVertex: {
  67880. name: string;
  67881. shader: string;
  67882. };
  67883. }
  67884. declare module BABYLON {
  67885. /** @hidden */
  67886. export var bonesVertex: {
  67887. name: string;
  67888. shader: string;
  67889. };
  67890. }
  67891. declare module BABYLON {
  67892. /** @hidden */
  67893. export var shadowMapVertexShader: {
  67894. name: string;
  67895. shader: string;
  67896. };
  67897. }
  67898. declare module BABYLON {
  67899. /** @hidden */
  67900. export var depthBoxBlurPixelShader: {
  67901. name: string;
  67902. shader: string;
  67903. };
  67904. }
  67905. declare module BABYLON {
  67906. /**
  67907. * Defines the options associated with the creation of a custom shader for a shadow generator.
  67908. */
  67909. export interface ICustomShaderOptions {
  67910. /**
  67911. * Gets or sets the custom shader name to use
  67912. */
  67913. shaderName: string;
  67914. /**
  67915. * The list of attribute names used in the shader
  67916. */
  67917. attributes?: string[];
  67918. /**
  67919. * The list of unifrom names used in the shader
  67920. */
  67921. uniforms?: string[];
  67922. /**
  67923. * The list of sampler names used in the shader
  67924. */
  67925. samplers?: string[];
  67926. /**
  67927. * The list of defines used in the shader
  67928. */
  67929. defines?: string[];
  67930. }
  67931. /**
  67932. * Interface to implement to create a shadow generator compatible with BJS.
  67933. */
  67934. export interface IShadowGenerator {
  67935. /**
  67936. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67937. * @returns The render target texture if present otherwise, null
  67938. */
  67939. getShadowMap(): Nullable<RenderTargetTexture>;
  67940. /**
  67941. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67942. * @returns The render target texture if the shadow map is present otherwise, null
  67943. */
  67944. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67945. /**
  67946. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67947. * @param subMesh The submesh we want to render in the shadow map
  67948. * @param useInstances Defines wether will draw in the map using instances
  67949. * @returns true if ready otherwise, false
  67950. */
  67951. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67952. /**
  67953. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67954. * @param defines Defines of the material we want to update
  67955. * @param lightIndex Index of the light in the enabled light list of the material
  67956. */
  67957. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67958. /**
  67959. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67960. * defined in the generator but impacting the effect).
  67961. * It implies the unifroms available on the materials are the standard BJS ones.
  67962. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67963. * @param effect The effect we are binfing the information for
  67964. */
  67965. bindShadowLight(lightIndex: string, effect: Effect): void;
  67966. /**
  67967. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67968. * (eq to shadow prjection matrix * light transform matrix)
  67969. * @returns The transform matrix used to create the shadow map
  67970. */
  67971. getTransformMatrix(): Matrix;
  67972. /**
  67973. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67974. * Cube and 2D textures for instance.
  67975. */
  67976. recreateShadowMap(): void;
  67977. /**
  67978. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67979. * @param onCompiled Callback triggered at the and of the effects compilation
  67980. * @param options Sets of optional options forcing the compilation with different modes
  67981. */
  67982. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67983. useInstances: boolean;
  67984. }>): void;
  67985. /**
  67986. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67987. * @param options Sets of optional options forcing the compilation with different modes
  67988. * @returns A promise that resolves when the compilation completes
  67989. */
  67990. forceCompilationAsync(options?: Partial<{
  67991. useInstances: boolean;
  67992. }>): Promise<void>;
  67993. /**
  67994. * Serializes the shadow generator setup to a json object.
  67995. * @returns The serialized JSON object
  67996. */
  67997. serialize(): any;
  67998. /**
  67999. * Disposes the Shadow map and related Textures and effects.
  68000. */
  68001. dispose(): void;
  68002. }
  68003. /**
  68004. * Default implementation IShadowGenerator.
  68005. * This is the main object responsible of generating shadows in the framework.
  68006. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68007. */
  68008. export class ShadowGenerator implements IShadowGenerator {
  68009. /**
  68010. * Shadow generator mode None: no filtering applied.
  68011. */
  68012. static readonly FILTER_NONE: number;
  68013. /**
  68014. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68015. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68016. */
  68017. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68018. /**
  68019. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68020. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68021. */
  68022. static readonly FILTER_POISSONSAMPLING: number;
  68023. /**
  68024. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68025. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68026. */
  68027. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68028. /**
  68029. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68030. * edge artifacts on steep falloff.
  68031. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68032. */
  68033. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68034. /**
  68035. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68036. * edge artifacts on steep falloff.
  68037. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68038. */
  68039. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68040. /**
  68041. * Shadow generator mode PCF: Percentage Closer Filtering
  68042. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68043. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68044. */
  68045. static readonly FILTER_PCF: number;
  68046. /**
  68047. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68048. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68049. * Contact Hardening
  68050. */
  68051. static readonly FILTER_PCSS: number;
  68052. /**
  68053. * Reserved for PCF and PCSS
  68054. * Highest Quality.
  68055. *
  68056. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68057. *
  68058. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68059. */
  68060. static readonly QUALITY_HIGH: number;
  68061. /**
  68062. * Reserved for PCF and PCSS
  68063. * Good tradeoff for quality/perf cross devices
  68064. *
  68065. * Execute PCF on a 3*3 kernel.
  68066. *
  68067. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68068. */
  68069. static readonly QUALITY_MEDIUM: number;
  68070. /**
  68071. * Reserved for PCF and PCSS
  68072. * The lowest quality but the fastest.
  68073. *
  68074. * Execute PCF on a 1*1 kernel.
  68075. *
  68076. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68077. */
  68078. static readonly QUALITY_LOW: number;
  68079. /** Gets or sets the custom shader name to use */
  68080. customShaderOptions: ICustomShaderOptions;
  68081. /**
  68082. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68083. */
  68084. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68085. /**
  68086. * Observable triggered before a mesh is rendered in the shadow map.
  68087. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68088. */
  68089. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68090. private _bias;
  68091. /**
  68092. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68093. */
  68094. /**
  68095. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68096. */
  68097. bias: number;
  68098. private _normalBias;
  68099. /**
  68100. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68101. */
  68102. /**
  68103. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68104. */
  68105. normalBias: number;
  68106. private _blurBoxOffset;
  68107. /**
  68108. * Gets the blur box offset: offset applied during the blur pass.
  68109. * Only useful if useKernelBlur = false
  68110. */
  68111. /**
  68112. * Sets the blur box offset: offset applied during the blur pass.
  68113. * Only useful if useKernelBlur = false
  68114. */
  68115. blurBoxOffset: number;
  68116. private _blurScale;
  68117. /**
  68118. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68119. * 2 means half of the size.
  68120. */
  68121. /**
  68122. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68123. * 2 means half of the size.
  68124. */
  68125. blurScale: number;
  68126. private _blurKernel;
  68127. /**
  68128. * Gets the blur kernel: kernel size of the blur pass.
  68129. * Only useful if useKernelBlur = true
  68130. */
  68131. /**
  68132. * Sets the blur kernel: kernel size of the blur pass.
  68133. * Only useful if useKernelBlur = true
  68134. */
  68135. blurKernel: number;
  68136. private _useKernelBlur;
  68137. /**
  68138. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68139. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68140. */
  68141. /**
  68142. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68143. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68144. */
  68145. useKernelBlur: boolean;
  68146. private _depthScale;
  68147. /**
  68148. * Gets the depth scale used in ESM mode.
  68149. */
  68150. /**
  68151. * Sets the depth scale used in ESM mode.
  68152. * This can override the scale stored on the light.
  68153. */
  68154. depthScale: number;
  68155. private _filter;
  68156. /**
  68157. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68158. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68159. */
  68160. /**
  68161. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68162. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68163. */
  68164. filter: number;
  68165. /**
  68166. * Gets if the current filter is set to Poisson Sampling.
  68167. */
  68168. /**
  68169. * Sets the current filter to Poisson Sampling.
  68170. */
  68171. usePoissonSampling: boolean;
  68172. /**
  68173. * Gets if the current filter is set to ESM.
  68174. */
  68175. /**
  68176. * Sets the current filter is to ESM.
  68177. */
  68178. useExponentialShadowMap: boolean;
  68179. /**
  68180. * Gets if the current filter is set to filtered ESM.
  68181. */
  68182. /**
  68183. * Gets if the current filter is set to filtered ESM.
  68184. */
  68185. useBlurExponentialShadowMap: boolean;
  68186. /**
  68187. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68188. * exponential to prevent steep falloff artifacts).
  68189. */
  68190. /**
  68191. * Sets the current filter to "close ESM" (using the inverse of the
  68192. * exponential to prevent steep falloff artifacts).
  68193. */
  68194. useCloseExponentialShadowMap: boolean;
  68195. /**
  68196. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68197. * exponential to prevent steep falloff artifacts).
  68198. */
  68199. /**
  68200. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68201. * exponential to prevent steep falloff artifacts).
  68202. */
  68203. useBlurCloseExponentialShadowMap: boolean;
  68204. /**
  68205. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68206. */
  68207. /**
  68208. * Sets the current filter to "PCF" (percentage closer filtering).
  68209. */
  68210. usePercentageCloserFiltering: boolean;
  68211. private _filteringQuality;
  68212. /**
  68213. * Gets the PCF or PCSS Quality.
  68214. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68215. */
  68216. /**
  68217. * Sets the PCF or PCSS Quality.
  68218. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68219. */
  68220. filteringQuality: number;
  68221. /**
  68222. * Gets if the current filter is set to "PCSS" (contact hardening).
  68223. */
  68224. /**
  68225. * Sets the current filter to "PCSS" (contact hardening).
  68226. */
  68227. useContactHardeningShadow: boolean;
  68228. private _contactHardeningLightSizeUVRatio;
  68229. /**
  68230. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68231. * Using a ratio helps keeping shape stability independently of the map size.
  68232. *
  68233. * It does not account for the light projection as it was having too much
  68234. * instability during the light setup or during light position changes.
  68235. *
  68236. * Only valid if useContactHardeningShadow is true.
  68237. */
  68238. /**
  68239. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68240. * Using a ratio helps keeping shape stability independently of the map size.
  68241. *
  68242. * It does not account for the light projection as it was having too much
  68243. * instability during the light setup or during light position changes.
  68244. *
  68245. * Only valid if useContactHardeningShadow is true.
  68246. */
  68247. contactHardeningLightSizeUVRatio: number;
  68248. private _darkness;
  68249. /**
  68250. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68251. * 0 means strongest and 1 would means no shadow.
  68252. * @returns the darkness.
  68253. */
  68254. getDarkness(): number;
  68255. /**
  68256. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68257. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68258. * @returns the shadow generator allowing fluent coding.
  68259. */
  68260. setDarkness(darkness: number): ShadowGenerator;
  68261. private _transparencyShadow;
  68262. /**
  68263. * Sets the ability to have transparent shadow (boolean).
  68264. * @param transparent True if transparent else False
  68265. * @returns the shadow generator allowing fluent coding
  68266. */
  68267. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68268. private _shadowMap;
  68269. private _shadowMap2;
  68270. /**
  68271. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68272. * @returns The render target texture if present otherwise, null
  68273. */
  68274. getShadowMap(): Nullable<RenderTargetTexture>;
  68275. /**
  68276. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68277. * @returns The render target texture if the shadow map is present otherwise, null
  68278. */
  68279. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68280. /**
  68281. * Helper function to add a mesh and its descendants to the list of shadow casters.
  68282. * @param mesh Mesh to add
  68283. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  68284. * @returns the Shadow Generator itself
  68285. */
  68286. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68287. /**
  68288. * Helper function to remove a mesh and its descendants from the list of shadow casters
  68289. * @param mesh Mesh to remove
  68290. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  68291. * @returns the Shadow Generator itself
  68292. */
  68293. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68294. /**
  68295. * Controls the extent to which the shadows fade out at the edge of the frustum
  68296. * Used only by directionals and spots
  68297. */
  68298. frustumEdgeFalloff: number;
  68299. private _light;
  68300. /**
  68301. * Returns the associated light object.
  68302. * @returns the light generating the shadow
  68303. */
  68304. getLight(): IShadowLight;
  68305. /**
  68306. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  68307. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  68308. * It might on the other hand introduce peter panning.
  68309. */
  68310. forceBackFacesOnly: boolean;
  68311. private _scene;
  68312. private _lightDirection;
  68313. private _effect;
  68314. private _viewMatrix;
  68315. private _projectionMatrix;
  68316. private _transformMatrix;
  68317. private _cachedPosition;
  68318. private _cachedDirection;
  68319. private _cachedDefines;
  68320. private _currentRenderID;
  68321. private _boxBlurPostprocess;
  68322. private _kernelBlurXPostprocess;
  68323. private _kernelBlurYPostprocess;
  68324. private _blurPostProcesses;
  68325. private _mapSize;
  68326. private _currentFaceIndex;
  68327. private _currentFaceIndexCache;
  68328. private _textureType;
  68329. private _defaultTextureMatrix;
  68330. /** @hidden */
  68331. static _SceneComponentInitialization: (scene: Scene) => void;
  68332. /**
  68333. * Creates a ShadowGenerator object.
  68334. * A ShadowGenerator is the required tool to use the shadows.
  68335. * Each light casting shadows needs to use its own ShadowGenerator.
  68336. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  68337. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  68338. * @param light The light object generating the shadows.
  68339. * @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.
  68340. */
  68341. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  68342. private _initializeGenerator;
  68343. private _initializeShadowMap;
  68344. private _initializeBlurRTTAndPostProcesses;
  68345. private _renderForShadowMap;
  68346. private _renderSubMeshForShadowMap;
  68347. private _applyFilterValues;
  68348. /**
  68349. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68350. * @param onCompiled Callback triggered at the and of the effects compilation
  68351. * @param options Sets of optional options forcing the compilation with different modes
  68352. */
  68353. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68354. useInstances: boolean;
  68355. }>): void;
  68356. /**
  68357. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68358. * @param options Sets of optional options forcing the compilation with different modes
  68359. * @returns A promise that resolves when the compilation completes
  68360. */
  68361. forceCompilationAsync(options?: Partial<{
  68362. useInstances: boolean;
  68363. }>): Promise<void>;
  68364. /**
  68365. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68366. * @param subMesh The submesh we want to render in the shadow map
  68367. * @param useInstances Defines wether will draw in the map using instances
  68368. * @returns true if ready otherwise, false
  68369. */
  68370. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68371. /**
  68372. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68373. * @param defines Defines of the material we want to update
  68374. * @param lightIndex Index of the light in the enabled light list of the material
  68375. */
  68376. prepareDefines(defines: any, lightIndex: number): void;
  68377. /**
  68378. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68379. * defined in the generator but impacting the effect).
  68380. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68381. * @param effect The effect we are binfing the information for
  68382. */
  68383. bindShadowLight(lightIndex: string, effect: Effect): void;
  68384. /**
  68385. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68386. * (eq to shadow prjection matrix * light transform matrix)
  68387. * @returns The transform matrix used to create the shadow map
  68388. */
  68389. getTransformMatrix(): Matrix;
  68390. /**
  68391. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68392. * Cube and 2D textures for instance.
  68393. */
  68394. recreateShadowMap(): void;
  68395. private _disposeBlurPostProcesses;
  68396. private _disposeRTTandPostProcesses;
  68397. /**
  68398. * Disposes the ShadowGenerator.
  68399. * Returns nothing.
  68400. */
  68401. dispose(): void;
  68402. /**
  68403. * Serializes the shadow generator setup to a json object.
  68404. * @returns The serialized JSON object
  68405. */
  68406. serialize(): any;
  68407. /**
  68408. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  68409. * @param parsedShadowGenerator The JSON object to parse
  68410. * @param scene The scene to create the shadow map for
  68411. * @returns The parsed shadow generator
  68412. */
  68413. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  68414. }
  68415. }
  68416. declare module BABYLON {
  68417. /**
  68418. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  68419. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  68420. * 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.
  68421. */
  68422. export abstract class Light extends Node {
  68423. /**
  68424. * Falloff Default: light is falling off following the material specification:
  68425. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  68426. */
  68427. static readonly FALLOFF_DEFAULT: number;
  68428. /**
  68429. * Falloff Physical: light is falling off following the inverse squared distance law.
  68430. */
  68431. static readonly FALLOFF_PHYSICAL: number;
  68432. /**
  68433. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  68434. * to enhance interoperability with other engines.
  68435. */
  68436. static readonly FALLOFF_GLTF: number;
  68437. /**
  68438. * Falloff Standard: light is falling off like in the standard material
  68439. * to enhance interoperability with other materials.
  68440. */
  68441. static readonly FALLOFF_STANDARD: number;
  68442. /**
  68443. * If every light affecting the material is in this lightmapMode,
  68444. * material.lightmapTexture adds or multiplies
  68445. * (depends on material.useLightmapAsShadowmap)
  68446. * after every other light calculations.
  68447. */
  68448. static readonly LIGHTMAP_DEFAULT: number;
  68449. /**
  68450. * material.lightmapTexture as only diffuse lighting from this light
  68451. * adds only specular lighting from this light
  68452. * adds dynamic shadows
  68453. */
  68454. static readonly LIGHTMAP_SPECULAR: number;
  68455. /**
  68456. * material.lightmapTexture as only lighting
  68457. * no light calculation from this light
  68458. * only adds dynamic shadows from this light
  68459. */
  68460. static readonly LIGHTMAP_SHADOWSONLY: number;
  68461. /**
  68462. * Each light type uses the default quantity according to its type:
  68463. * point/spot lights use luminous intensity
  68464. * directional lights use illuminance
  68465. */
  68466. static readonly INTENSITYMODE_AUTOMATIC: number;
  68467. /**
  68468. * lumen (lm)
  68469. */
  68470. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  68471. /**
  68472. * candela (lm/sr)
  68473. */
  68474. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  68475. /**
  68476. * lux (lm/m^2)
  68477. */
  68478. static readonly INTENSITYMODE_ILLUMINANCE: number;
  68479. /**
  68480. * nit (cd/m^2)
  68481. */
  68482. static readonly INTENSITYMODE_LUMINANCE: number;
  68483. /**
  68484. * Light type const id of the point light.
  68485. */
  68486. static readonly LIGHTTYPEID_POINTLIGHT: number;
  68487. /**
  68488. * Light type const id of the directional light.
  68489. */
  68490. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  68491. /**
  68492. * Light type const id of the spot light.
  68493. */
  68494. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  68495. /**
  68496. * Light type const id of the hemispheric light.
  68497. */
  68498. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  68499. /**
  68500. * Diffuse gives the basic color to an object.
  68501. */
  68502. diffuse: Color3;
  68503. /**
  68504. * Specular produces a highlight color on an object.
  68505. * Note: This is note affecting PBR materials.
  68506. */
  68507. specular: Color3;
  68508. /**
  68509. * Defines the falloff type for this light. This lets overrriding how punctual light are
  68510. * falling off base on range or angle.
  68511. * This can be set to any values in Light.FALLOFF_x.
  68512. *
  68513. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  68514. * other types of materials.
  68515. */
  68516. falloffType: number;
  68517. /**
  68518. * Strength of the light.
  68519. * Note: By default it is define in the framework own unit.
  68520. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  68521. */
  68522. intensity: number;
  68523. private _range;
  68524. protected _inverseSquaredRange: number;
  68525. /**
  68526. * Defines how far from the source the light is impacting in scene units.
  68527. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68528. */
  68529. /**
  68530. * Defines how far from the source the light is impacting in scene units.
  68531. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68532. */
  68533. range: number;
  68534. /**
  68535. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  68536. * of light.
  68537. */
  68538. private _photometricScale;
  68539. private _intensityMode;
  68540. /**
  68541. * Gets the photometric scale used to interpret the intensity.
  68542. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68543. */
  68544. /**
  68545. * Sets the photometric scale used to interpret the intensity.
  68546. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68547. */
  68548. intensityMode: number;
  68549. private _radius;
  68550. /**
  68551. * Gets the light radius used by PBR Materials to simulate soft area lights.
  68552. */
  68553. /**
  68554. * sets the light radius used by PBR Materials to simulate soft area lights.
  68555. */
  68556. radius: number;
  68557. private _renderPriority;
  68558. /**
  68559. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  68560. * exceeding the number allowed of the materials.
  68561. */
  68562. renderPriority: number;
  68563. private _shadowEnabled;
  68564. /**
  68565. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68566. * the current shadow generator.
  68567. */
  68568. /**
  68569. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68570. * the current shadow generator.
  68571. */
  68572. shadowEnabled: boolean;
  68573. private _includedOnlyMeshes;
  68574. /**
  68575. * Gets the only meshes impacted by this light.
  68576. */
  68577. /**
  68578. * Sets the only meshes impacted by this light.
  68579. */
  68580. includedOnlyMeshes: AbstractMesh[];
  68581. private _excludedMeshes;
  68582. /**
  68583. * Gets the meshes not impacted by this light.
  68584. */
  68585. /**
  68586. * Sets the meshes not impacted by this light.
  68587. */
  68588. excludedMeshes: AbstractMesh[];
  68589. private _excludeWithLayerMask;
  68590. /**
  68591. * Gets the layer id use to find what meshes are not impacted by the light.
  68592. * Inactive if 0
  68593. */
  68594. /**
  68595. * Sets the layer id use to find what meshes are not impacted by the light.
  68596. * Inactive if 0
  68597. */
  68598. excludeWithLayerMask: number;
  68599. private _includeOnlyWithLayerMask;
  68600. /**
  68601. * Gets the layer id use to find what meshes are impacted by the light.
  68602. * Inactive if 0
  68603. */
  68604. /**
  68605. * Sets the layer id use to find what meshes are impacted by the light.
  68606. * Inactive if 0
  68607. */
  68608. includeOnlyWithLayerMask: number;
  68609. private _lightmapMode;
  68610. /**
  68611. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68612. */
  68613. /**
  68614. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68615. */
  68616. lightmapMode: number;
  68617. /**
  68618. * Shadow generator associted to the light.
  68619. * @hidden Internal use only.
  68620. */
  68621. _shadowGenerator: Nullable<IShadowGenerator>;
  68622. /**
  68623. * @hidden Internal use only.
  68624. */
  68625. _excludedMeshesIds: string[];
  68626. /**
  68627. * @hidden Internal use only.
  68628. */
  68629. _includedOnlyMeshesIds: string[];
  68630. /**
  68631. * The current light unifom buffer.
  68632. * @hidden Internal use only.
  68633. */
  68634. _uniformBuffer: UniformBuffer;
  68635. /**
  68636. * Creates a Light object in the scene.
  68637. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68638. * @param name The firendly name of the light
  68639. * @param scene The scene the light belongs too
  68640. */
  68641. constructor(name: string, scene: Scene);
  68642. protected abstract _buildUniformLayout(): void;
  68643. /**
  68644. * Sets the passed Effect "effect" with the Light information.
  68645. * @param effect The effect to update
  68646. * @param lightIndex The index of the light in the effect to update
  68647. * @returns The light
  68648. */
  68649. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  68650. /**
  68651. * Returns the string "Light".
  68652. * @returns the class name
  68653. */
  68654. getClassName(): string;
  68655. /** @hidden */
  68656. readonly _isLight: boolean;
  68657. /**
  68658. * Converts the light information to a readable string for debug purpose.
  68659. * @param fullDetails Supports for multiple levels of logging within scene loading
  68660. * @returns the human readable light info
  68661. */
  68662. toString(fullDetails?: boolean): string;
  68663. /** @hidden */
  68664. protected _syncParentEnabledState(): void;
  68665. /**
  68666. * Set the enabled state of this node.
  68667. * @param value - the new enabled state
  68668. */
  68669. setEnabled(value: boolean): void;
  68670. /**
  68671. * Returns the Light associated shadow generator if any.
  68672. * @return the associated shadow generator.
  68673. */
  68674. getShadowGenerator(): Nullable<IShadowGenerator>;
  68675. /**
  68676. * Returns a Vector3, the absolute light position in the World.
  68677. * @returns the world space position of the light
  68678. */
  68679. getAbsolutePosition(): Vector3;
  68680. /**
  68681. * Specifies if the light will affect the passed mesh.
  68682. * @param mesh The mesh to test against the light
  68683. * @return true the mesh is affected otherwise, false.
  68684. */
  68685. canAffectMesh(mesh: AbstractMesh): boolean;
  68686. /**
  68687. * Sort function to order lights for rendering.
  68688. * @param a First Light object to compare to second.
  68689. * @param b Second Light object to compare first.
  68690. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  68691. */
  68692. static CompareLightsPriority(a: Light, b: Light): number;
  68693. /**
  68694. * Releases resources associated with this node.
  68695. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  68696. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  68697. */
  68698. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68699. /**
  68700. * Returns the light type ID (integer).
  68701. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68702. */
  68703. getTypeID(): number;
  68704. /**
  68705. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68706. * @returns the scaled intensity in intensity mode unit
  68707. */
  68708. getScaledIntensity(): number;
  68709. /**
  68710. * Returns a new Light object, named "name", from the current one.
  68711. * @param name The name of the cloned light
  68712. * @returns the new created light
  68713. */
  68714. clone(name: string): Nullable<Light>;
  68715. /**
  68716. * Serializes the current light into a Serialization object.
  68717. * @returns the serialized object.
  68718. */
  68719. serialize(): any;
  68720. /**
  68721. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68722. * This new light is named "name" and added to the passed scene.
  68723. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68724. * @param name The friendly name of the light
  68725. * @param scene The scene the new light will belong to
  68726. * @returns the constructor function
  68727. */
  68728. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68729. /**
  68730. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68731. * @param parsedLight The JSON representation of the light
  68732. * @param scene The scene to create the parsed light in
  68733. * @returns the created light after parsing
  68734. */
  68735. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68736. private _hookArrayForExcluded;
  68737. private _hookArrayForIncludedOnly;
  68738. private _resyncMeshes;
  68739. /**
  68740. * Forces the meshes to update their light related information in their rendering used effects
  68741. * @hidden Internal Use Only
  68742. */
  68743. _markMeshesAsLightDirty(): void;
  68744. /**
  68745. * Recomputes the cached photometric scale if needed.
  68746. */
  68747. private _computePhotometricScale;
  68748. /**
  68749. * Returns the Photometric Scale according to the light type and intensity mode.
  68750. */
  68751. private _getPhotometricScale;
  68752. /**
  68753. * Reorder the light in the scene according to their defined priority.
  68754. * @hidden Internal Use Only
  68755. */
  68756. _reorderLightsInScene(): void;
  68757. /**
  68758. * Prepares the list of defines specific to the light type.
  68759. * @param defines the list of defines
  68760. * @param lightIndex defines the index of the light for the effect
  68761. */
  68762. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68763. }
  68764. }
  68765. declare module BABYLON {
  68766. /**
  68767. * Interface used to define Action
  68768. */
  68769. export interface IAction {
  68770. /**
  68771. * Trigger for the action
  68772. */
  68773. trigger: number;
  68774. /** Options of the trigger */
  68775. triggerOptions: any;
  68776. /**
  68777. * Gets the trigger parameters
  68778. * @returns the trigger parameters
  68779. */
  68780. getTriggerParameter(): any;
  68781. /**
  68782. * Internal only - executes current action event
  68783. * @hidden
  68784. */
  68785. _executeCurrent(evt?: ActionEvent): void;
  68786. /**
  68787. * Serialize placeholder for child classes
  68788. * @param parent of child
  68789. * @returns the serialized object
  68790. */
  68791. serialize(parent: any): any;
  68792. /**
  68793. * Internal only
  68794. * @hidden
  68795. */
  68796. _prepare(): void;
  68797. /**
  68798. * Internal only - manager for action
  68799. * @hidden
  68800. */
  68801. _actionManager: AbstractActionManager;
  68802. }
  68803. /**
  68804. * The action to be carried out following a trigger
  68805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  68806. */
  68807. export class Action implements IAction {
  68808. /** the trigger, with or without parameters, for the action */
  68809. triggerOptions: any;
  68810. /**
  68811. * Trigger for the action
  68812. */
  68813. trigger: number;
  68814. /**
  68815. * Internal only - manager for action
  68816. * @hidden
  68817. */
  68818. _actionManager: ActionManager;
  68819. private _nextActiveAction;
  68820. private _child;
  68821. private _condition?;
  68822. private _triggerParameter;
  68823. /**
  68824. * An event triggered prior to action being executed.
  68825. */
  68826. onBeforeExecuteObservable: Observable<Action>;
  68827. /**
  68828. * Creates a new Action
  68829. * @param triggerOptions the trigger, with or without parameters, for the action
  68830. * @param condition an optional determinant of action
  68831. */
  68832. constructor(
  68833. /** the trigger, with or without parameters, for the action */
  68834. triggerOptions: any, condition?: Condition);
  68835. /**
  68836. * Internal only
  68837. * @hidden
  68838. */
  68839. _prepare(): void;
  68840. /**
  68841. * Gets the trigger parameters
  68842. * @returns the trigger parameters
  68843. */
  68844. getTriggerParameter(): any;
  68845. /**
  68846. * Internal only - executes current action event
  68847. * @hidden
  68848. */
  68849. _executeCurrent(evt?: ActionEvent): void;
  68850. /**
  68851. * Execute placeholder for child classes
  68852. * @param evt optional action event
  68853. */
  68854. execute(evt?: ActionEvent): void;
  68855. /**
  68856. * Skips to next active action
  68857. */
  68858. skipToNextActiveAction(): void;
  68859. /**
  68860. * Adds action to chain of actions, may be a DoNothingAction
  68861. * @param action defines the next action to execute
  68862. * @returns The action passed in
  68863. * @see https://www.babylonjs-playground.com/#1T30HR#0
  68864. */
  68865. then(action: Action): Action;
  68866. /**
  68867. * Internal only
  68868. * @hidden
  68869. */
  68870. _getProperty(propertyPath: string): string;
  68871. /**
  68872. * Internal only
  68873. * @hidden
  68874. */
  68875. _getEffectiveTarget(target: any, propertyPath: string): any;
  68876. /**
  68877. * Serialize placeholder for child classes
  68878. * @param parent of child
  68879. * @returns the serialized object
  68880. */
  68881. serialize(parent: any): any;
  68882. /**
  68883. * Internal only called by serialize
  68884. * @hidden
  68885. */
  68886. protected _serialize(serializedAction: any, parent?: any): any;
  68887. /**
  68888. * Internal only
  68889. * @hidden
  68890. */
  68891. static _SerializeValueAsString: (value: any) => string;
  68892. /**
  68893. * Internal only
  68894. * @hidden
  68895. */
  68896. static _GetTargetProperty: (target: Scene | Node) => {
  68897. name: string;
  68898. targetType: string;
  68899. value: string;
  68900. };
  68901. }
  68902. }
  68903. declare module BABYLON {
  68904. /**
  68905. * A Condition applied to an Action
  68906. */
  68907. export class Condition {
  68908. /**
  68909. * Internal only - manager for action
  68910. * @hidden
  68911. */
  68912. _actionManager: ActionManager;
  68913. /**
  68914. * Internal only
  68915. * @hidden
  68916. */
  68917. _evaluationId: number;
  68918. /**
  68919. * Internal only
  68920. * @hidden
  68921. */
  68922. _currentResult: boolean;
  68923. /**
  68924. * Creates a new Condition
  68925. * @param actionManager the manager of the action the condition is applied to
  68926. */
  68927. constructor(actionManager: ActionManager);
  68928. /**
  68929. * Check if the current condition is valid
  68930. * @returns a boolean
  68931. */
  68932. isValid(): boolean;
  68933. /**
  68934. * Internal only
  68935. * @hidden
  68936. */
  68937. _getProperty(propertyPath: string): string;
  68938. /**
  68939. * Internal only
  68940. * @hidden
  68941. */
  68942. _getEffectiveTarget(target: any, propertyPath: string): any;
  68943. /**
  68944. * Serialize placeholder for child classes
  68945. * @returns the serialized object
  68946. */
  68947. serialize(): any;
  68948. /**
  68949. * Internal only
  68950. * @hidden
  68951. */
  68952. protected _serialize(serializedCondition: any): any;
  68953. }
  68954. /**
  68955. * Defines specific conditional operators as extensions of Condition
  68956. */
  68957. export class ValueCondition extends Condition {
  68958. /** path to specify the property of the target the conditional operator uses */
  68959. propertyPath: string;
  68960. /** the value compared by the conditional operator against the current value of the property */
  68961. value: any;
  68962. /** the conditional operator, default ValueCondition.IsEqual */
  68963. operator: number;
  68964. /**
  68965. * Internal only
  68966. * @hidden
  68967. */
  68968. private static _IsEqual;
  68969. /**
  68970. * Internal only
  68971. * @hidden
  68972. */
  68973. private static _IsDifferent;
  68974. /**
  68975. * Internal only
  68976. * @hidden
  68977. */
  68978. private static _IsGreater;
  68979. /**
  68980. * Internal only
  68981. * @hidden
  68982. */
  68983. private static _IsLesser;
  68984. /**
  68985. * returns the number for IsEqual
  68986. */
  68987. static readonly IsEqual: number;
  68988. /**
  68989. * Returns the number for IsDifferent
  68990. */
  68991. static readonly IsDifferent: number;
  68992. /**
  68993. * Returns the number for IsGreater
  68994. */
  68995. static readonly IsGreater: number;
  68996. /**
  68997. * Returns the number for IsLesser
  68998. */
  68999. static readonly IsLesser: number;
  69000. /**
  69001. * Internal only The action manager for the condition
  69002. * @hidden
  69003. */
  69004. _actionManager: ActionManager;
  69005. /**
  69006. * Internal only
  69007. * @hidden
  69008. */
  69009. private _target;
  69010. /**
  69011. * Internal only
  69012. * @hidden
  69013. */
  69014. private _effectiveTarget;
  69015. /**
  69016. * Internal only
  69017. * @hidden
  69018. */
  69019. private _property;
  69020. /**
  69021. * Creates a new ValueCondition
  69022. * @param actionManager manager for the action the condition applies to
  69023. * @param target for the action
  69024. * @param propertyPath path to specify the property of the target the conditional operator uses
  69025. * @param value the value compared by the conditional operator against the current value of the property
  69026. * @param operator the conditional operator, default ValueCondition.IsEqual
  69027. */
  69028. constructor(actionManager: ActionManager, target: any,
  69029. /** path to specify the property of the target the conditional operator uses */
  69030. propertyPath: string,
  69031. /** the value compared by the conditional operator against the current value of the property */
  69032. value: any,
  69033. /** the conditional operator, default ValueCondition.IsEqual */
  69034. operator?: number);
  69035. /**
  69036. * Compares the given value with the property value for the specified conditional operator
  69037. * @returns the result of the comparison
  69038. */
  69039. isValid(): boolean;
  69040. /**
  69041. * Serialize the ValueCondition into a JSON compatible object
  69042. * @returns serialization object
  69043. */
  69044. serialize(): any;
  69045. /**
  69046. * Gets the name of the conditional operator for the ValueCondition
  69047. * @param operator the conditional operator
  69048. * @returns the name
  69049. */
  69050. static GetOperatorName(operator: number): string;
  69051. }
  69052. /**
  69053. * Defines a predicate condition as an extension of Condition
  69054. */
  69055. export class PredicateCondition extends Condition {
  69056. /** defines the predicate function used to validate the condition */
  69057. predicate: () => boolean;
  69058. /**
  69059. * Internal only - manager for action
  69060. * @hidden
  69061. */
  69062. _actionManager: ActionManager;
  69063. /**
  69064. * Creates a new PredicateCondition
  69065. * @param actionManager manager for the action the condition applies to
  69066. * @param predicate defines the predicate function used to validate the condition
  69067. */
  69068. constructor(actionManager: ActionManager,
  69069. /** defines the predicate function used to validate the condition */
  69070. predicate: () => boolean);
  69071. /**
  69072. * @returns the validity of the predicate condition
  69073. */
  69074. isValid(): boolean;
  69075. }
  69076. /**
  69077. * Defines a state condition as an extension of Condition
  69078. */
  69079. export class StateCondition extends Condition {
  69080. /** Value to compare with target state */
  69081. value: string;
  69082. /**
  69083. * Internal only - manager for action
  69084. * @hidden
  69085. */
  69086. _actionManager: ActionManager;
  69087. /**
  69088. * Internal only
  69089. * @hidden
  69090. */
  69091. private _target;
  69092. /**
  69093. * Creates a new StateCondition
  69094. * @param actionManager manager for the action the condition applies to
  69095. * @param target of the condition
  69096. * @param value to compare with target state
  69097. */
  69098. constructor(actionManager: ActionManager, target: any,
  69099. /** Value to compare with target state */
  69100. value: string);
  69101. /**
  69102. * Gets a boolean indicating if the current condition is met
  69103. * @returns the validity of the state
  69104. */
  69105. isValid(): boolean;
  69106. /**
  69107. * Serialize the StateCondition into a JSON compatible object
  69108. * @returns serialization object
  69109. */
  69110. serialize(): any;
  69111. }
  69112. }
  69113. declare module BABYLON {
  69114. /**
  69115. * This defines an action responsible to toggle a boolean once triggered.
  69116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69117. */
  69118. export class SwitchBooleanAction extends Action {
  69119. /**
  69120. * The path to the boolean property in the target object
  69121. */
  69122. propertyPath: string;
  69123. private _target;
  69124. private _effectiveTarget;
  69125. private _property;
  69126. /**
  69127. * Instantiate the action
  69128. * @param triggerOptions defines the trigger options
  69129. * @param target defines the object containing the boolean
  69130. * @param propertyPath defines the path to the boolean property in the target object
  69131. * @param condition defines the trigger related conditions
  69132. */
  69133. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69134. /** @hidden */
  69135. _prepare(): void;
  69136. /**
  69137. * Execute the action toggle the boolean value.
  69138. */
  69139. execute(): void;
  69140. /**
  69141. * Serializes the actions and its related information.
  69142. * @param parent defines the object to serialize in
  69143. * @returns the serialized object
  69144. */
  69145. serialize(parent: any): any;
  69146. }
  69147. /**
  69148. * This defines an action responsible to set a the state field of the target
  69149. * to a desired value once triggered.
  69150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69151. */
  69152. export class SetStateAction extends Action {
  69153. /**
  69154. * The value to store in the state field.
  69155. */
  69156. value: string;
  69157. private _target;
  69158. /**
  69159. * Instantiate the action
  69160. * @param triggerOptions defines the trigger options
  69161. * @param target defines the object containing the state property
  69162. * @param value defines the value to store in the state field
  69163. * @param condition defines the trigger related conditions
  69164. */
  69165. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69166. /**
  69167. * Execute the action and store the value on the target state property.
  69168. */
  69169. execute(): void;
  69170. /**
  69171. * Serializes the actions and its related information.
  69172. * @param parent defines the object to serialize in
  69173. * @returns the serialized object
  69174. */
  69175. serialize(parent: any): any;
  69176. }
  69177. /**
  69178. * This defines an action responsible to set a property of the target
  69179. * to a desired value once triggered.
  69180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69181. */
  69182. export class SetValueAction extends Action {
  69183. /**
  69184. * The path of the property to set in the target.
  69185. */
  69186. propertyPath: string;
  69187. /**
  69188. * The value to set in the property
  69189. */
  69190. value: any;
  69191. private _target;
  69192. private _effectiveTarget;
  69193. private _property;
  69194. /**
  69195. * Instantiate the action
  69196. * @param triggerOptions defines the trigger options
  69197. * @param target defines the object containing the property
  69198. * @param propertyPath defines the path of the property to set in the target
  69199. * @param value defines the value to set in the property
  69200. * @param condition defines the trigger related conditions
  69201. */
  69202. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69203. /** @hidden */
  69204. _prepare(): void;
  69205. /**
  69206. * Execute the action and set the targetted property to the desired value.
  69207. */
  69208. execute(): void;
  69209. /**
  69210. * Serializes the actions and its related information.
  69211. * @param parent defines the object to serialize in
  69212. * @returns the serialized object
  69213. */
  69214. serialize(parent: any): any;
  69215. }
  69216. /**
  69217. * This defines an action responsible to increment the target value
  69218. * to a desired value once triggered.
  69219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69220. */
  69221. export class IncrementValueAction extends Action {
  69222. /**
  69223. * The path of the property to increment in the target.
  69224. */
  69225. propertyPath: string;
  69226. /**
  69227. * The value we should increment the property by.
  69228. */
  69229. value: any;
  69230. private _target;
  69231. private _effectiveTarget;
  69232. private _property;
  69233. /**
  69234. * Instantiate the action
  69235. * @param triggerOptions defines the trigger options
  69236. * @param target defines the object containing the property
  69237. * @param propertyPath defines the path of the property to increment in the target
  69238. * @param value defines the value value we should increment the property by
  69239. * @param condition defines the trigger related conditions
  69240. */
  69241. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69242. /** @hidden */
  69243. _prepare(): void;
  69244. /**
  69245. * Execute the action and increment the target of the value amount.
  69246. */
  69247. execute(): void;
  69248. /**
  69249. * Serializes the actions and its related information.
  69250. * @param parent defines the object to serialize in
  69251. * @returns the serialized object
  69252. */
  69253. serialize(parent: any): any;
  69254. }
  69255. /**
  69256. * This defines an action responsible to start an animation once triggered.
  69257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69258. */
  69259. export class PlayAnimationAction extends Action {
  69260. /**
  69261. * Where the animation should start (animation frame)
  69262. */
  69263. from: number;
  69264. /**
  69265. * Where the animation should stop (animation frame)
  69266. */
  69267. to: number;
  69268. /**
  69269. * Define if the animation should loop or stop after the first play.
  69270. */
  69271. loop?: boolean;
  69272. private _target;
  69273. /**
  69274. * Instantiate the action
  69275. * @param triggerOptions defines the trigger options
  69276. * @param target defines the target animation or animation name
  69277. * @param from defines from where the animation should start (animation frame)
  69278. * @param end defines where the animation should stop (animation frame)
  69279. * @param loop defines if the animation should loop or stop after the first play
  69280. * @param condition defines the trigger related conditions
  69281. */
  69282. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  69283. /** @hidden */
  69284. _prepare(): void;
  69285. /**
  69286. * Execute the action and play the animation.
  69287. */
  69288. execute(): void;
  69289. /**
  69290. * Serializes the actions and its related information.
  69291. * @param parent defines the object to serialize in
  69292. * @returns the serialized object
  69293. */
  69294. serialize(parent: any): any;
  69295. }
  69296. /**
  69297. * This defines an action responsible to stop an animation once triggered.
  69298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69299. */
  69300. export class StopAnimationAction extends Action {
  69301. private _target;
  69302. /**
  69303. * Instantiate the action
  69304. * @param triggerOptions defines the trigger options
  69305. * @param target defines the target animation or animation name
  69306. * @param condition defines the trigger related conditions
  69307. */
  69308. constructor(triggerOptions: any, target: any, condition?: Condition);
  69309. /** @hidden */
  69310. _prepare(): void;
  69311. /**
  69312. * Execute the action and stop the animation.
  69313. */
  69314. execute(): void;
  69315. /**
  69316. * Serializes the actions and its related information.
  69317. * @param parent defines the object to serialize in
  69318. * @returns the serialized object
  69319. */
  69320. serialize(parent: any): any;
  69321. }
  69322. /**
  69323. * This defines an action responsible that does nothing once triggered.
  69324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69325. */
  69326. export class DoNothingAction extends Action {
  69327. /**
  69328. * Instantiate the action
  69329. * @param triggerOptions defines the trigger options
  69330. * @param condition defines the trigger related conditions
  69331. */
  69332. constructor(triggerOptions?: any, condition?: Condition);
  69333. /**
  69334. * Execute the action and do nothing.
  69335. */
  69336. execute(): void;
  69337. /**
  69338. * Serializes the actions and its related information.
  69339. * @param parent defines the object to serialize in
  69340. * @returns the serialized object
  69341. */
  69342. serialize(parent: any): any;
  69343. }
  69344. /**
  69345. * This defines an action responsible to trigger several actions once triggered.
  69346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69347. */
  69348. export class CombineAction extends Action {
  69349. /**
  69350. * The list of aggregated animations to run.
  69351. */
  69352. children: Action[];
  69353. /**
  69354. * Instantiate the action
  69355. * @param triggerOptions defines the trigger options
  69356. * @param children defines the list of aggregated animations to run
  69357. * @param condition defines the trigger related conditions
  69358. */
  69359. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  69360. /** @hidden */
  69361. _prepare(): void;
  69362. /**
  69363. * Execute the action and executes all the aggregated actions.
  69364. */
  69365. execute(evt: ActionEvent): void;
  69366. /**
  69367. * Serializes the actions and its related information.
  69368. * @param parent defines the object to serialize in
  69369. * @returns the serialized object
  69370. */
  69371. serialize(parent: any): any;
  69372. }
  69373. /**
  69374. * This defines an action responsible to run code (external event) once triggered.
  69375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69376. */
  69377. export class ExecuteCodeAction extends Action {
  69378. /**
  69379. * The callback function to run.
  69380. */
  69381. func: (evt: ActionEvent) => void;
  69382. /**
  69383. * Instantiate the action
  69384. * @param triggerOptions defines the trigger options
  69385. * @param func defines the callback function to run
  69386. * @param condition defines the trigger related conditions
  69387. */
  69388. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  69389. /**
  69390. * Execute the action and run the attached code.
  69391. */
  69392. execute(evt: ActionEvent): void;
  69393. }
  69394. /**
  69395. * This defines an action responsible to set the parent property of the target once triggered.
  69396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69397. */
  69398. export class SetParentAction extends Action {
  69399. private _parent;
  69400. private _target;
  69401. /**
  69402. * Instantiate the action
  69403. * @param triggerOptions defines the trigger options
  69404. * @param target defines the target containing the parent property
  69405. * @param parent defines from where the animation should start (animation frame)
  69406. * @param condition defines the trigger related conditions
  69407. */
  69408. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  69409. /** @hidden */
  69410. _prepare(): void;
  69411. /**
  69412. * Execute the action and set the parent property.
  69413. */
  69414. execute(): void;
  69415. /**
  69416. * Serializes the actions and its related information.
  69417. * @param parent defines the object to serialize in
  69418. * @returns the serialized object
  69419. */
  69420. serialize(parent: any): any;
  69421. }
  69422. }
  69423. declare module BABYLON {
  69424. /**
  69425. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  69426. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  69427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69428. */
  69429. export class ActionManager extends AbstractActionManager {
  69430. /**
  69431. * Nothing
  69432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69433. */
  69434. static readonly NothingTrigger: number;
  69435. /**
  69436. * On pick
  69437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69438. */
  69439. static readonly OnPickTrigger: number;
  69440. /**
  69441. * On left pick
  69442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69443. */
  69444. static readonly OnLeftPickTrigger: number;
  69445. /**
  69446. * On right pick
  69447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69448. */
  69449. static readonly OnRightPickTrigger: number;
  69450. /**
  69451. * On center pick
  69452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69453. */
  69454. static readonly OnCenterPickTrigger: number;
  69455. /**
  69456. * On pick down
  69457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69458. */
  69459. static readonly OnPickDownTrigger: number;
  69460. /**
  69461. * On double pick
  69462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69463. */
  69464. static readonly OnDoublePickTrigger: number;
  69465. /**
  69466. * On pick up
  69467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69468. */
  69469. static readonly OnPickUpTrigger: number;
  69470. /**
  69471. * On pick out.
  69472. * This trigger will only be raised if you also declared a OnPickDown
  69473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69474. */
  69475. static readonly OnPickOutTrigger: number;
  69476. /**
  69477. * On long press
  69478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69479. */
  69480. static readonly OnLongPressTrigger: number;
  69481. /**
  69482. * On pointer over
  69483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69484. */
  69485. static readonly OnPointerOverTrigger: number;
  69486. /**
  69487. * On pointer out
  69488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69489. */
  69490. static readonly OnPointerOutTrigger: number;
  69491. /**
  69492. * On every frame
  69493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69494. */
  69495. static readonly OnEveryFrameTrigger: number;
  69496. /**
  69497. * On intersection enter
  69498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69499. */
  69500. static readonly OnIntersectionEnterTrigger: number;
  69501. /**
  69502. * On intersection exit
  69503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69504. */
  69505. static readonly OnIntersectionExitTrigger: number;
  69506. /**
  69507. * On key down
  69508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69509. */
  69510. static readonly OnKeyDownTrigger: number;
  69511. /**
  69512. * On key up
  69513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69514. */
  69515. static readonly OnKeyUpTrigger: number;
  69516. private _scene;
  69517. /**
  69518. * Creates a new action manager
  69519. * @param scene defines the hosting scene
  69520. */
  69521. constructor(scene: Scene);
  69522. /**
  69523. * Releases all associated resources
  69524. */
  69525. dispose(): void;
  69526. /**
  69527. * Gets hosting scene
  69528. * @returns the hosting scene
  69529. */
  69530. getScene(): Scene;
  69531. /**
  69532. * Does this action manager handles actions of any of the given triggers
  69533. * @param triggers defines the triggers to be tested
  69534. * @return a boolean indicating whether one (or more) of the triggers is handled
  69535. */
  69536. hasSpecificTriggers(triggers: number[]): boolean;
  69537. /**
  69538. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  69539. * speed.
  69540. * @param triggerA defines the trigger to be tested
  69541. * @param triggerB defines the trigger to be tested
  69542. * @return a boolean indicating whether one (or more) of the triggers is handled
  69543. */
  69544. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  69545. /**
  69546. * Does this action manager handles actions of a given trigger
  69547. * @param trigger defines the trigger to be tested
  69548. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  69549. * @return whether the trigger is handled
  69550. */
  69551. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  69552. /**
  69553. * Does this action manager has pointer triggers
  69554. */
  69555. readonly hasPointerTriggers: boolean;
  69556. /**
  69557. * Does this action manager has pick triggers
  69558. */
  69559. readonly hasPickTriggers: boolean;
  69560. /**
  69561. * Registers an action to this action manager
  69562. * @param action defines the action to be registered
  69563. * @return the action amended (prepared) after registration
  69564. */
  69565. registerAction(action: IAction): Nullable<IAction>;
  69566. /**
  69567. * Unregisters an action to this action manager
  69568. * @param action defines the action to be unregistered
  69569. * @return a boolean indicating whether the action has been unregistered
  69570. */
  69571. unregisterAction(action: IAction): Boolean;
  69572. /**
  69573. * Process a specific trigger
  69574. * @param trigger defines the trigger to process
  69575. * @param evt defines the event details to be processed
  69576. */
  69577. processTrigger(trigger: number, evt?: IActionEvent): void;
  69578. /** @hidden */
  69579. _getEffectiveTarget(target: any, propertyPath: string): any;
  69580. /** @hidden */
  69581. _getProperty(propertyPath: string): string;
  69582. /**
  69583. * Serialize this manager to a JSON object
  69584. * @param name defines the property name to store this manager
  69585. * @returns a JSON representation of this manager
  69586. */
  69587. serialize(name: string): any;
  69588. /**
  69589. * Creates a new ActionManager from a JSON data
  69590. * @param parsedActions defines the JSON data to read from
  69591. * @param object defines the hosting mesh
  69592. * @param scene defines the hosting scene
  69593. */
  69594. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  69595. /**
  69596. * Get a trigger name by index
  69597. * @param trigger defines the trigger index
  69598. * @returns a trigger name
  69599. */
  69600. static GetTriggerName(trigger: number): string;
  69601. }
  69602. }
  69603. declare module BABYLON {
  69604. /**
  69605. * Class representing a ray with position and direction
  69606. */
  69607. export class Ray {
  69608. /** origin point */
  69609. origin: Vector3;
  69610. /** direction */
  69611. direction: Vector3;
  69612. /** length of the ray */
  69613. length: number;
  69614. private static readonly TmpVector3;
  69615. private _tmpRay;
  69616. /**
  69617. * Creates a new ray
  69618. * @param origin origin point
  69619. * @param direction direction
  69620. * @param length length of the ray
  69621. */
  69622. constructor(
  69623. /** origin point */
  69624. origin: Vector3,
  69625. /** direction */
  69626. direction: Vector3,
  69627. /** length of the ray */
  69628. length?: number);
  69629. /**
  69630. * Checks if the ray intersects a box
  69631. * @param minimum bound of the box
  69632. * @param maximum bound of the box
  69633. * @param intersectionTreshold extra extend to be added to the box in all direction
  69634. * @returns if the box was hit
  69635. */
  69636. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  69637. /**
  69638. * Checks if the ray intersects a box
  69639. * @param box the bounding box to check
  69640. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  69641. * @returns if the box was hit
  69642. */
  69643. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  69644. /**
  69645. * If the ray hits a sphere
  69646. * @param sphere the bounding sphere to check
  69647. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  69648. * @returns true if it hits the sphere
  69649. */
  69650. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  69651. /**
  69652. * If the ray hits a triange
  69653. * @param vertex0 triangle vertex
  69654. * @param vertex1 triangle vertex
  69655. * @param vertex2 triangle vertex
  69656. * @returns intersection information if hit
  69657. */
  69658. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  69659. /**
  69660. * Checks if ray intersects a plane
  69661. * @param plane the plane to check
  69662. * @returns the distance away it was hit
  69663. */
  69664. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  69665. /**
  69666. * Checks if ray intersects a mesh
  69667. * @param mesh the mesh to check
  69668. * @param fastCheck if only the bounding box should checked
  69669. * @returns picking info of the intersecton
  69670. */
  69671. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  69672. /**
  69673. * Checks if ray intersects a mesh
  69674. * @param meshes the meshes to check
  69675. * @param fastCheck if only the bounding box should checked
  69676. * @param results array to store result in
  69677. * @returns Array of picking infos
  69678. */
  69679. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  69680. private _comparePickingInfo;
  69681. private static smallnum;
  69682. private static rayl;
  69683. /**
  69684. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  69685. * @param sega the first point of the segment to test the intersection against
  69686. * @param segb the second point of the segment to test the intersection against
  69687. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  69688. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  69689. */
  69690. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  69691. /**
  69692. * Update the ray from viewport position
  69693. * @param x position
  69694. * @param y y position
  69695. * @param viewportWidth viewport width
  69696. * @param viewportHeight viewport height
  69697. * @param world world matrix
  69698. * @param view view matrix
  69699. * @param projection projection matrix
  69700. * @returns this ray updated
  69701. */
  69702. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69703. /**
  69704. * Creates a ray with origin and direction of 0,0,0
  69705. * @returns the new ray
  69706. */
  69707. static Zero(): Ray;
  69708. /**
  69709. * Creates a new ray from screen space and viewport
  69710. * @param x position
  69711. * @param y y position
  69712. * @param viewportWidth viewport width
  69713. * @param viewportHeight viewport height
  69714. * @param world world matrix
  69715. * @param view view matrix
  69716. * @param projection projection matrix
  69717. * @returns new ray
  69718. */
  69719. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69720. /**
  69721. * 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
  69722. * transformed to the given world matrix.
  69723. * @param origin The origin point
  69724. * @param end The end point
  69725. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69726. * @returns the new ray
  69727. */
  69728. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69729. /**
  69730. * Transforms a ray by a matrix
  69731. * @param ray ray to transform
  69732. * @param matrix matrix to apply
  69733. * @returns the resulting new ray
  69734. */
  69735. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69736. /**
  69737. * Transforms a ray by a matrix
  69738. * @param ray ray to transform
  69739. * @param matrix matrix to apply
  69740. * @param result ray to store result in
  69741. */
  69742. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69743. /**
  69744. * Unproject a ray from screen space to object space
  69745. * @param sourceX defines the screen space x coordinate to use
  69746. * @param sourceY defines the screen space y coordinate to use
  69747. * @param viewportWidth defines the current width of the viewport
  69748. * @param viewportHeight defines the current height of the viewport
  69749. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69750. * @param view defines the view matrix to use
  69751. * @param projection defines the projection matrix to use
  69752. */
  69753. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69754. }
  69755. /**
  69756. * Type used to define predicate used to select faces when a mesh intersection is detected
  69757. */
  69758. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69759. interface Scene {
  69760. /** @hidden */
  69761. _tempPickingRay: Nullable<Ray>;
  69762. /** @hidden */
  69763. _cachedRayForTransform: Ray;
  69764. /** @hidden */
  69765. _pickWithRayInverseMatrix: Matrix;
  69766. /** @hidden */
  69767. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69768. /** @hidden */
  69769. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  69770. }
  69771. }
  69772. declare module BABYLON {
  69773. /**
  69774. * Groups all the scene component constants in one place to ease maintenance.
  69775. * @hidden
  69776. */
  69777. export class SceneComponentConstants {
  69778. static readonly NAME_EFFECTLAYER: string;
  69779. static readonly NAME_LAYER: string;
  69780. static readonly NAME_LENSFLARESYSTEM: string;
  69781. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69782. static readonly NAME_PARTICLESYSTEM: string;
  69783. static readonly NAME_GAMEPAD: string;
  69784. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69785. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69786. static readonly NAME_DEPTHRENDERER: string;
  69787. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69788. static readonly NAME_SPRITE: string;
  69789. static readonly NAME_OUTLINERENDERER: string;
  69790. static readonly NAME_PROCEDURALTEXTURE: string;
  69791. static readonly NAME_SHADOWGENERATOR: string;
  69792. static readonly NAME_OCTREE: string;
  69793. static readonly NAME_PHYSICSENGINE: string;
  69794. static readonly NAME_AUDIO: string;
  69795. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69796. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69797. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69798. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69799. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69800. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69801. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69802. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69803. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69804. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69805. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69806. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69807. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69808. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69809. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69810. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69811. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69812. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69813. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69814. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69815. static readonly STEP_AFTERRENDER_AUDIO: number;
  69816. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69817. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69818. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69819. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69820. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69821. static readonly STEP_POINTERMOVE_SPRITE: number;
  69822. static readonly STEP_POINTERDOWN_SPRITE: number;
  69823. static readonly STEP_POINTERUP_SPRITE: number;
  69824. }
  69825. /**
  69826. * This represents a scene component.
  69827. *
  69828. * This is used to decouple the dependency the scene is having on the different workloads like
  69829. * layers, post processes...
  69830. */
  69831. export interface ISceneComponent {
  69832. /**
  69833. * The name of the component. Each component must have a unique name.
  69834. */
  69835. name: string;
  69836. /**
  69837. * The scene the component belongs to.
  69838. */
  69839. scene: Scene;
  69840. /**
  69841. * Register the component to one instance of a scene.
  69842. */
  69843. register(): void;
  69844. /**
  69845. * Rebuilds the elements related to this component in case of
  69846. * context lost for instance.
  69847. */
  69848. rebuild(): void;
  69849. /**
  69850. * Disposes the component and the associated ressources.
  69851. */
  69852. dispose(): void;
  69853. }
  69854. /**
  69855. * This represents a SERIALIZABLE scene component.
  69856. *
  69857. * This extends Scene Component to add Serialization methods on top.
  69858. */
  69859. export interface ISceneSerializableComponent extends ISceneComponent {
  69860. /**
  69861. * Adds all the element from the container to the scene
  69862. * @param container the container holding the elements
  69863. */
  69864. addFromContainer(container: AbstractScene): void;
  69865. /**
  69866. * Removes all the elements in the container from the scene
  69867. * @param container contains the elements to remove
  69868. */
  69869. removeFromContainer(container: AbstractScene): void;
  69870. /**
  69871. * Serializes the component data to the specified json object
  69872. * @param serializationObject The object to serialize to
  69873. */
  69874. serialize(serializationObject: any): void;
  69875. }
  69876. /**
  69877. * Strong typing of a Mesh related stage step action
  69878. */
  69879. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69880. /**
  69881. * Strong typing of a Evaluate Sub Mesh related stage step action
  69882. */
  69883. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69884. /**
  69885. * Strong typing of a Active Mesh related stage step action
  69886. */
  69887. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69888. /**
  69889. * Strong typing of a Camera related stage step action
  69890. */
  69891. export type CameraStageAction = (camera: Camera) => void;
  69892. /**
  69893. * Strong typing of a Render Target related stage step action
  69894. */
  69895. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69896. /**
  69897. * Strong typing of a RenderingGroup related stage step action
  69898. */
  69899. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69900. /**
  69901. * Strong typing of a Mesh Render related stage step action
  69902. */
  69903. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69904. /**
  69905. * Strong typing of a simple stage step action
  69906. */
  69907. export type SimpleStageAction = () => void;
  69908. /**
  69909. * Strong typing of a render target action.
  69910. */
  69911. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69912. /**
  69913. * Strong typing of a pointer move action.
  69914. */
  69915. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69916. /**
  69917. * Strong typing of a pointer up/down action.
  69918. */
  69919. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69920. /**
  69921. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69922. * @hidden
  69923. */
  69924. export class Stage<T extends Function> extends Array<{
  69925. index: number;
  69926. component: ISceneComponent;
  69927. action: T;
  69928. }> {
  69929. /**
  69930. * Hide ctor from the rest of the world.
  69931. * @param items The items to add.
  69932. */
  69933. private constructor();
  69934. /**
  69935. * Creates a new Stage.
  69936. * @returns A new instance of a Stage
  69937. */
  69938. static Create<T extends Function>(): Stage<T>;
  69939. /**
  69940. * Registers a step in an ordered way in the targeted stage.
  69941. * @param index Defines the position to register the step in
  69942. * @param component Defines the component attached to the step
  69943. * @param action Defines the action to launch during the step
  69944. */
  69945. registerStep(index: number, component: ISceneComponent, action: T): void;
  69946. /**
  69947. * Clears all the steps from the stage.
  69948. */
  69949. clear(): void;
  69950. }
  69951. }
  69952. declare module BABYLON {
  69953. interface Scene {
  69954. /** @hidden */
  69955. _pointerOverSprite: Nullable<Sprite>;
  69956. /** @hidden */
  69957. _pickedDownSprite: Nullable<Sprite>;
  69958. /** @hidden */
  69959. _tempSpritePickingRay: Nullable<Ray>;
  69960. /**
  69961. * All of the sprite managers added to this scene
  69962. * @see http://doc.babylonjs.com/babylon101/sprites
  69963. */
  69964. spriteManagers: Array<ISpriteManager>;
  69965. /**
  69966. * An event triggered when sprites rendering is about to start
  69967. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69968. */
  69969. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69970. /**
  69971. * An event triggered when sprites rendering is done
  69972. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69973. */
  69974. onAfterSpritesRenderingObservable: Observable<Scene>;
  69975. /** @hidden */
  69976. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69977. /** Launch a ray to try to pick a sprite in the scene
  69978. * @param x position on screen
  69979. * @param y position on screen
  69980. * @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
  69981. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69982. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69983. * @returns a PickingInfo
  69984. */
  69985. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69986. /** Use the given ray to pick a sprite in the scene
  69987. * @param ray The ray (in world space) to use to pick meshes
  69988. * @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
  69989. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69990. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69991. * @returns a PickingInfo
  69992. */
  69993. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69994. /**
  69995. * Force the sprite under the pointer
  69996. * @param sprite defines the sprite to use
  69997. */
  69998. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69999. /**
  70000. * Gets the sprite under the pointer
  70001. * @returns a Sprite or null if no sprite is under the pointer
  70002. */
  70003. getPointerOverSprite(): Nullable<Sprite>;
  70004. }
  70005. /**
  70006. * Defines the sprite scene component responsible to manage sprites
  70007. * in a given scene.
  70008. */
  70009. export class SpriteSceneComponent implements ISceneComponent {
  70010. /**
  70011. * The component name helpfull to identify the component in the list of scene components.
  70012. */
  70013. readonly name: string;
  70014. /**
  70015. * The scene the component belongs to.
  70016. */
  70017. scene: Scene;
  70018. /** @hidden */
  70019. private _spritePredicate;
  70020. /**
  70021. * Creates a new instance of the component for the given scene
  70022. * @param scene Defines the scene to register the component in
  70023. */
  70024. constructor(scene: Scene);
  70025. /**
  70026. * Registers the component in a given scene
  70027. */
  70028. register(): void;
  70029. /**
  70030. * Rebuilds the elements related to this component in case of
  70031. * context lost for instance.
  70032. */
  70033. rebuild(): void;
  70034. /**
  70035. * Disposes the component and the associated ressources.
  70036. */
  70037. dispose(): void;
  70038. private _pickSpriteButKeepRay;
  70039. private _pointerMove;
  70040. private _pointerDown;
  70041. private _pointerUp;
  70042. }
  70043. }
  70044. declare module BABYLON {
  70045. /** @hidden */
  70046. export var fogFragmentDeclaration: {
  70047. name: string;
  70048. shader: string;
  70049. };
  70050. }
  70051. declare module BABYLON {
  70052. /** @hidden */
  70053. export var fogFragment: {
  70054. name: string;
  70055. shader: string;
  70056. };
  70057. }
  70058. declare module BABYLON {
  70059. /** @hidden */
  70060. export var spritesPixelShader: {
  70061. name: string;
  70062. shader: string;
  70063. };
  70064. }
  70065. declare module BABYLON {
  70066. /** @hidden */
  70067. export var fogVertexDeclaration: {
  70068. name: string;
  70069. shader: string;
  70070. };
  70071. }
  70072. declare module BABYLON {
  70073. /** @hidden */
  70074. export var spritesVertexShader: {
  70075. name: string;
  70076. shader: string;
  70077. };
  70078. }
  70079. declare module BABYLON {
  70080. /**
  70081. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70082. */
  70083. export interface ISpriteManager extends IDisposable {
  70084. /**
  70085. * Restricts the camera to viewing objects with the same layerMask.
  70086. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70087. */
  70088. layerMask: number;
  70089. /**
  70090. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70091. */
  70092. isPickable: boolean;
  70093. /**
  70094. * Specifies the rendering group id for this mesh (0 by default)
  70095. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70096. */
  70097. renderingGroupId: number;
  70098. /**
  70099. * Defines the list of sprites managed by the manager.
  70100. */
  70101. sprites: Array<Sprite>;
  70102. /**
  70103. * Tests the intersection of a sprite with a specific ray.
  70104. * @param ray The ray we are sending to test the collision
  70105. * @param camera The camera space we are sending rays in
  70106. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70107. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70108. * @returns picking info or null.
  70109. */
  70110. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70111. /**
  70112. * Renders the list of sprites on screen.
  70113. */
  70114. render(): void;
  70115. }
  70116. /**
  70117. * Class used to manage multiple sprites on the same spritesheet
  70118. * @see http://doc.babylonjs.com/babylon101/sprites
  70119. */
  70120. export class SpriteManager implements ISpriteManager {
  70121. /** defines the manager's name */
  70122. name: string;
  70123. /** Gets the list of sprites */
  70124. sprites: Sprite[];
  70125. /** Gets or sets the rendering group id (0 by default) */
  70126. renderingGroupId: number;
  70127. /** Gets or sets camera layer mask */
  70128. layerMask: number;
  70129. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70130. fogEnabled: boolean;
  70131. /** Gets or sets a boolean indicating if the sprites are pickable */
  70132. isPickable: boolean;
  70133. /** Defines the default width of a cell in the spritesheet */
  70134. cellWidth: number;
  70135. /** Defines the default height of a cell in the spritesheet */
  70136. cellHeight: number;
  70137. /**
  70138. * An event triggered when the manager is disposed.
  70139. */
  70140. onDisposeObservable: Observable<SpriteManager>;
  70141. private _onDisposeObserver;
  70142. /**
  70143. * Callback called when the manager is disposed
  70144. */
  70145. onDispose: () => void;
  70146. private _capacity;
  70147. private _spriteTexture;
  70148. private _epsilon;
  70149. private _scene;
  70150. private _vertexData;
  70151. private _buffer;
  70152. private _vertexBuffers;
  70153. private _indexBuffer;
  70154. private _effectBase;
  70155. private _effectFog;
  70156. /**
  70157. * Gets or sets the spritesheet texture
  70158. */
  70159. texture: Texture;
  70160. /**
  70161. * Creates a new sprite manager
  70162. * @param name defines the manager's name
  70163. * @param imgUrl defines the sprite sheet url
  70164. * @param capacity defines the maximum allowed number of sprites
  70165. * @param cellSize defines the size of a sprite cell
  70166. * @param scene defines the hosting scene
  70167. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70168. * @param samplingMode defines the smapling mode to use with spritesheet
  70169. */
  70170. constructor(
  70171. /** defines the manager's name */
  70172. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70173. private _appendSpriteVertex;
  70174. /**
  70175. * Intersects the sprites with a ray
  70176. * @param ray defines the ray to intersect with
  70177. * @param camera defines the current active camera
  70178. * @param predicate defines a predicate used to select candidate sprites
  70179. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70180. * @returns null if no hit or a PickingInfo
  70181. */
  70182. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70183. /**
  70184. * Render all child sprites
  70185. */
  70186. render(): void;
  70187. /**
  70188. * Release associated resources
  70189. */
  70190. dispose(): void;
  70191. }
  70192. }
  70193. declare module BABYLON {
  70194. /**
  70195. * Class used to represent a sprite
  70196. * @see http://doc.babylonjs.com/babylon101/sprites
  70197. */
  70198. export class Sprite {
  70199. /** defines the name */
  70200. name: string;
  70201. /** Gets or sets the current world position */
  70202. position: Vector3;
  70203. /** Gets or sets the main color */
  70204. color: Color4;
  70205. /** Gets or sets the width */
  70206. width: number;
  70207. /** Gets or sets the height */
  70208. height: number;
  70209. /** Gets or sets rotation angle */
  70210. angle: number;
  70211. /** Gets or sets the cell index in the sprite sheet */
  70212. cellIndex: number;
  70213. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70214. invertU: number;
  70215. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70216. invertV: number;
  70217. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70218. disposeWhenFinishedAnimating: boolean;
  70219. /** Gets the list of attached animations */
  70220. animations: Animation[];
  70221. /** Gets or sets a boolean indicating if the sprite can be picked */
  70222. isPickable: boolean;
  70223. /**
  70224. * Gets or sets the associated action manager
  70225. */
  70226. actionManager: Nullable<ActionManager>;
  70227. private _animationStarted;
  70228. private _loopAnimation;
  70229. private _fromIndex;
  70230. private _toIndex;
  70231. private _delay;
  70232. private _direction;
  70233. private _manager;
  70234. private _time;
  70235. private _onAnimationEnd;
  70236. /**
  70237. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70238. */
  70239. isVisible: boolean;
  70240. /**
  70241. * Gets or sets the sprite size
  70242. */
  70243. size: number;
  70244. /**
  70245. * Creates a new Sprite
  70246. * @param name defines the name
  70247. * @param manager defines the manager
  70248. */
  70249. constructor(
  70250. /** defines the name */
  70251. name: string, manager: ISpriteManager);
  70252. /**
  70253. * Starts an animation
  70254. * @param from defines the initial key
  70255. * @param to defines the end key
  70256. * @param loop defines if the animation must loop
  70257. * @param delay defines the start delay (in ms)
  70258. * @param onAnimationEnd defines a callback to call when animation ends
  70259. */
  70260. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70261. /** Stops current animation (if any) */
  70262. stopAnimation(): void;
  70263. /** @hidden */
  70264. _animate(deltaTime: number): void;
  70265. /** Release associated resources */
  70266. dispose(): void;
  70267. }
  70268. }
  70269. declare module BABYLON {
  70270. /**
  70271. * Information about the result of picking within a scene
  70272. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70273. */
  70274. export class PickingInfo {
  70275. /** @hidden */
  70276. _pickingUnavailable: boolean;
  70277. /**
  70278. * If the pick collided with an object
  70279. */
  70280. hit: boolean;
  70281. /**
  70282. * Distance away where the pick collided
  70283. */
  70284. distance: number;
  70285. /**
  70286. * The location of pick collision
  70287. */
  70288. pickedPoint: Nullable<Vector3>;
  70289. /**
  70290. * The mesh corresponding the the pick collision
  70291. */
  70292. pickedMesh: Nullable<AbstractMesh>;
  70293. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  70294. bu: number;
  70295. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  70296. bv: number;
  70297. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  70298. faceId: number;
  70299. /** Id of the the submesh that was picked */
  70300. subMeshId: number;
  70301. /** If a sprite was picked, this will be the sprite the pick collided with */
  70302. pickedSprite: Nullable<Sprite>;
  70303. /**
  70304. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  70305. */
  70306. originMesh: Nullable<AbstractMesh>;
  70307. /**
  70308. * The ray that was used to perform the picking.
  70309. */
  70310. ray: Nullable<Ray>;
  70311. /**
  70312. * Gets the normal correspodning to the face the pick collided with
  70313. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  70314. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  70315. * @returns The normal correspodning to the face the pick collided with
  70316. */
  70317. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  70318. /**
  70319. * Gets the texture coordinates of where the pick occured
  70320. * @returns the vector containing the coordnates of the texture
  70321. */
  70322. getTextureCoordinates(): Nullable<Vector2>;
  70323. }
  70324. }
  70325. declare module BABYLON {
  70326. /**
  70327. * Gather the list of pointer event types as constants.
  70328. */
  70329. export class PointerEventTypes {
  70330. /**
  70331. * 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.
  70332. */
  70333. static readonly POINTERDOWN: number;
  70334. /**
  70335. * The pointerup event is fired when a pointer is no longer active.
  70336. */
  70337. static readonly POINTERUP: number;
  70338. /**
  70339. * The pointermove event is fired when a pointer changes coordinates.
  70340. */
  70341. static readonly POINTERMOVE: number;
  70342. /**
  70343. * The pointerwheel event is fired when a mouse wheel has been rotated.
  70344. */
  70345. static readonly POINTERWHEEL: number;
  70346. /**
  70347. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  70348. */
  70349. static readonly POINTERPICK: number;
  70350. /**
  70351. * The pointertap event is fired when a the object has been touched and released without drag.
  70352. */
  70353. static readonly POINTERTAP: number;
  70354. /**
  70355. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  70356. */
  70357. static readonly POINTERDOUBLETAP: number;
  70358. }
  70359. /**
  70360. * Base class of pointer info types.
  70361. */
  70362. export class PointerInfoBase {
  70363. /**
  70364. * Defines the type of event (PointerEventTypes)
  70365. */
  70366. type: number;
  70367. /**
  70368. * Defines the related dom event
  70369. */
  70370. event: PointerEvent | MouseWheelEvent;
  70371. /**
  70372. * Instantiates the base class of pointers info.
  70373. * @param type Defines the type of event (PointerEventTypes)
  70374. * @param event Defines the related dom event
  70375. */
  70376. constructor(
  70377. /**
  70378. * Defines the type of event (PointerEventTypes)
  70379. */
  70380. type: number,
  70381. /**
  70382. * Defines the related dom event
  70383. */
  70384. event: PointerEvent | MouseWheelEvent);
  70385. }
  70386. /**
  70387. * This class is used to store pointer related info for the onPrePointerObservable event.
  70388. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  70389. */
  70390. export class PointerInfoPre extends PointerInfoBase {
  70391. /**
  70392. * Ray from a pointer if availible (eg. 6dof controller)
  70393. */
  70394. ray: Nullable<Ray>;
  70395. /**
  70396. * Defines the local position of the pointer on the canvas.
  70397. */
  70398. localPosition: Vector2;
  70399. /**
  70400. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  70401. */
  70402. skipOnPointerObservable: boolean;
  70403. /**
  70404. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  70405. * @param type Defines the type of event (PointerEventTypes)
  70406. * @param event Defines the related dom event
  70407. * @param localX Defines the local x coordinates of the pointer when the event occured
  70408. * @param localY Defines the local y coordinates of the pointer when the event occured
  70409. */
  70410. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  70411. }
  70412. /**
  70413. * This type contains all the data related to a pointer event in Babylon.js.
  70414. * 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.
  70415. */
  70416. export class PointerInfo extends PointerInfoBase {
  70417. /**
  70418. * Defines the picking info associated to the info (if any)\
  70419. */
  70420. pickInfo: Nullable<PickingInfo>;
  70421. /**
  70422. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  70423. * @param type Defines the type of event (PointerEventTypes)
  70424. * @param event Defines the related dom event
  70425. * @param pickInfo Defines the picking info associated to the info (if any)\
  70426. */
  70427. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  70428. /**
  70429. * Defines the picking info associated to the info (if any)\
  70430. */
  70431. pickInfo: Nullable<PickingInfo>);
  70432. }
  70433. /**
  70434. * Data relating to a touch event on the screen.
  70435. */
  70436. export interface PointerTouch {
  70437. /**
  70438. * X coordinate of touch.
  70439. */
  70440. x: number;
  70441. /**
  70442. * Y coordinate of touch.
  70443. */
  70444. y: number;
  70445. /**
  70446. * Id of touch. Unique for each finger.
  70447. */
  70448. pointerId: number;
  70449. /**
  70450. * Event type passed from DOM.
  70451. */
  70452. type: any;
  70453. }
  70454. }
  70455. declare module BABYLON {
  70456. /**
  70457. * Manage the mouse inputs to control the movement of a free camera.
  70458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70459. */
  70460. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  70461. /**
  70462. * Define if touch is enabled in the mouse input
  70463. */
  70464. touchEnabled: boolean;
  70465. /**
  70466. * Defines the camera the input is attached to.
  70467. */
  70468. camera: FreeCamera;
  70469. /**
  70470. * Defines the buttons associated with the input to handle camera move.
  70471. */
  70472. buttons: number[];
  70473. /**
  70474. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  70475. */
  70476. angularSensibility: number;
  70477. private _pointerInput;
  70478. private _onMouseMove;
  70479. private _observer;
  70480. private previousPosition;
  70481. /**
  70482. * Manage the mouse inputs to control the movement of a free camera.
  70483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70484. * @param touchEnabled Defines if touch is enabled or not
  70485. */
  70486. constructor(
  70487. /**
  70488. * Define if touch is enabled in the mouse input
  70489. */
  70490. touchEnabled?: boolean);
  70491. /**
  70492. * Attach the input controls to a specific dom element to get the input from.
  70493. * @param element Defines the element the controls should be listened from
  70494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70495. */
  70496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70497. /**
  70498. * Called on JS contextmenu event.
  70499. * Override this method to provide functionality.
  70500. */
  70501. protected onContextMenu(evt: PointerEvent): void;
  70502. /**
  70503. * Detach the current controls from the specified dom element.
  70504. * @param element Defines the element to stop listening the inputs from
  70505. */
  70506. detachControl(element: Nullable<HTMLElement>): void;
  70507. /**
  70508. * Gets the class name of the current intput.
  70509. * @returns the class name
  70510. */
  70511. getClassName(): string;
  70512. /**
  70513. * Get the friendly name associated with the input class.
  70514. * @returns the input friendly name
  70515. */
  70516. getSimpleName(): string;
  70517. }
  70518. }
  70519. declare module BABYLON {
  70520. /**
  70521. * Manage the touch inputs to control the movement of a free camera.
  70522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70523. */
  70524. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  70525. /**
  70526. * Defines the camera the input is attached to.
  70527. */
  70528. camera: FreeCamera;
  70529. /**
  70530. * Defines the touch sensibility for rotation.
  70531. * The higher the faster.
  70532. */
  70533. touchAngularSensibility: number;
  70534. /**
  70535. * Defines the touch sensibility for move.
  70536. * The higher the faster.
  70537. */
  70538. touchMoveSensibility: number;
  70539. private _offsetX;
  70540. private _offsetY;
  70541. private _pointerPressed;
  70542. private _pointerInput;
  70543. private _observer;
  70544. private _onLostFocus;
  70545. /**
  70546. * Attach the input controls to a specific dom element to get the input from.
  70547. * @param element Defines the element the controls should be listened from
  70548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70549. */
  70550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70551. /**
  70552. * Detach the current controls from the specified dom element.
  70553. * @param element Defines the element to stop listening the inputs from
  70554. */
  70555. detachControl(element: Nullable<HTMLElement>): void;
  70556. /**
  70557. * Update the current camera state depending on the inputs that have been used this frame.
  70558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70559. */
  70560. checkInputs(): void;
  70561. /**
  70562. * Gets the class name of the current intput.
  70563. * @returns the class name
  70564. */
  70565. getClassName(): string;
  70566. /**
  70567. * Get the friendly name associated with the input class.
  70568. * @returns the input friendly name
  70569. */
  70570. getSimpleName(): string;
  70571. }
  70572. }
  70573. declare module BABYLON {
  70574. /**
  70575. * Default Inputs manager for the FreeCamera.
  70576. * It groups all the default supported inputs for ease of use.
  70577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70578. */
  70579. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  70580. /**
  70581. * Instantiates a new FreeCameraInputsManager.
  70582. * @param camera Defines the camera the inputs belong to
  70583. */
  70584. constructor(camera: FreeCamera);
  70585. /**
  70586. * Add keyboard input support to the input manager.
  70587. * @returns the current input manager
  70588. */
  70589. addKeyboard(): FreeCameraInputsManager;
  70590. /**
  70591. * Add mouse input support to the input manager.
  70592. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  70593. * @returns the current input manager
  70594. */
  70595. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  70596. /**
  70597. * Add touch input support to the input manager.
  70598. * @returns the current input manager
  70599. */
  70600. addTouch(): FreeCameraInputsManager;
  70601. }
  70602. }
  70603. declare module BABYLON {
  70604. /**
  70605. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70606. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  70607. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70608. */
  70609. export class FreeCamera extends TargetCamera {
  70610. /**
  70611. * Define the collision ellipsoid of the camera.
  70612. * This is helpful to simulate a camera body like the player body around the camera
  70613. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  70614. */
  70615. ellipsoid: Vector3;
  70616. /**
  70617. * Define an offset for the position of the ellipsoid around the camera.
  70618. * This can be helpful to determine the center of the body near the gravity center of the body
  70619. * instead of its head.
  70620. */
  70621. ellipsoidOffset: Vector3;
  70622. /**
  70623. * Enable or disable collisions of the camera with the rest of the scene objects.
  70624. */
  70625. checkCollisions: boolean;
  70626. /**
  70627. * Enable or disable gravity on the camera.
  70628. */
  70629. applyGravity: boolean;
  70630. /**
  70631. * Define the input manager associated to the camera.
  70632. */
  70633. inputs: FreeCameraInputsManager;
  70634. /**
  70635. * Gets the input sensibility for a mouse input. (default is 2000.0)
  70636. * Higher values reduce sensitivity.
  70637. */
  70638. /**
  70639. * Sets the input sensibility for a mouse input. (default is 2000.0)
  70640. * Higher values reduce sensitivity.
  70641. */
  70642. angularSensibility: number;
  70643. /**
  70644. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70645. */
  70646. keysUp: number[];
  70647. /**
  70648. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70649. */
  70650. keysDown: number[];
  70651. /**
  70652. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70653. */
  70654. keysLeft: number[];
  70655. /**
  70656. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70657. */
  70658. keysRight: number[];
  70659. /**
  70660. * Event raised when the camera collide with a mesh in the scene.
  70661. */
  70662. onCollide: (collidedMesh: AbstractMesh) => void;
  70663. private _collider;
  70664. private _needMoveForGravity;
  70665. private _oldPosition;
  70666. private _diffPosition;
  70667. private _newPosition;
  70668. /** @hidden */
  70669. _localDirection: Vector3;
  70670. /** @hidden */
  70671. _transformedDirection: Vector3;
  70672. /**
  70673. * Instantiates a Free Camera.
  70674. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70675. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  70676. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70677. * @param name Define the name of the camera in the scene
  70678. * @param position Define the start position of the camera in the scene
  70679. * @param scene Define the scene the camera belongs to
  70680. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70681. */
  70682. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70683. /**
  70684. * Attached controls to the current camera.
  70685. * @param element Defines the element the controls should be listened from
  70686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70687. */
  70688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70689. /**
  70690. * Detach the current controls from the camera.
  70691. * The camera will stop reacting to inputs.
  70692. * @param element Defines the element to stop listening the inputs from
  70693. */
  70694. detachControl(element: HTMLElement): void;
  70695. private _collisionMask;
  70696. /**
  70697. * Define a collision mask to limit the list of object the camera can collide with
  70698. */
  70699. collisionMask: number;
  70700. /** @hidden */
  70701. _collideWithWorld(displacement: Vector3): void;
  70702. private _onCollisionPositionChange;
  70703. /** @hidden */
  70704. _checkInputs(): void;
  70705. /** @hidden */
  70706. _decideIfNeedsToMove(): boolean;
  70707. /** @hidden */
  70708. _updatePosition(): void;
  70709. /**
  70710. * Destroy the camera and release the current resources hold by it.
  70711. */
  70712. dispose(): void;
  70713. /**
  70714. * Gets the current object class name.
  70715. * @return the class name
  70716. */
  70717. getClassName(): string;
  70718. }
  70719. }
  70720. declare module BABYLON {
  70721. /**
  70722. * Represents a gamepad control stick position
  70723. */
  70724. export class StickValues {
  70725. /**
  70726. * The x component of the control stick
  70727. */
  70728. x: number;
  70729. /**
  70730. * The y component of the control stick
  70731. */
  70732. y: number;
  70733. /**
  70734. * Initializes the gamepad x and y control stick values
  70735. * @param x The x component of the gamepad control stick value
  70736. * @param y The y component of the gamepad control stick value
  70737. */
  70738. constructor(
  70739. /**
  70740. * The x component of the control stick
  70741. */
  70742. x: number,
  70743. /**
  70744. * The y component of the control stick
  70745. */
  70746. y: number);
  70747. }
  70748. /**
  70749. * An interface which manages callbacks for gamepad button changes
  70750. */
  70751. export interface GamepadButtonChanges {
  70752. /**
  70753. * Called when a gamepad has been changed
  70754. */
  70755. changed: boolean;
  70756. /**
  70757. * Called when a gamepad press event has been triggered
  70758. */
  70759. pressChanged: boolean;
  70760. /**
  70761. * Called when a touch event has been triggered
  70762. */
  70763. touchChanged: boolean;
  70764. /**
  70765. * Called when a value has changed
  70766. */
  70767. valueChanged: boolean;
  70768. }
  70769. /**
  70770. * Represents a gamepad
  70771. */
  70772. export class Gamepad {
  70773. /**
  70774. * The id of the gamepad
  70775. */
  70776. id: string;
  70777. /**
  70778. * The index of the gamepad
  70779. */
  70780. index: number;
  70781. /**
  70782. * The browser gamepad
  70783. */
  70784. browserGamepad: any;
  70785. /**
  70786. * Specifies what type of gamepad this represents
  70787. */
  70788. type: number;
  70789. private _leftStick;
  70790. private _rightStick;
  70791. /** @hidden */
  70792. _isConnected: boolean;
  70793. private _leftStickAxisX;
  70794. private _leftStickAxisY;
  70795. private _rightStickAxisX;
  70796. private _rightStickAxisY;
  70797. /**
  70798. * Triggered when the left control stick has been changed
  70799. */
  70800. private _onleftstickchanged;
  70801. /**
  70802. * Triggered when the right control stick has been changed
  70803. */
  70804. private _onrightstickchanged;
  70805. /**
  70806. * Represents a gamepad controller
  70807. */
  70808. static GAMEPAD: number;
  70809. /**
  70810. * Represents a generic controller
  70811. */
  70812. static GENERIC: number;
  70813. /**
  70814. * Represents an XBox controller
  70815. */
  70816. static XBOX: number;
  70817. /**
  70818. * Represents a pose-enabled controller
  70819. */
  70820. static POSE_ENABLED: number;
  70821. /**
  70822. * Specifies whether the left control stick should be Y-inverted
  70823. */
  70824. protected _invertLeftStickY: boolean;
  70825. /**
  70826. * Specifies if the gamepad has been connected
  70827. */
  70828. readonly isConnected: boolean;
  70829. /**
  70830. * Initializes the gamepad
  70831. * @param id The id of the gamepad
  70832. * @param index The index of the gamepad
  70833. * @param browserGamepad The browser gamepad
  70834. * @param leftStickX The x component of the left joystick
  70835. * @param leftStickY The y component of the left joystick
  70836. * @param rightStickX The x component of the right joystick
  70837. * @param rightStickY The y component of the right joystick
  70838. */
  70839. constructor(
  70840. /**
  70841. * The id of the gamepad
  70842. */
  70843. id: string,
  70844. /**
  70845. * The index of the gamepad
  70846. */
  70847. index: number,
  70848. /**
  70849. * The browser gamepad
  70850. */
  70851. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  70852. /**
  70853. * Callback triggered when the left joystick has changed
  70854. * @param callback
  70855. */
  70856. onleftstickchanged(callback: (values: StickValues) => void): void;
  70857. /**
  70858. * Callback triggered when the right joystick has changed
  70859. * @param callback
  70860. */
  70861. onrightstickchanged(callback: (values: StickValues) => void): void;
  70862. /**
  70863. * Gets the left joystick
  70864. */
  70865. /**
  70866. * Sets the left joystick values
  70867. */
  70868. leftStick: StickValues;
  70869. /**
  70870. * Gets the right joystick
  70871. */
  70872. /**
  70873. * Sets the right joystick value
  70874. */
  70875. rightStick: StickValues;
  70876. /**
  70877. * Updates the gamepad joystick positions
  70878. */
  70879. update(): void;
  70880. /**
  70881. * Disposes the gamepad
  70882. */
  70883. dispose(): void;
  70884. }
  70885. /**
  70886. * Represents a generic gamepad
  70887. */
  70888. export class GenericPad extends Gamepad {
  70889. private _buttons;
  70890. private _onbuttondown;
  70891. private _onbuttonup;
  70892. /**
  70893. * Observable triggered when a button has been pressed
  70894. */
  70895. onButtonDownObservable: Observable<number>;
  70896. /**
  70897. * Observable triggered when a button has been released
  70898. */
  70899. onButtonUpObservable: Observable<number>;
  70900. /**
  70901. * Callback triggered when a button has been pressed
  70902. * @param callback Called when a button has been pressed
  70903. */
  70904. onbuttondown(callback: (buttonPressed: number) => void): void;
  70905. /**
  70906. * Callback triggered when a button has been released
  70907. * @param callback Called when a button has been released
  70908. */
  70909. onbuttonup(callback: (buttonReleased: number) => void): void;
  70910. /**
  70911. * Initializes the generic gamepad
  70912. * @param id The id of the generic gamepad
  70913. * @param index The index of the generic gamepad
  70914. * @param browserGamepad The browser gamepad
  70915. */
  70916. constructor(id: string, index: number, browserGamepad: any);
  70917. private _setButtonValue;
  70918. /**
  70919. * Updates the generic gamepad
  70920. */
  70921. update(): void;
  70922. /**
  70923. * Disposes the generic gamepad
  70924. */
  70925. dispose(): void;
  70926. }
  70927. }
  70928. declare module BABYLON {
  70929. /**
  70930. * Defines the types of pose enabled controllers that are supported
  70931. */
  70932. export enum PoseEnabledControllerType {
  70933. /**
  70934. * HTC Vive
  70935. */
  70936. VIVE = 0,
  70937. /**
  70938. * Oculus Rift
  70939. */
  70940. OCULUS = 1,
  70941. /**
  70942. * Windows mixed reality
  70943. */
  70944. WINDOWS = 2,
  70945. /**
  70946. * Samsung gear VR
  70947. */
  70948. GEAR_VR = 3,
  70949. /**
  70950. * Google Daydream
  70951. */
  70952. DAYDREAM = 4,
  70953. /**
  70954. * Generic
  70955. */
  70956. GENERIC = 5
  70957. }
  70958. /**
  70959. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70960. */
  70961. export interface MutableGamepadButton {
  70962. /**
  70963. * Value of the button/trigger
  70964. */
  70965. value: number;
  70966. /**
  70967. * If the button/trigger is currently touched
  70968. */
  70969. touched: boolean;
  70970. /**
  70971. * If the button/trigger is currently pressed
  70972. */
  70973. pressed: boolean;
  70974. }
  70975. /**
  70976. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70977. * @hidden
  70978. */
  70979. export interface ExtendedGamepadButton extends GamepadButton {
  70980. /**
  70981. * If the button/trigger is currently pressed
  70982. */
  70983. readonly pressed: boolean;
  70984. /**
  70985. * If the button/trigger is currently touched
  70986. */
  70987. readonly touched: boolean;
  70988. /**
  70989. * Value of the button/trigger
  70990. */
  70991. readonly value: number;
  70992. }
  70993. /** @hidden */
  70994. export interface _GamePadFactory {
  70995. /**
  70996. * Returns wether or not the current gamepad can be created for this type of controller.
  70997. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70998. * @returns true if it can be created, otherwise false
  70999. */
  71000. canCreate(gamepadInfo: any): boolean;
  71001. /**
  71002. * Creates a new instance of the Gamepad.
  71003. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71004. * @returns the new gamepad instance
  71005. */
  71006. create(gamepadInfo: any): Gamepad;
  71007. }
  71008. /**
  71009. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71010. */
  71011. export class PoseEnabledControllerHelper {
  71012. /** @hidden */
  71013. static _ControllerFactories: _GamePadFactory[];
  71014. /** @hidden */
  71015. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71016. /**
  71017. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71018. * @param vrGamepad the gamepad to initialized
  71019. * @returns a vr controller of the type the gamepad identified as
  71020. */
  71021. static InitiateController(vrGamepad: any): Gamepad;
  71022. }
  71023. /**
  71024. * Defines the PoseEnabledController object that contains state of a vr capable controller
  71025. */
  71026. export class PoseEnabledController extends Gamepad implements PoseControlled {
  71027. private _deviceRoomPosition;
  71028. private _deviceRoomRotationQuaternion;
  71029. /**
  71030. * The device position in babylon space
  71031. */
  71032. devicePosition: Vector3;
  71033. /**
  71034. * The device rotation in babylon space
  71035. */
  71036. deviceRotationQuaternion: Quaternion;
  71037. /**
  71038. * The scale factor of the device in babylon space
  71039. */
  71040. deviceScaleFactor: number;
  71041. /**
  71042. * (Likely devicePosition should be used instead) The device position in its room space
  71043. */
  71044. position: Vector3;
  71045. /**
  71046. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  71047. */
  71048. rotationQuaternion: Quaternion;
  71049. /**
  71050. * The type of controller (Eg. Windows mixed reality)
  71051. */
  71052. controllerType: PoseEnabledControllerType;
  71053. protected _calculatedPosition: Vector3;
  71054. private _calculatedRotation;
  71055. /**
  71056. * The raw pose from the device
  71057. */
  71058. rawPose: DevicePose;
  71059. private _trackPosition;
  71060. private _maxRotationDistFromHeadset;
  71061. private _draggedRoomRotation;
  71062. /**
  71063. * @hidden
  71064. */
  71065. _disableTrackPosition(fixedPosition: Vector3): void;
  71066. /**
  71067. * Internal, the mesh attached to the controller
  71068. * @hidden
  71069. */
  71070. _mesh: Nullable<AbstractMesh>;
  71071. private _poseControlledCamera;
  71072. private _leftHandSystemQuaternion;
  71073. /**
  71074. * Internal, matrix used to convert room space to babylon space
  71075. * @hidden
  71076. */
  71077. _deviceToWorld: Matrix;
  71078. /**
  71079. * Node to be used when casting a ray from the controller
  71080. * @hidden
  71081. */
  71082. _pointingPoseNode: Nullable<TransformNode>;
  71083. /**
  71084. * Name of the child mesh that can be used to cast a ray from the controller
  71085. */
  71086. static readonly POINTING_POSE: string;
  71087. /**
  71088. * Creates a new PoseEnabledController from a gamepad
  71089. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71090. */
  71091. constructor(browserGamepad: any);
  71092. private _workingMatrix;
  71093. /**
  71094. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71095. */
  71096. update(): void;
  71097. /**
  71098. * Updates only the pose device and mesh without doing any button event checking
  71099. */
  71100. protected _updatePoseAndMesh(): void;
  71101. /**
  71102. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71103. * @param poseData raw pose fromthe device
  71104. */
  71105. updateFromDevice(poseData: DevicePose): void;
  71106. /**
  71107. * @hidden
  71108. */
  71109. _meshAttachedObservable: Observable<AbstractMesh>;
  71110. /**
  71111. * Attaches a mesh to the controller
  71112. * @param mesh the mesh to be attached
  71113. */
  71114. attachToMesh(mesh: AbstractMesh): void;
  71115. /**
  71116. * Attaches the controllers mesh to a camera
  71117. * @param camera the camera the mesh should be attached to
  71118. */
  71119. attachToPoseControlledCamera(camera: TargetCamera): void;
  71120. /**
  71121. * Disposes of the controller
  71122. */
  71123. dispose(): void;
  71124. /**
  71125. * The mesh that is attached to the controller
  71126. */
  71127. readonly mesh: Nullable<AbstractMesh>;
  71128. /**
  71129. * Gets the ray of the controller in the direction the controller is pointing
  71130. * @param length the length the resulting ray should be
  71131. * @returns a ray in the direction the controller is pointing
  71132. */
  71133. getForwardRay(length?: number): Ray;
  71134. }
  71135. }
  71136. declare module BABYLON {
  71137. /**
  71138. * Defines the WebVRController object that represents controllers tracked in 3D space
  71139. */
  71140. export abstract class WebVRController extends PoseEnabledController {
  71141. /**
  71142. * Internal, the default controller model for the controller
  71143. */
  71144. protected _defaultModel: AbstractMesh;
  71145. /**
  71146. * Fired when the trigger state has changed
  71147. */
  71148. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71149. /**
  71150. * Fired when the main button state has changed
  71151. */
  71152. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71153. /**
  71154. * Fired when the secondary button state has changed
  71155. */
  71156. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71157. /**
  71158. * Fired when the pad state has changed
  71159. */
  71160. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71161. /**
  71162. * Fired when controllers stick values have changed
  71163. */
  71164. onPadValuesChangedObservable: Observable<StickValues>;
  71165. /**
  71166. * Array of button availible on the controller
  71167. */
  71168. protected _buttons: Array<MutableGamepadButton>;
  71169. private _onButtonStateChange;
  71170. /**
  71171. * Fired when a controller button's state has changed
  71172. * @param callback the callback containing the button that was modified
  71173. */
  71174. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71175. /**
  71176. * X and Y axis corrisponding to the controllers joystick
  71177. */
  71178. pad: StickValues;
  71179. /**
  71180. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71181. */
  71182. hand: string;
  71183. /**
  71184. * The default controller model for the controller
  71185. */
  71186. readonly defaultModel: AbstractMesh;
  71187. /**
  71188. * Creates a new WebVRController from a gamepad
  71189. * @param vrGamepad the gamepad that the WebVRController should be created from
  71190. */
  71191. constructor(vrGamepad: any);
  71192. /**
  71193. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71194. */
  71195. update(): void;
  71196. /**
  71197. * Function to be called when a button is modified
  71198. */
  71199. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71200. /**
  71201. * Loads a mesh and attaches it to the controller
  71202. * @param scene the scene the mesh should be added to
  71203. * @param meshLoaded callback for when the mesh has been loaded
  71204. */
  71205. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71206. private _setButtonValue;
  71207. private _changes;
  71208. private _checkChanges;
  71209. /**
  71210. * Disposes of th webVRCOntroller
  71211. */
  71212. dispose(): void;
  71213. }
  71214. }
  71215. declare module BABYLON {
  71216. /**
  71217. * The HemisphericLight simulates the ambient environment light,
  71218. * so the passed direction is the light reflection direction, not the incoming direction.
  71219. */
  71220. export class HemisphericLight extends Light {
  71221. /**
  71222. * The groundColor is the light in the opposite direction to the one specified during creation.
  71223. * 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.
  71224. */
  71225. groundColor: Color3;
  71226. /**
  71227. * The light reflection direction, not the incoming direction.
  71228. */
  71229. direction: Vector3;
  71230. /**
  71231. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71232. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71233. * The HemisphericLight can't cast shadows.
  71234. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71235. * @param name The friendly name of the light
  71236. * @param direction The direction of the light reflection
  71237. * @param scene The scene the light belongs to
  71238. */
  71239. constructor(name: string, direction: Vector3, scene: Scene);
  71240. protected _buildUniformLayout(): void;
  71241. /**
  71242. * Returns the string "HemisphericLight".
  71243. * @return The class name
  71244. */
  71245. getClassName(): string;
  71246. /**
  71247. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71248. * Returns the updated direction.
  71249. * @param target The target the direction should point to
  71250. * @return The computed direction
  71251. */
  71252. setDirectionToTarget(target: Vector3): Vector3;
  71253. /**
  71254. * Returns the shadow generator associated to the light.
  71255. * @returns Always null for hemispheric lights because it does not support shadows.
  71256. */
  71257. getShadowGenerator(): Nullable<IShadowGenerator>;
  71258. /**
  71259. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  71260. * @param effect The effect to update
  71261. * @param lightIndex The index of the light in the effect to update
  71262. * @returns The hemispheric light
  71263. */
  71264. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  71265. /**
  71266. * Computes the world matrix of the node
  71267. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71268. * @param useWasUpdatedFlag defines a reserved property
  71269. * @returns the world matrix
  71270. */
  71271. computeWorldMatrix(): Matrix;
  71272. /**
  71273. * Returns the integer 3.
  71274. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  71275. */
  71276. getTypeID(): number;
  71277. /**
  71278. * Prepares the list of defines specific to the light type.
  71279. * @param defines the list of defines
  71280. * @param lightIndex defines the index of the light for the effect
  71281. */
  71282. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  71283. }
  71284. }
  71285. declare module BABYLON {
  71286. /**
  71287. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  71288. * IMPORTANT!! The data is right-hand data.
  71289. * @export
  71290. * @interface DevicePose
  71291. */
  71292. export interface DevicePose {
  71293. /**
  71294. * The position of the device, values in array are [x,y,z].
  71295. */
  71296. readonly position: Nullable<Float32Array>;
  71297. /**
  71298. * The linearVelocity of the device, values in array are [x,y,z].
  71299. */
  71300. readonly linearVelocity: Nullable<Float32Array>;
  71301. /**
  71302. * The linearAcceleration of the device, values in array are [x,y,z].
  71303. */
  71304. readonly linearAcceleration: Nullable<Float32Array>;
  71305. /**
  71306. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  71307. */
  71308. readonly orientation: Nullable<Float32Array>;
  71309. /**
  71310. * The angularVelocity of the device, values in array are [x,y,z].
  71311. */
  71312. readonly angularVelocity: Nullable<Float32Array>;
  71313. /**
  71314. * The angularAcceleration of the device, values in array are [x,y,z].
  71315. */
  71316. readonly angularAcceleration: Nullable<Float32Array>;
  71317. }
  71318. /**
  71319. * Interface representing a pose controlled object in Babylon.
  71320. * A pose controlled object has both regular pose values as well as pose values
  71321. * from an external device such as a VR head mounted display
  71322. */
  71323. export interface PoseControlled {
  71324. /**
  71325. * The position of the object in babylon space.
  71326. */
  71327. position: Vector3;
  71328. /**
  71329. * The rotation quaternion of the object in babylon space.
  71330. */
  71331. rotationQuaternion: Quaternion;
  71332. /**
  71333. * The position of the device in babylon space.
  71334. */
  71335. devicePosition?: Vector3;
  71336. /**
  71337. * The rotation quaternion of the device in babylon space.
  71338. */
  71339. deviceRotationQuaternion: Quaternion;
  71340. /**
  71341. * The raw pose coming from the device.
  71342. */
  71343. rawPose: Nullable<DevicePose>;
  71344. /**
  71345. * The scale of the device to be used when translating from device space to babylon space.
  71346. */
  71347. deviceScaleFactor: number;
  71348. /**
  71349. * Updates the poseControlled values based on the input device pose.
  71350. * @param poseData the pose data to update the object with
  71351. */
  71352. updateFromDevice(poseData: DevicePose): void;
  71353. }
  71354. /**
  71355. * Set of options to customize the webVRCamera
  71356. */
  71357. export interface WebVROptions {
  71358. /**
  71359. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  71360. */
  71361. trackPosition?: boolean;
  71362. /**
  71363. * Sets the scale of the vrDevice in babylon space. (default: 1)
  71364. */
  71365. positionScale?: number;
  71366. /**
  71367. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  71368. */
  71369. displayName?: string;
  71370. /**
  71371. * Should the native controller meshes be initialized. (default: true)
  71372. */
  71373. controllerMeshes?: boolean;
  71374. /**
  71375. * Creating a default HemiLight only on controllers. (default: true)
  71376. */
  71377. defaultLightingOnControllers?: boolean;
  71378. /**
  71379. * If you don't want to use the default VR button of the helper. (default: false)
  71380. */
  71381. useCustomVRButton?: boolean;
  71382. /**
  71383. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  71384. */
  71385. customVRButton?: HTMLButtonElement;
  71386. /**
  71387. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  71388. */
  71389. rayLength?: number;
  71390. /**
  71391. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  71392. */
  71393. defaultHeight?: number;
  71394. }
  71395. /**
  71396. * This represents a WebVR camera.
  71397. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  71398. * @example http://doc.babylonjs.com/how_to/webvr_camera
  71399. */
  71400. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  71401. private webVROptions;
  71402. /**
  71403. * @hidden
  71404. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  71405. */
  71406. _vrDevice: any;
  71407. /**
  71408. * The rawPose of the vrDevice.
  71409. */
  71410. rawPose: Nullable<DevicePose>;
  71411. private _onVREnabled;
  71412. private _specsVersion;
  71413. private _attached;
  71414. private _frameData;
  71415. protected _descendants: Array<Node>;
  71416. private _deviceRoomPosition;
  71417. /** @hidden */
  71418. _deviceRoomRotationQuaternion: Quaternion;
  71419. private _standingMatrix;
  71420. /**
  71421. * Represents device position in babylon space.
  71422. */
  71423. devicePosition: Vector3;
  71424. /**
  71425. * Represents device rotation in babylon space.
  71426. */
  71427. deviceRotationQuaternion: Quaternion;
  71428. /**
  71429. * The scale of the device to be used when translating from device space to babylon space.
  71430. */
  71431. deviceScaleFactor: number;
  71432. private _deviceToWorld;
  71433. private _worldToDevice;
  71434. /**
  71435. * References to the webVR controllers for the vrDevice.
  71436. */
  71437. controllers: Array<WebVRController>;
  71438. /**
  71439. * Emits an event when a controller is attached.
  71440. */
  71441. onControllersAttachedObservable: Observable<WebVRController[]>;
  71442. /**
  71443. * Emits an event when a controller's mesh has been loaded;
  71444. */
  71445. onControllerMeshLoadedObservable: Observable<WebVRController>;
  71446. /**
  71447. * Emits an event when the HMD's pose has been updated.
  71448. */
  71449. onPoseUpdatedFromDeviceObservable: Observable<any>;
  71450. private _poseSet;
  71451. /**
  71452. * If the rig cameras be used as parent instead of this camera.
  71453. */
  71454. rigParenting: boolean;
  71455. private _lightOnControllers;
  71456. private _defaultHeight?;
  71457. /**
  71458. * Instantiates a WebVRFreeCamera.
  71459. * @param name The name of the WebVRFreeCamera
  71460. * @param position The starting anchor position for the camera
  71461. * @param scene The scene the camera belongs to
  71462. * @param webVROptions a set of customizable options for the webVRCamera
  71463. */
  71464. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  71465. /**
  71466. * Gets the device distance from the ground in meters.
  71467. * @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.
  71468. */
  71469. deviceDistanceToRoomGround(): number;
  71470. /**
  71471. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71472. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  71473. */
  71474. useStandingMatrix(callback?: (bool: boolean) => void): void;
  71475. /**
  71476. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71477. * @returns A promise with a boolean set to if the standing matrix is supported.
  71478. */
  71479. useStandingMatrixAsync(): Promise<boolean>;
  71480. /**
  71481. * Disposes the camera
  71482. */
  71483. dispose(): void;
  71484. /**
  71485. * Gets a vrController by name.
  71486. * @param name The name of the controller to retreive
  71487. * @returns the controller matching the name specified or null if not found
  71488. */
  71489. getControllerByName(name: string): Nullable<WebVRController>;
  71490. private _leftController;
  71491. /**
  71492. * The controller corrisponding to the users left hand.
  71493. */
  71494. readonly leftController: Nullable<WebVRController>;
  71495. private _rightController;
  71496. /**
  71497. * The controller corrisponding to the users right hand.
  71498. */
  71499. readonly rightController: Nullable<WebVRController>;
  71500. /**
  71501. * Casts a ray forward from the vrCamera's gaze.
  71502. * @param length Length of the ray (default: 100)
  71503. * @returns the ray corrisponding to the gaze
  71504. */
  71505. getForwardRay(length?: number): Ray;
  71506. /**
  71507. * @hidden
  71508. * Updates the camera based on device's frame data
  71509. */
  71510. _checkInputs(): void;
  71511. /**
  71512. * Updates the poseControlled values based on the input device pose.
  71513. * @param poseData Pose coming from the device
  71514. */
  71515. updateFromDevice(poseData: DevicePose): void;
  71516. private _htmlElementAttached;
  71517. private _detachIfAttached;
  71518. /**
  71519. * WebVR's attach control will start broadcasting frames to the device.
  71520. * Note that in certain browsers (chrome for example) this function must be called
  71521. * within a user-interaction callback. Example:
  71522. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  71523. *
  71524. * @param element html element to attach the vrDevice to
  71525. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  71526. */
  71527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71528. /**
  71529. * Detaches the camera from the html element and disables VR
  71530. *
  71531. * @param element html element to detach from
  71532. */
  71533. detachControl(element: HTMLElement): void;
  71534. /**
  71535. * @returns the name of this class
  71536. */
  71537. getClassName(): string;
  71538. /**
  71539. * Calls resetPose on the vrDisplay
  71540. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  71541. */
  71542. resetToCurrentRotation(): void;
  71543. /**
  71544. * @hidden
  71545. * Updates the rig cameras (left and right eye)
  71546. */
  71547. _updateRigCameras(): void;
  71548. private _workingVector;
  71549. private _oneVector;
  71550. private _workingMatrix;
  71551. private updateCacheCalled;
  71552. private _correctPositionIfNotTrackPosition;
  71553. /**
  71554. * @hidden
  71555. * Updates the cached values of the camera
  71556. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  71557. */
  71558. _updateCache(ignoreParentClass?: boolean): void;
  71559. /**
  71560. * @hidden
  71561. * Get current device position in babylon world
  71562. */
  71563. _computeDevicePosition(): void;
  71564. /**
  71565. * Updates the current device position and rotation in the babylon world
  71566. */
  71567. update(): void;
  71568. /**
  71569. * @hidden
  71570. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  71571. * @returns an identity matrix
  71572. */
  71573. _getViewMatrix(): Matrix;
  71574. private _tmpMatrix;
  71575. /**
  71576. * This function is called by the two RIG cameras.
  71577. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  71578. * @hidden
  71579. */
  71580. _getWebVRViewMatrix(): Matrix;
  71581. /** @hidden */
  71582. _getWebVRProjectionMatrix(): Matrix;
  71583. private _onGamepadConnectedObserver;
  71584. private _onGamepadDisconnectedObserver;
  71585. private _updateCacheWhenTrackingDisabledObserver;
  71586. /**
  71587. * Initializes the controllers and their meshes
  71588. */
  71589. initControllers(): void;
  71590. }
  71591. }
  71592. declare module BABYLON {
  71593. /**
  71594. * Size options for a post process
  71595. */
  71596. export type PostProcessOptions = {
  71597. width: number;
  71598. height: number;
  71599. };
  71600. /**
  71601. * PostProcess can be used to apply a shader to a texture after it has been rendered
  71602. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71603. */
  71604. export class PostProcess {
  71605. /** Name of the PostProcess. */
  71606. name: string;
  71607. /**
  71608. * Gets or sets the unique id of the post process
  71609. */
  71610. uniqueId: number;
  71611. /**
  71612. * Width of the texture to apply the post process on
  71613. */
  71614. width: number;
  71615. /**
  71616. * Height of the texture to apply the post process on
  71617. */
  71618. height: number;
  71619. /**
  71620. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  71621. * @hidden
  71622. */
  71623. _outputTexture: Nullable<InternalTexture>;
  71624. /**
  71625. * Sampling mode used by the shader
  71626. * See https://doc.babylonjs.com/classes/3.1/texture
  71627. */
  71628. renderTargetSamplingMode: number;
  71629. /**
  71630. * Clear color to use when screen clearing
  71631. */
  71632. clearColor: Color4;
  71633. /**
  71634. * If the buffer needs to be cleared before applying the post process. (default: true)
  71635. * Should be set to false if shader will overwrite all previous pixels.
  71636. */
  71637. autoClear: boolean;
  71638. /**
  71639. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  71640. */
  71641. alphaMode: number;
  71642. /**
  71643. * Sets the setAlphaBlendConstants of the babylon engine
  71644. */
  71645. alphaConstants: Color4;
  71646. /**
  71647. * Animations to be used for the post processing
  71648. */
  71649. animations: Animation[];
  71650. /**
  71651. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  71652. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  71653. */
  71654. enablePixelPerfectMode: boolean;
  71655. /**
  71656. * Force the postprocess to be applied without taking in account viewport
  71657. */
  71658. forceFullscreenViewport: boolean;
  71659. /**
  71660. * List of inspectable custom properties (used by the Inspector)
  71661. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71662. */
  71663. inspectableCustomProperties: IInspectable[];
  71664. /**
  71665. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  71666. *
  71667. * | Value | Type | Description |
  71668. * | ----- | ----------------------------------- | ----------- |
  71669. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  71670. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  71671. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  71672. *
  71673. */
  71674. scaleMode: number;
  71675. /**
  71676. * Force textures to be a power of two (default: false)
  71677. */
  71678. alwaysForcePOT: boolean;
  71679. private _samples;
  71680. /**
  71681. * Number of sample textures (default: 1)
  71682. */
  71683. samples: number;
  71684. /**
  71685. * Modify the scale of the post process to be the same as the viewport (default: false)
  71686. */
  71687. adaptScaleToCurrentViewport: boolean;
  71688. private _camera;
  71689. private _scene;
  71690. private _engine;
  71691. private _options;
  71692. private _reusable;
  71693. private _textureType;
  71694. /**
  71695. * Smart array of input and output textures for the post process.
  71696. * @hidden
  71697. */
  71698. _textures: SmartArray<InternalTexture>;
  71699. /**
  71700. * The index in _textures that corresponds to the output texture.
  71701. * @hidden
  71702. */
  71703. _currentRenderTextureInd: number;
  71704. private _effect;
  71705. private _samplers;
  71706. private _fragmentUrl;
  71707. private _vertexUrl;
  71708. private _parameters;
  71709. private _scaleRatio;
  71710. protected _indexParameters: any;
  71711. private _shareOutputWithPostProcess;
  71712. private _texelSize;
  71713. private _forcedOutputTexture;
  71714. /**
  71715. * Returns the fragment url or shader name used in the post process.
  71716. * @returns the fragment url or name in the shader store.
  71717. */
  71718. getEffectName(): string;
  71719. /**
  71720. * An event triggered when the postprocess is activated.
  71721. */
  71722. onActivateObservable: Observable<Camera>;
  71723. private _onActivateObserver;
  71724. /**
  71725. * A function that is added to the onActivateObservable
  71726. */
  71727. onActivate: Nullable<(camera: Camera) => void>;
  71728. /**
  71729. * An event triggered when the postprocess changes its size.
  71730. */
  71731. onSizeChangedObservable: Observable<PostProcess>;
  71732. private _onSizeChangedObserver;
  71733. /**
  71734. * A function that is added to the onSizeChangedObservable
  71735. */
  71736. onSizeChanged: (postProcess: PostProcess) => void;
  71737. /**
  71738. * An event triggered when the postprocess applies its effect.
  71739. */
  71740. onApplyObservable: Observable<Effect>;
  71741. private _onApplyObserver;
  71742. /**
  71743. * A function that is added to the onApplyObservable
  71744. */
  71745. onApply: (effect: Effect) => void;
  71746. /**
  71747. * An event triggered before rendering the postprocess
  71748. */
  71749. onBeforeRenderObservable: Observable<Effect>;
  71750. private _onBeforeRenderObserver;
  71751. /**
  71752. * A function that is added to the onBeforeRenderObservable
  71753. */
  71754. onBeforeRender: (effect: Effect) => void;
  71755. /**
  71756. * An event triggered after rendering the postprocess
  71757. */
  71758. onAfterRenderObservable: Observable<Effect>;
  71759. private _onAfterRenderObserver;
  71760. /**
  71761. * A function that is added to the onAfterRenderObservable
  71762. */
  71763. onAfterRender: (efect: Effect) => void;
  71764. /**
  71765. * 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
  71766. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  71767. */
  71768. inputTexture: InternalTexture;
  71769. /**
  71770. * Gets the camera which post process is applied to.
  71771. * @returns The camera the post process is applied to.
  71772. */
  71773. getCamera(): Camera;
  71774. /**
  71775. * Gets the texel size of the postprocess.
  71776. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  71777. */
  71778. readonly texelSize: Vector2;
  71779. /**
  71780. * Creates a new instance PostProcess
  71781. * @param name The name of the PostProcess.
  71782. * @param fragmentUrl The url of the fragment shader to be used.
  71783. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  71784. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  71785. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71786. * @param camera The camera to apply the render pass to.
  71787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71788. * @param engine The engine which the post process will be applied. (default: current engine)
  71789. * @param reusable If the post process can be reused on the same frame. (default: false)
  71790. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  71791. * @param textureType Type of textures used when performing the post process. (default: 0)
  71792. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  71793. * @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
  71794. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  71795. */
  71796. constructor(
  71797. /** Name of the PostProcess. */
  71798. 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);
  71799. /**
  71800. * Gets a string idenfifying the name of the class
  71801. * @returns "PostProcess" string
  71802. */
  71803. getClassName(): string;
  71804. /**
  71805. * Gets the engine which this post process belongs to.
  71806. * @returns The engine the post process was enabled with.
  71807. */
  71808. getEngine(): Engine;
  71809. /**
  71810. * The effect that is created when initializing the post process.
  71811. * @returns The created effect corrisponding the the postprocess.
  71812. */
  71813. getEffect(): Effect;
  71814. /**
  71815. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  71816. * @param postProcess The post process to share the output with.
  71817. * @returns This post process.
  71818. */
  71819. shareOutputWith(postProcess: PostProcess): PostProcess;
  71820. /**
  71821. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  71822. * This should be called if the post process that shares output with this post process is disabled/disposed.
  71823. */
  71824. useOwnOutput(): void;
  71825. /**
  71826. * Updates the effect with the current post process compile time values and recompiles the shader.
  71827. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71828. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71829. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71830. * @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
  71831. * @param onCompiled Called when the shader has been compiled.
  71832. * @param onError Called if there is an error when compiling a shader.
  71833. */
  71834. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71835. /**
  71836. * The post process is reusable if it can be used multiple times within one frame.
  71837. * @returns If the post process is reusable
  71838. */
  71839. isReusable(): boolean;
  71840. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  71841. markTextureDirty(): void;
  71842. /**
  71843. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  71844. * 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.
  71845. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  71846. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  71847. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  71848. * @returns The target texture that was bound to be written to.
  71849. */
  71850. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  71851. /**
  71852. * If the post process is supported.
  71853. */
  71854. readonly isSupported: boolean;
  71855. /**
  71856. * The aspect ratio of the output texture.
  71857. */
  71858. readonly aspectRatio: number;
  71859. /**
  71860. * Get a value indicating if the post-process is ready to be used
  71861. * @returns true if the post-process is ready (shader is compiled)
  71862. */
  71863. isReady(): boolean;
  71864. /**
  71865. * Binds all textures and uniforms to the shader, this will be run on every pass.
  71866. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  71867. */
  71868. apply(): Nullable<Effect>;
  71869. private _disposeTextures;
  71870. /**
  71871. * Disposes the post process.
  71872. * @param camera The camera to dispose the post process on.
  71873. */
  71874. dispose(camera?: Camera): void;
  71875. }
  71876. }
  71877. declare module BABYLON {
  71878. /**
  71879. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71880. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71881. */
  71882. export class PostProcessManager {
  71883. private _scene;
  71884. private _indexBuffer;
  71885. private _vertexBuffers;
  71886. /**
  71887. * Creates a new instance PostProcess
  71888. * @param scene The scene that the post process is associated with.
  71889. */
  71890. constructor(scene: Scene);
  71891. private _prepareBuffers;
  71892. private _buildIndexBuffer;
  71893. /**
  71894. * Rebuilds the vertex buffers of the manager.
  71895. * @hidden
  71896. */
  71897. _rebuild(): void;
  71898. /**
  71899. * Prepares a frame to be run through a post process.
  71900. * @param sourceTexture The input texture to the post procesess. (default: null)
  71901. * @param postProcesses An array of post processes to be run. (default: null)
  71902. * @returns True if the post processes were able to be run.
  71903. * @hidden
  71904. */
  71905. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  71906. /**
  71907. * Manually render a set of post processes to a texture.
  71908. * @param postProcesses An array of post processes to be run.
  71909. * @param targetTexture The target texture to render to.
  71910. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  71911. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  71912. * @param lodLevel defines which lod of the texture to render to
  71913. */
  71914. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  71915. /**
  71916. * Finalize the result of the output of the postprocesses.
  71917. * @param doNotPresent If true the result will not be displayed to the screen.
  71918. * @param targetTexture The target texture to render to.
  71919. * @param faceIndex The index of the face to bind the target texture to.
  71920. * @param postProcesses The array of post processes to render.
  71921. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71922. * @hidden
  71923. */
  71924. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71925. /**
  71926. * Disposes of the post process manager.
  71927. */
  71928. dispose(): void;
  71929. }
  71930. }
  71931. declare module BABYLON {
  71932. interface AbstractScene {
  71933. /**
  71934. * The list of layers (background and foreground) of the scene
  71935. */
  71936. layers: Array<Layer>;
  71937. }
  71938. /**
  71939. * Defines the layer scene component responsible to manage any layers
  71940. * in a given scene.
  71941. */
  71942. export class LayerSceneComponent implements ISceneComponent {
  71943. /**
  71944. * The component name helpfull to identify the component in the list of scene components.
  71945. */
  71946. readonly name: string;
  71947. /**
  71948. * The scene the component belongs to.
  71949. */
  71950. scene: Scene;
  71951. private _engine;
  71952. /**
  71953. * Creates a new instance of the component for the given scene
  71954. * @param scene Defines the scene to register the component in
  71955. */
  71956. constructor(scene: Scene);
  71957. /**
  71958. * Registers the component in a given scene
  71959. */
  71960. register(): void;
  71961. /**
  71962. * Rebuilds the elements related to this component in case of
  71963. * context lost for instance.
  71964. */
  71965. rebuild(): void;
  71966. /**
  71967. * Disposes the component and the associated ressources.
  71968. */
  71969. dispose(): void;
  71970. private _draw;
  71971. private _drawCameraPredicate;
  71972. private _drawCameraBackground;
  71973. private _drawCameraForeground;
  71974. private _drawRenderTargetPredicate;
  71975. private _drawRenderTargetBackground;
  71976. private _drawRenderTargetForeground;
  71977. }
  71978. }
  71979. declare module BABYLON {
  71980. /** @hidden */
  71981. export var layerPixelShader: {
  71982. name: string;
  71983. shader: string;
  71984. };
  71985. }
  71986. declare module BABYLON {
  71987. /** @hidden */
  71988. export var layerVertexShader: {
  71989. name: string;
  71990. shader: string;
  71991. };
  71992. }
  71993. declare module BABYLON {
  71994. /**
  71995. * This represents a full screen 2d layer.
  71996. * This can be useful to display a picture in the background of your scene for instance.
  71997. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71998. */
  71999. export class Layer {
  72000. /**
  72001. * Define the name of the layer.
  72002. */
  72003. name: string;
  72004. /**
  72005. * Define the texture the layer should display.
  72006. */
  72007. texture: Nullable<Texture>;
  72008. /**
  72009. * Is the layer in background or foreground.
  72010. */
  72011. isBackground: boolean;
  72012. /**
  72013. * Define the color of the layer (instead of texture).
  72014. */
  72015. color: Color4;
  72016. /**
  72017. * Define the scale of the layer in order to zoom in out of the texture.
  72018. */
  72019. scale: Vector2;
  72020. /**
  72021. * Define an offset for the layer in order to shift the texture.
  72022. */
  72023. offset: Vector2;
  72024. /**
  72025. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  72026. */
  72027. alphaBlendingMode: number;
  72028. /**
  72029. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  72030. * Alpha test will not mix with the background color in case of transparency.
  72031. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  72032. */
  72033. alphaTest: boolean;
  72034. /**
  72035. * Define a mask to restrict the layer to only some of the scene cameras.
  72036. */
  72037. layerMask: number;
  72038. /**
  72039. * Define the list of render target the layer is visible into.
  72040. */
  72041. renderTargetTextures: RenderTargetTexture[];
  72042. /**
  72043. * Define if the layer is only used in renderTarget or if it also
  72044. * renders in the main frame buffer of the canvas.
  72045. */
  72046. renderOnlyInRenderTargetTextures: boolean;
  72047. private _scene;
  72048. private _vertexBuffers;
  72049. private _indexBuffer;
  72050. private _effect;
  72051. private _alphaTestEffect;
  72052. /**
  72053. * An event triggered when the layer is disposed.
  72054. */
  72055. onDisposeObservable: Observable<Layer>;
  72056. private _onDisposeObserver;
  72057. /**
  72058. * Back compatibility with callback before the onDisposeObservable existed.
  72059. * The set callback will be triggered when the layer has been disposed.
  72060. */
  72061. onDispose: () => void;
  72062. /**
  72063. * An event triggered before rendering the scene
  72064. */
  72065. onBeforeRenderObservable: Observable<Layer>;
  72066. private _onBeforeRenderObserver;
  72067. /**
  72068. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72069. * The set callback will be triggered just before rendering the layer.
  72070. */
  72071. onBeforeRender: () => void;
  72072. /**
  72073. * An event triggered after rendering the scene
  72074. */
  72075. onAfterRenderObservable: Observable<Layer>;
  72076. private _onAfterRenderObserver;
  72077. /**
  72078. * Back compatibility with callback before the onAfterRenderObservable existed.
  72079. * The set callback will be triggered just after rendering the layer.
  72080. */
  72081. onAfterRender: () => void;
  72082. /**
  72083. * Instantiates a new layer.
  72084. * This represents a full screen 2d layer.
  72085. * This can be useful to display a picture in the background of your scene for instance.
  72086. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72087. * @param name Define the name of the layer in the scene
  72088. * @param imgUrl Define the url of the texture to display in the layer
  72089. * @param scene Define the scene the layer belongs to
  72090. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72091. * @param color Defines a color for the layer
  72092. */
  72093. constructor(
  72094. /**
  72095. * Define the name of the layer.
  72096. */
  72097. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72098. private _createIndexBuffer;
  72099. /** @hidden */
  72100. _rebuild(): void;
  72101. /**
  72102. * Renders the layer in the scene.
  72103. */
  72104. render(): void;
  72105. /**
  72106. * Disposes and releases the associated ressources.
  72107. */
  72108. dispose(): void;
  72109. }
  72110. }
  72111. declare module BABYLON {
  72112. interface AbstractScene {
  72113. /**
  72114. * The list of procedural textures added to the scene
  72115. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72116. */
  72117. proceduralTextures: Array<ProceduralTexture>;
  72118. }
  72119. /**
  72120. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72121. * in a given scene.
  72122. */
  72123. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72124. /**
  72125. * The component name helpfull to identify the component in the list of scene components.
  72126. */
  72127. readonly name: string;
  72128. /**
  72129. * The scene the component belongs to.
  72130. */
  72131. scene: Scene;
  72132. /**
  72133. * Creates a new instance of the component for the given scene
  72134. * @param scene Defines the scene to register the component in
  72135. */
  72136. constructor(scene: Scene);
  72137. /**
  72138. * Registers the component in a given scene
  72139. */
  72140. register(): void;
  72141. /**
  72142. * Rebuilds the elements related to this component in case of
  72143. * context lost for instance.
  72144. */
  72145. rebuild(): void;
  72146. /**
  72147. * Disposes the component and the associated ressources.
  72148. */
  72149. dispose(): void;
  72150. private _beforeClear;
  72151. }
  72152. }
  72153. declare module BABYLON {
  72154. /** @hidden */
  72155. export var proceduralVertexShader: {
  72156. name: string;
  72157. shader: string;
  72158. };
  72159. }
  72160. declare module BABYLON {
  72161. /**
  72162. * 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.
  72163. * This is the base class of any Procedural texture and contains most of the shareable code.
  72164. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72165. */
  72166. export class ProceduralTexture extends Texture {
  72167. isCube: boolean;
  72168. /**
  72169. * Define if the texture is enabled or not (disabled texture will not render)
  72170. */
  72171. isEnabled: boolean;
  72172. /**
  72173. * Define if the texture must be cleared before rendering (default is true)
  72174. */
  72175. autoClear: boolean;
  72176. /**
  72177. * Callback called when the texture is generated
  72178. */
  72179. onGenerated: () => void;
  72180. /**
  72181. * Event raised when the texture is generated
  72182. */
  72183. onGeneratedObservable: Observable<ProceduralTexture>;
  72184. /** @hidden */
  72185. _generateMipMaps: boolean;
  72186. /** @hidden **/
  72187. _effect: Effect;
  72188. /** @hidden */
  72189. _textures: {
  72190. [key: string]: Texture;
  72191. };
  72192. private _size;
  72193. private _currentRefreshId;
  72194. private _refreshRate;
  72195. private _vertexBuffers;
  72196. private _indexBuffer;
  72197. private _uniforms;
  72198. private _samplers;
  72199. private _fragment;
  72200. private _floats;
  72201. private _ints;
  72202. private _floatsArrays;
  72203. private _colors3;
  72204. private _colors4;
  72205. private _vectors2;
  72206. private _vectors3;
  72207. private _matrices;
  72208. private _fallbackTexture;
  72209. private _fallbackTextureUsed;
  72210. private _engine;
  72211. private _cachedDefines;
  72212. private _contentUpdateId;
  72213. private _contentData;
  72214. /**
  72215. * Instantiates a new procedural texture.
  72216. * 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.
  72217. * This is the base class of any Procedural texture and contains most of the shareable code.
  72218. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72219. * @param name Define the name of the texture
  72220. * @param size Define the size of the texture to create
  72221. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  72222. * @param scene Define the scene the texture belongs to
  72223. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  72224. * @param generateMipMaps Define if the texture should creates mip maps or not
  72225. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  72226. */
  72227. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  72228. /**
  72229. * The effect that is created when initializing the post process.
  72230. * @returns The created effect corrisponding the the postprocess.
  72231. */
  72232. getEffect(): Effect;
  72233. /**
  72234. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  72235. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  72236. */
  72237. getContent(): Nullable<ArrayBufferView>;
  72238. private _createIndexBuffer;
  72239. /** @hidden */
  72240. _rebuild(): void;
  72241. /**
  72242. * Resets the texture in order to recreate its associated resources.
  72243. * This can be called in case of context loss
  72244. */
  72245. reset(): void;
  72246. protected _getDefines(): string;
  72247. /**
  72248. * Is the texture ready to be used ? (rendered at least once)
  72249. * @returns true if ready, otherwise, false.
  72250. */
  72251. isReady(): boolean;
  72252. /**
  72253. * Resets the refresh counter of the texture and start bak from scratch.
  72254. * Could be useful to regenerate the texture if it is setup to render only once.
  72255. */
  72256. resetRefreshCounter(): void;
  72257. /**
  72258. * Set the fragment shader to use in order to render the texture.
  72259. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  72260. */
  72261. setFragment(fragment: any): void;
  72262. /**
  72263. * Define the refresh rate of the texture or the rendering frequency.
  72264. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  72265. */
  72266. refreshRate: number;
  72267. /** @hidden */
  72268. _shouldRender(): boolean;
  72269. /**
  72270. * Get the size the texture is rendering at.
  72271. * @returns the size (texture is always squared)
  72272. */
  72273. getRenderSize(): number;
  72274. /**
  72275. * Resize the texture to new value.
  72276. * @param size Define the new size the texture should have
  72277. * @param generateMipMaps Define whether the new texture should create mip maps
  72278. */
  72279. resize(size: number, generateMipMaps: boolean): void;
  72280. private _checkUniform;
  72281. /**
  72282. * Set a texture in the shader program used to render.
  72283. * @param name Define the name of the uniform samplers as defined in the shader
  72284. * @param texture Define the texture to bind to this sampler
  72285. * @return the texture itself allowing "fluent" like uniform updates
  72286. */
  72287. setTexture(name: string, texture: Texture): ProceduralTexture;
  72288. /**
  72289. * Set a float in the shader.
  72290. * @param name Define the name of the uniform as defined in the shader
  72291. * @param value Define the value to give to the uniform
  72292. * @return the texture itself allowing "fluent" like uniform updates
  72293. */
  72294. setFloat(name: string, value: number): ProceduralTexture;
  72295. /**
  72296. * Set a int in the shader.
  72297. * @param name Define the name of the uniform as defined in the shader
  72298. * @param value Define the value to give to the uniform
  72299. * @return the texture itself allowing "fluent" like uniform updates
  72300. */
  72301. setInt(name: string, value: number): ProceduralTexture;
  72302. /**
  72303. * Set an array of floats in the shader.
  72304. * @param name Define the name of the uniform as defined in the shader
  72305. * @param value Define the value to give to the uniform
  72306. * @return the texture itself allowing "fluent" like uniform updates
  72307. */
  72308. setFloats(name: string, value: number[]): ProceduralTexture;
  72309. /**
  72310. * Set a vec3 in the shader from a Color3.
  72311. * @param name Define the name of the uniform as defined in the shader
  72312. * @param value Define the value to give to the uniform
  72313. * @return the texture itself allowing "fluent" like uniform updates
  72314. */
  72315. setColor3(name: string, value: Color3): ProceduralTexture;
  72316. /**
  72317. * Set a vec4 in the shader from a Color4.
  72318. * @param name Define the name of the uniform as defined in the shader
  72319. * @param value Define the value to give to the uniform
  72320. * @return the texture itself allowing "fluent" like uniform updates
  72321. */
  72322. setColor4(name: string, value: Color4): ProceduralTexture;
  72323. /**
  72324. * Set a vec2 in the shader from a Vector2.
  72325. * @param name Define the name of the uniform as defined in the shader
  72326. * @param value Define the value to give to the uniform
  72327. * @return the texture itself allowing "fluent" like uniform updates
  72328. */
  72329. setVector2(name: string, value: Vector2): ProceduralTexture;
  72330. /**
  72331. * Set a vec3 in the shader from a Vector3.
  72332. * @param name Define the name of the uniform as defined in the shader
  72333. * @param value Define the value to give to the uniform
  72334. * @return the texture itself allowing "fluent" like uniform updates
  72335. */
  72336. setVector3(name: string, value: Vector3): ProceduralTexture;
  72337. /**
  72338. * Set a mat4 in the shader from a MAtrix.
  72339. * @param name Define the name of the uniform as defined in the shader
  72340. * @param value Define the value to give to the uniform
  72341. * @return the texture itself allowing "fluent" like uniform updates
  72342. */
  72343. setMatrix(name: string, value: Matrix): ProceduralTexture;
  72344. /**
  72345. * Render the texture to its associated render target.
  72346. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  72347. */
  72348. render(useCameraPostProcess?: boolean): void;
  72349. /**
  72350. * Clone the texture.
  72351. * @returns the cloned texture
  72352. */
  72353. clone(): ProceduralTexture;
  72354. /**
  72355. * Dispose the texture and release its asoociated resources.
  72356. */
  72357. dispose(): void;
  72358. }
  72359. }
  72360. declare module BABYLON {
  72361. /**
  72362. * This represents the base class for particle system in Babylon.
  72363. * 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.
  72364. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72365. * @example https://doc.babylonjs.com/babylon101/particles
  72366. */
  72367. export class BaseParticleSystem {
  72368. /**
  72369. * Source color is added to the destination color without alpha affecting the result
  72370. */
  72371. static BLENDMODE_ONEONE: number;
  72372. /**
  72373. * Blend current color and particle color using particle’s alpha
  72374. */
  72375. static BLENDMODE_STANDARD: number;
  72376. /**
  72377. * Add current color and particle color multiplied by particle’s alpha
  72378. */
  72379. static BLENDMODE_ADD: number;
  72380. /**
  72381. * Multiply current color with particle color
  72382. */
  72383. static BLENDMODE_MULTIPLY: number;
  72384. /**
  72385. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  72386. */
  72387. static BLENDMODE_MULTIPLYADD: number;
  72388. /**
  72389. * List of animations used by the particle system.
  72390. */
  72391. animations: Animation[];
  72392. /**
  72393. * The id of the Particle system.
  72394. */
  72395. id: string;
  72396. /**
  72397. * The friendly name of the Particle system.
  72398. */
  72399. name: string;
  72400. /**
  72401. * The rendering group used by the Particle system to chose when to render.
  72402. */
  72403. renderingGroupId: number;
  72404. /**
  72405. * The emitter represents the Mesh or position we are attaching the particle system to.
  72406. */
  72407. emitter: Nullable<AbstractMesh | Vector3>;
  72408. /**
  72409. * The maximum number of particles to emit per frame
  72410. */
  72411. emitRate: number;
  72412. /**
  72413. * If you want to launch only a few particles at once, that can be done, as well.
  72414. */
  72415. manualEmitCount: number;
  72416. /**
  72417. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72418. */
  72419. updateSpeed: number;
  72420. /**
  72421. * The amount of time the particle system is running (depends of the overall update speed).
  72422. */
  72423. targetStopDuration: number;
  72424. /**
  72425. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72426. */
  72427. disposeOnStop: boolean;
  72428. /**
  72429. * Minimum power of emitting particles.
  72430. */
  72431. minEmitPower: number;
  72432. /**
  72433. * Maximum power of emitting particles.
  72434. */
  72435. maxEmitPower: number;
  72436. /**
  72437. * Minimum life time of emitting particles.
  72438. */
  72439. minLifeTime: number;
  72440. /**
  72441. * Maximum life time of emitting particles.
  72442. */
  72443. maxLifeTime: number;
  72444. /**
  72445. * Minimum Size of emitting particles.
  72446. */
  72447. minSize: number;
  72448. /**
  72449. * Maximum Size of emitting particles.
  72450. */
  72451. maxSize: number;
  72452. /**
  72453. * Minimum scale of emitting particles on X axis.
  72454. */
  72455. minScaleX: number;
  72456. /**
  72457. * Maximum scale of emitting particles on X axis.
  72458. */
  72459. maxScaleX: number;
  72460. /**
  72461. * Minimum scale of emitting particles on Y axis.
  72462. */
  72463. minScaleY: number;
  72464. /**
  72465. * Maximum scale of emitting particles on Y axis.
  72466. */
  72467. maxScaleY: number;
  72468. /**
  72469. * Gets or sets the minimal initial rotation in radians.
  72470. */
  72471. minInitialRotation: number;
  72472. /**
  72473. * Gets or sets the maximal initial rotation in radians.
  72474. */
  72475. maxInitialRotation: number;
  72476. /**
  72477. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72478. */
  72479. minAngularSpeed: number;
  72480. /**
  72481. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72482. */
  72483. maxAngularSpeed: number;
  72484. /**
  72485. * The texture used to render each particle. (this can be a spritesheet)
  72486. */
  72487. particleTexture: Nullable<Texture>;
  72488. /**
  72489. * The layer mask we are rendering the particles through.
  72490. */
  72491. layerMask: number;
  72492. /**
  72493. * This can help using your own shader to render the particle system.
  72494. * The according effect will be created
  72495. */
  72496. customShader: any;
  72497. /**
  72498. * By default particle system starts as soon as they are created. This prevents the
  72499. * automatic start to happen and let you decide when to start emitting particles.
  72500. */
  72501. preventAutoStart: boolean;
  72502. private _noiseTexture;
  72503. /**
  72504. * Gets or sets a texture used to add random noise to particle positions
  72505. */
  72506. noiseTexture: Nullable<ProceduralTexture>;
  72507. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72508. noiseStrength: Vector3;
  72509. /**
  72510. * Callback triggered when the particle animation is ending.
  72511. */
  72512. onAnimationEnd: Nullable<() => void>;
  72513. /**
  72514. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  72515. */
  72516. blendMode: number;
  72517. /**
  72518. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72519. * to override the particles.
  72520. */
  72521. forceDepthWrite: boolean;
  72522. /** 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 */
  72523. preWarmCycles: number;
  72524. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  72525. preWarmStepOffset: number;
  72526. /**
  72527. * 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)
  72528. */
  72529. spriteCellChangeSpeed: number;
  72530. /**
  72531. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72532. */
  72533. startSpriteCellID: number;
  72534. /**
  72535. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72536. */
  72537. endSpriteCellID: number;
  72538. /**
  72539. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72540. */
  72541. spriteCellWidth: number;
  72542. /**
  72543. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72544. */
  72545. spriteCellHeight: number;
  72546. /**
  72547. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72548. */
  72549. spriteRandomStartCell: boolean;
  72550. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72551. translationPivot: Vector2;
  72552. /** @hidden */
  72553. protected _isAnimationSheetEnabled: boolean;
  72554. /**
  72555. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72556. */
  72557. beginAnimationOnStart: boolean;
  72558. /**
  72559. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72560. */
  72561. beginAnimationFrom: number;
  72562. /**
  72563. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72564. */
  72565. beginAnimationTo: number;
  72566. /**
  72567. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72568. */
  72569. beginAnimationLoop: boolean;
  72570. /**
  72571. * Gets or sets a world offset applied to all particles
  72572. */
  72573. worldOffset: Vector3;
  72574. /**
  72575. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  72576. */
  72577. isAnimationSheetEnabled: boolean;
  72578. /**
  72579. * Get hosting scene
  72580. * @returns the scene
  72581. */
  72582. getScene(): Scene;
  72583. /**
  72584. * You can use gravity if you want to give an orientation to your particles.
  72585. */
  72586. gravity: Vector3;
  72587. protected _colorGradients: Nullable<Array<ColorGradient>>;
  72588. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  72589. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  72590. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  72591. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  72592. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  72593. protected _dragGradients: Nullable<Array<FactorGradient>>;
  72594. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  72595. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  72596. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  72597. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  72598. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  72599. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  72600. /**
  72601. * Defines the delay in milliseconds before starting the system (0 by default)
  72602. */
  72603. startDelay: number;
  72604. /**
  72605. * Gets the current list of drag gradients.
  72606. * You must use addDragGradient and removeDragGradient to udpate this list
  72607. * @returns the list of drag gradients
  72608. */
  72609. getDragGradients(): Nullable<Array<FactorGradient>>;
  72610. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72611. limitVelocityDamping: number;
  72612. /**
  72613. * Gets the current list of limit velocity gradients.
  72614. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72615. * @returns the list of limit velocity gradients
  72616. */
  72617. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72618. /**
  72619. * Gets the current list of color gradients.
  72620. * You must use addColorGradient and removeColorGradient to udpate this list
  72621. * @returns the list of color gradients
  72622. */
  72623. getColorGradients(): Nullable<Array<ColorGradient>>;
  72624. /**
  72625. * Gets the current list of size gradients.
  72626. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72627. * @returns the list of size gradients
  72628. */
  72629. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72630. /**
  72631. * Gets the current list of color remap gradients.
  72632. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72633. * @returns the list of color remap gradients
  72634. */
  72635. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72636. /**
  72637. * Gets the current list of alpha remap gradients.
  72638. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72639. * @returns the list of alpha remap gradients
  72640. */
  72641. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72642. /**
  72643. * Gets the current list of life time gradients.
  72644. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72645. * @returns the list of life time gradients
  72646. */
  72647. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72648. /**
  72649. * Gets the current list of angular speed gradients.
  72650. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72651. * @returns the list of angular speed gradients
  72652. */
  72653. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72654. /**
  72655. * Gets the current list of velocity gradients.
  72656. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72657. * @returns the list of velocity gradients
  72658. */
  72659. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72660. /**
  72661. * Gets the current list of start size gradients.
  72662. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72663. * @returns the list of start size gradients
  72664. */
  72665. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72666. /**
  72667. * Gets the current list of emit rate gradients.
  72668. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72669. * @returns the list of emit rate gradients
  72670. */
  72671. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72672. /**
  72673. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72674. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72675. */
  72676. direction1: Vector3;
  72677. /**
  72678. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72679. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72680. */
  72681. direction2: Vector3;
  72682. /**
  72683. * 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.
  72684. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72685. */
  72686. minEmitBox: Vector3;
  72687. /**
  72688. * 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.
  72689. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72690. */
  72691. maxEmitBox: Vector3;
  72692. /**
  72693. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72694. */
  72695. color1: Color4;
  72696. /**
  72697. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72698. */
  72699. color2: Color4;
  72700. /**
  72701. * Color the particle will have at the end of its lifetime
  72702. */
  72703. colorDead: Color4;
  72704. /**
  72705. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  72706. */
  72707. textureMask: Color4;
  72708. /**
  72709. * The particle emitter type defines the emitter used by the particle system.
  72710. * It can be for example box, sphere, or cone...
  72711. */
  72712. particleEmitterType: IParticleEmitterType;
  72713. /** @hidden */
  72714. _isSubEmitter: boolean;
  72715. /**
  72716. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72717. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72718. */
  72719. billboardMode: number;
  72720. protected _isBillboardBased: boolean;
  72721. /**
  72722. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72723. */
  72724. isBillboardBased: boolean;
  72725. /**
  72726. * The scene the particle system belongs to.
  72727. */
  72728. protected _scene: Scene;
  72729. /**
  72730. * Local cache of defines for image processing.
  72731. */
  72732. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  72733. /**
  72734. * Default configuration related to image processing available in the standard Material.
  72735. */
  72736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  72737. /**
  72738. * Gets the image processing configuration used either in this material.
  72739. */
  72740. /**
  72741. * Sets the Default image processing configuration used either in the this material.
  72742. *
  72743. * If sets to null, the scene one is in use.
  72744. */
  72745. imageProcessingConfiguration: ImageProcessingConfiguration;
  72746. /**
  72747. * Attaches a new image processing configuration to the Standard Material.
  72748. * @param configuration
  72749. */
  72750. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  72751. /** @hidden */
  72752. protected _reset(): void;
  72753. /** @hidden */
  72754. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  72755. /**
  72756. * Instantiates a particle system.
  72757. * 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.
  72758. * @param name The name of the particle system
  72759. */
  72760. constructor(name: string);
  72761. /**
  72762. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72765. * @returns the emitter
  72766. */
  72767. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72768. /**
  72769. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72770. * @param radius The radius of the hemisphere to emit from
  72771. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72772. * @returns the emitter
  72773. */
  72774. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  72775. /**
  72776. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72777. * @param radius The radius of the sphere to emit from
  72778. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72779. * @returns the emitter
  72780. */
  72781. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  72782. /**
  72783. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72784. * @param radius The radius of the sphere to emit from
  72785. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72786. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72787. * @returns the emitter
  72788. */
  72789. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  72790. /**
  72791. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72792. * @param radius The radius of the emission cylinder
  72793. * @param height The height of the emission cylinder
  72794. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72795. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72796. * @returns the emitter
  72797. */
  72798. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  72799. /**
  72800. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72801. * @param radius The radius of the cylinder to emit from
  72802. * @param height The height of the emission cylinder
  72803. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72804. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72805. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72806. * @returns the emitter
  72807. */
  72808. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  72809. /**
  72810. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72811. * @param radius The radius of the cone to emit from
  72812. * @param angle The base angle of the cone
  72813. * @returns the emitter
  72814. */
  72815. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  72816. /**
  72817. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72818. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72819. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72820. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72821. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72822. * @returns the emitter
  72823. */
  72824. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72825. }
  72826. }
  72827. declare module BABYLON {
  72828. /**
  72829. * Type of sub emitter
  72830. */
  72831. export enum SubEmitterType {
  72832. /**
  72833. * Attached to the particle over it's lifetime
  72834. */
  72835. ATTACHED = 0,
  72836. /**
  72837. * Created when the particle dies
  72838. */
  72839. END = 1
  72840. }
  72841. /**
  72842. * Sub emitter class used to emit particles from an existing particle
  72843. */
  72844. export class SubEmitter {
  72845. /**
  72846. * the particle system to be used by the sub emitter
  72847. */
  72848. particleSystem: ParticleSystem;
  72849. /**
  72850. * Type of the submitter (Default: END)
  72851. */
  72852. type: SubEmitterType;
  72853. /**
  72854. * 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)
  72855. * Note: This only is supported when using an emitter of type Mesh
  72856. */
  72857. inheritDirection: boolean;
  72858. /**
  72859. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  72860. */
  72861. inheritedVelocityAmount: number;
  72862. /**
  72863. * Creates a sub emitter
  72864. * @param particleSystem the particle system to be used by the sub emitter
  72865. */
  72866. constructor(
  72867. /**
  72868. * the particle system to be used by the sub emitter
  72869. */
  72870. particleSystem: ParticleSystem);
  72871. /**
  72872. * Clones the sub emitter
  72873. * @returns the cloned sub emitter
  72874. */
  72875. clone(): SubEmitter;
  72876. /**
  72877. * Serialize current object to a JSON object
  72878. * @returns the serialized object
  72879. */
  72880. serialize(): any;
  72881. /** @hidden */
  72882. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72883. /**
  72884. * Creates a new SubEmitter from a serialized JSON version
  72885. * @param serializationObject defines the JSON object to read from
  72886. * @param scene defines the hosting scene
  72887. * @param rootUrl defines the rootUrl for data loading
  72888. * @returns a new SubEmitter
  72889. */
  72890. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72891. /** Release associated resources */
  72892. dispose(): void;
  72893. }
  72894. }
  72895. declare module BABYLON {
  72896. /** @hidden */
  72897. export var clipPlaneFragmentDeclaration: {
  72898. name: string;
  72899. shader: string;
  72900. };
  72901. }
  72902. declare module BABYLON {
  72903. /** @hidden */
  72904. export var imageProcessingDeclaration: {
  72905. name: string;
  72906. shader: string;
  72907. };
  72908. }
  72909. declare module BABYLON {
  72910. /** @hidden */
  72911. export var imageProcessingFunctions: {
  72912. name: string;
  72913. shader: string;
  72914. };
  72915. }
  72916. declare module BABYLON {
  72917. /** @hidden */
  72918. export var clipPlaneFragment: {
  72919. name: string;
  72920. shader: string;
  72921. };
  72922. }
  72923. declare module BABYLON {
  72924. /** @hidden */
  72925. export var particlesPixelShader: {
  72926. name: string;
  72927. shader: string;
  72928. };
  72929. }
  72930. declare module BABYLON {
  72931. /** @hidden */
  72932. export var clipPlaneVertexDeclaration: {
  72933. name: string;
  72934. shader: string;
  72935. };
  72936. }
  72937. declare module BABYLON {
  72938. /** @hidden */
  72939. export var clipPlaneVertex: {
  72940. name: string;
  72941. shader: string;
  72942. };
  72943. }
  72944. declare module BABYLON {
  72945. /** @hidden */
  72946. export var particlesVertexShader: {
  72947. name: string;
  72948. shader: string;
  72949. };
  72950. }
  72951. declare module BABYLON {
  72952. /**
  72953. * This represents a particle system in Babylon.
  72954. * 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.
  72955. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72956. * @example https://doc.babylonjs.com/babylon101/particles
  72957. */
  72958. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72959. /**
  72960. * Billboard mode will only apply to Y axis
  72961. */
  72962. static readonly BILLBOARDMODE_Y: number;
  72963. /**
  72964. * Billboard mode will apply to all axes
  72965. */
  72966. static readonly BILLBOARDMODE_ALL: number;
  72967. /**
  72968. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72969. */
  72970. static readonly BILLBOARDMODE_STRETCHED: number;
  72971. /**
  72972. * This function can be defined to provide custom update for active particles.
  72973. * This function will be called instead of regular update (age, position, color, etc.).
  72974. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72975. */
  72976. updateFunction: (particles: Particle[]) => void;
  72977. private _emitterWorldMatrix;
  72978. /**
  72979. * This function can be defined to specify initial direction for every new particle.
  72980. * It by default use the emitterType defined function
  72981. */
  72982. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72983. /**
  72984. * This function can be defined to specify initial position for every new particle.
  72985. * It by default use the emitterType defined function
  72986. */
  72987. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72988. /**
  72989. * @hidden
  72990. */
  72991. _inheritedVelocityOffset: Vector3;
  72992. /**
  72993. * An event triggered when the system is disposed
  72994. */
  72995. onDisposeObservable: Observable<ParticleSystem>;
  72996. private _onDisposeObserver;
  72997. /**
  72998. * Sets a callback that will be triggered when the system is disposed
  72999. */
  73000. onDispose: () => void;
  73001. private _particles;
  73002. private _epsilon;
  73003. private _capacity;
  73004. private _stockParticles;
  73005. private _newPartsExcess;
  73006. private _vertexData;
  73007. private _vertexBuffer;
  73008. private _vertexBuffers;
  73009. private _spriteBuffer;
  73010. private _indexBuffer;
  73011. private _effect;
  73012. private _customEffect;
  73013. private _cachedDefines;
  73014. private _scaledColorStep;
  73015. private _colorDiff;
  73016. private _scaledDirection;
  73017. private _scaledGravity;
  73018. private _currentRenderId;
  73019. private _alive;
  73020. private _useInstancing;
  73021. private _started;
  73022. private _stopped;
  73023. private _actualFrame;
  73024. private _scaledUpdateSpeed;
  73025. private _vertexBufferSize;
  73026. /** @hidden */
  73027. _currentEmitRateGradient: Nullable<FactorGradient>;
  73028. /** @hidden */
  73029. _currentEmitRate1: number;
  73030. /** @hidden */
  73031. _currentEmitRate2: number;
  73032. /** @hidden */
  73033. _currentStartSizeGradient: Nullable<FactorGradient>;
  73034. /** @hidden */
  73035. _currentStartSize1: number;
  73036. /** @hidden */
  73037. _currentStartSize2: number;
  73038. private readonly _rawTextureWidth;
  73039. private _rampGradientsTexture;
  73040. private _useRampGradients;
  73041. /** Gets or sets a boolean indicating that ramp gradients must be used
  73042. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73043. */
  73044. useRampGradients: boolean;
  73045. /**
  73046. * 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.
  73047. * 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: [])
  73048. */
  73049. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73050. private _subEmitters;
  73051. /**
  73052. * @hidden
  73053. * If the particle systems emitter should be disposed when the particle system is disposed
  73054. */
  73055. _disposeEmitterOnDispose: boolean;
  73056. /**
  73057. * The current active Sub-systems, this property is used by the root particle system only.
  73058. */
  73059. activeSubSystems: Array<ParticleSystem>;
  73060. private _rootParticleSystem;
  73061. /**
  73062. * Gets the current list of active particles
  73063. */
  73064. readonly particles: Particle[];
  73065. /**
  73066. * Returns the string "ParticleSystem"
  73067. * @returns a string containing the class name
  73068. */
  73069. getClassName(): string;
  73070. /**
  73071. * Instantiates a particle system.
  73072. * 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.
  73073. * @param name The name of the particle system
  73074. * @param capacity The max number of particles alive at the same time
  73075. * @param scene The scene the particle system belongs to
  73076. * @param customEffect a custom effect used to change the way particles are rendered by default
  73077. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73078. * @param epsilon Offset used to render the particles
  73079. */
  73080. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73081. private _addFactorGradient;
  73082. private _removeFactorGradient;
  73083. /**
  73084. * Adds a new life time gradient
  73085. * @param gradient defines the gradient to use (between 0 and 1)
  73086. * @param factor defines the life time factor to affect to the specified gradient
  73087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73088. * @returns the current particle system
  73089. */
  73090. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73091. /**
  73092. * Remove a specific life time gradient
  73093. * @param gradient defines the gradient to remove
  73094. * @returns the current particle system
  73095. */
  73096. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73097. /**
  73098. * Adds a new size gradient
  73099. * @param gradient defines the gradient to use (between 0 and 1)
  73100. * @param factor defines the size factor to affect to the specified gradient
  73101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73102. * @returns the current particle system
  73103. */
  73104. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73105. /**
  73106. * Remove a specific size gradient
  73107. * @param gradient defines the gradient to remove
  73108. * @returns the current particle system
  73109. */
  73110. removeSizeGradient(gradient: number): IParticleSystem;
  73111. /**
  73112. * Adds a new color remap gradient
  73113. * @param gradient defines the gradient to use (between 0 and 1)
  73114. * @param min defines the color remap minimal range
  73115. * @param max defines the color remap maximal range
  73116. * @returns the current particle system
  73117. */
  73118. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73119. /**
  73120. * Remove a specific color remap gradient
  73121. * @param gradient defines the gradient to remove
  73122. * @returns the current particle system
  73123. */
  73124. removeColorRemapGradient(gradient: number): IParticleSystem;
  73125. /**
  73126. * Adds a new alpha remap gradient
  73127. * @param gradient defines the gradient to use (between 0 and 1)
  73128. * @param min defines the alpha remap minimal range
  73129. * @param max defines the alpha remap maximal range
  73130. * @returns the current particle system
  73131. */
  73132. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73133. /**
  73134. * Remove a specific alpha remap gradient
  73135. * @param gradient defines the gradient to remove
  73136. * @returns the current particle system
  73137. */
  73138. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73139. /**
  73140. * Adds a new angular speed gradient
  73141. * @param gradient defines the gradient to use (between 0 and 1)
  73142. * @param factor defines the angular speed to affect to the specified gradient
  73143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73144. * @returns the current particle system
  73145. */
  73146. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73147. /**
  73148. * Remove a specific angular speed gradient
  73149. * @param gradient defines the gradient to remove
  73150. * @returns the current particle system
  73151. */
  73152. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73153. /**
  73154. * Adds a new velocity gradient
  73155. * @param gradient defines the gradient to use (between 0 and 1)
  73156. * @param factor defines the velocity to affect to the specified gradient
  73157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73158. * @returns the current particle system
  73159. */
  73160. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73161. /**
  73162. * Remove a specific velocity gradient
  73163. * @param gradient defines the gradient to remove
  73164. * @returns the current particle system
  73165. */
  73166. removeVelocityGradient(gradient: number): IParticleSystem;
  73167. /**
  73168. * Adds a new limit velocity gradient
  73169. * @param gradient defines the gradient to use (between 0 and 1)
  73170. * @param factor defines the limit velocity value to affect to the specified gradient
  73171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73172. * @returns the current particle system
  73173. */
  73174. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73175. /**
  73176. * Remove a specific limit velocity gradient
  73177. * @param gradient defines the gradient to remove
  73178. * @returns the current particle system
  73179. */
  73180. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73181. /**
  73182. * Adds a new drag gradient
  73183. * @param gradient defines the gradient to use (between 0 and 1)
  73184. * @param factor defines the drag value to affect to the specified gradient
  73185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73186. * @returns the current particle system
  73187. */
  73188. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73189. /**
  73190. * Remove a specific drag gradient
  73191. * @param gradient defines the gradient to remove
  73192. * @returns the current particle system
  73193. */
  73194. removeDragGradient(gradient: number): IParticleSystem;
  73195. /**
  73196. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73197. * @param gradient defines the gradient to use (between 0 and 1)
  73198. * @param factor defines the emit rate value to affect to the specified gradient
  73199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73200. * @returns the current particle system
  73201. */
  73202. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73203. /**
  73204. * Remove a specific emit rate gradient
  73205. * @param gradient defines the gradient to remove
  73206. * @returns the current particle system
  73207. */
  73208. removeEmitRateGradient(gradient: number): IParticleSystem;
  73209. /**
  73210. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73211. * @param gradient defines the gradient to use (between 0 and 1)
  73212. * @param factor defines the start size value to affect to the specified gradient
  73213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73214. * @returns the current particle system
  73215. */
  73216. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73217. /**
  73218. * Remove a specific start size gradient
  73219. * @param gradient defines the gradient to remove
  73220. * @returns the current particle system
  73221. */
  73222. removeStartSizeGradient(gradient: number): IParticleSystem;
  73223. private _createRampGradientTexture;
  73224. /**
  73225. * Gets the current list of ramp gradients.
  73226. * You must use addRampGradient and removeRampGradient to udpate this list
  73227. * @returns the list of ramp gradients
  73228. */
  73229. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73230. /**
  73231. * Adds a new ramp gradient used to remap particle colors
  73232. * @param gradient defines the gradient to use (between 0 and 1)
  73233. * @param color defines the color to affect to the specified gradient
  73234. * @returns the current particle system
  73235. */
  73236. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  73237. /**
  73238. * Remove a specific ramp gradient
  73239. * @param gradient defines the gradient to remove
  73240. * @returns the current particle system
  73241. */
  73242. removeRampGradient(gradient: number): ParticleSystem;
  73243. /**
  73244. * Adds a new color gradient
  73245. * @param gradient defines the gradient to use (between 0 and 1)
  73246. * @param color1 defines the color to affect to the specified gradient
  73247. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73248. * @returns this particle system
  73249. */
  73250. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73251. /**
  73252. * Remove a specific color gradient
  73253. * @param gradient defines the gradient to remove
  73254. * @returns this particle system
  73255. */
  73256. removeColorGradient(gradient: number): IParticleSystem;
  73257. private _fetchR;
  73258. protected _reset(): void;
  73259. private _resetEffect;
  73260. private _createVertexBuffers;
  73261. private _createIndexBuffer;
  73262. /**
  73263. * Gets the maximum number of particles active at the same time.
  73264. * @returns The max number of active particles.
  73265. */
  73266. getCapacity(): number;
  73267. /**
  73268. * Gets whether there are still active particles in the system.
  73269. * @returns True if it is alive, otherwise false.
  73270. */
  73271. isAlive(): boolean;
  73272. /**
  73273. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73274. * @returns True if it has been started, otherwise false.
  73275. */
  73276. isStarted(): boolean;
  73277. private _prepareSubEmitterInternalArray;
  73278. /**
  73279. * Starts the particle system and begins to emit
  73280. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  73281. */
  73282. start(delay?: number): void;
  73283. /**
  73284. * Stops the particle system.
  73285. * @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.
  73286. */
  73287. stop(stopSubEmitters?: boolean): void;
  73288. /**
  73289. * Remove all active particles
  73290. */
  73291. reset(): void;
  73292. /**
  73293. * @hidden (for internal use only)
  73294. */
  73295. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  73296. /**
  73297. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  73298. * Its lifetime will start back at 0.
  73299. */
  73300. recycleParticle: (particle: Particle) => void;
  73301. private _stopSubEmitters;
  73302. private _createParticle;
  73303. private _removeFromRoot;
  73304. private _emitFromParticle;
  73305. private _update;
  73306. /** @hidden */
  73307. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  73308. /** @hidden */
  73309. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  73310. /** @hidden */
  73311. private _getEffect;
  73312. /**
  73313. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73314. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  73315. */
  73316. animate(preWarmOnly?: boolean): void;
  73317. private _appendParticleVertices;
  73318. /**
  73319. * Rebuilds the particle system.
  73320. */
  73321. rebuild(): void;
  73322. /**
  73323. * Is this system ready to be used/rendered
  73324. * @return true if the system is ready
  73325. */
  73326. isReady(): boolean;
  73327. private _render;
  73328. /**
  73329. * Renders the particle system in its current state.
  73330. * @returns the current number of particles
  73331. */
  73332. render(): number;
  73333. /**
  73334. * Disposes the particle system and free the associated resources
  73335. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73336. */
  73337. dispose(disposeTexture?: boolean): void;
  73338. /**
  73339. * Clones the particle system.
  73340. * @param name The name of the cloned object
  73341. * @param newEmitter The new emitter to use
  73342. * @returns the cloned particle system
  73343. */
  73344. clone(name: string, newEmitter: any): ParticleSystem;
  73345. /**
  73346. * Serializes the particle system to a JSON object.
  73347. * @returns the JSON object
  73348. */
  73349. serialize(): any;
  73350. /** @hidden */
  73351. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  73352. /** @hidden */
  73353. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  73354. /**
  73355. * Parses a JSON object to create a particle system.
  73356. * @param parsedParticleSystem The JSON object to parse
  73357. * @param scene The scene to create the particle system in
  73358. * @param rootUrl The root url to use to load external dependencies like texture
  73359. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73360. * @returns the Parsed particle system
  73361. */
  73362. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  73363. }
  73364. }
  73365. declare module BABYLON {
  73366. /**
  73367. * A particle represents one of the element emitted by a particle system.
  73368. * This is mainly define by its coordinates, direction, velocity and age.
  73369. */
  73370. export class Particle {
  73371. /**
  73372. * The particle system the particle belongs to.
  73373. */
  73374. particleSystem: ParticleSystem;
  73375. private static _Count;
  73376. /**
  73377. * Unique ID of the particle
  73378. */
  73379. id: number;
  73380. /**
  73381. * The world position of the particle in the scene.
  73382. */
  73383. position: Vector3;
  73384. /**
  73385. * The world direction of the particle in the scene.
  73386. */
  73387. direction: Vector3;
  73388. /**
  73389. * The color of the particle.
  73390. */
  73391. color: Color4;
  73392. /**
  73393. * The color change of the particle per step.
  73394. */
  73395. colorStep: Color4;
  73396. /**
  73397. * Defines how long will the life of the particle be.
  73398. */
  73399. lifeTime: number;
  73400. /**
  73401. * The current age of the particle.
  73402. */
  73403. age: number;
  73404. /**
  73405. * The current size of the particle.
  73406. */
  73407. size: number;
  73408. /**
  73409. * The current scale of the particle.
  73410. */
  73411. scale: Vector2;
  73412. /**
  73413. * The current angle of the particle.
  73414. */
  73415. angle: number;
  73416. /**
  73417. * Defines how fast is the angle changing.
  73418. */
  73419. angularSpeed: number;
  73420. /**
  73421. * Defines the cell index used by the particle to be rendered from a sprite.
  73422. */
  73423. cellIndex: number;
  73424. /**
  73425. * The information required to support color remapping
  73426. */
  73427. remapData: Vector4;
  73428. /** @hidden */
  73429. _randomCellOffset?: number;
  73430. /** @hidden */
  73431. _initialDirection: Nullable<Vector3>;
  73432. /** @hidden */
  73433. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  73434. /** @hidden */
  73435. _initialStartSpriteCellID: number;
  73436. /** @hidden */
  73437. _initialEndSpriteCellID: number;
  73438. /** @hidden */
  73439. _currentColorGradient: Nullable<ColorGradient>;
  73440. /** @hidden */
  73441. _currentColor1: Color4;
  73442. /** @hidden */
  73443. _currentColor2: Color4;
  73444. /** @hidden */
  73445. _currentSizeGradient: Nullable<FactorGradient>;
  73446. /** @hidden */
  73447. _currentSize1: number;
  73448. /** @hidden */
  73449. _currentSize2: number;
  73450. /** @hidden */
  73451. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  73452. /** @hidden */
  73453. _currentAngularSpeed1: number;
  73454. /** @hidden */
  73455. _currentAngularSpeed2: number;
  73456. /** @hidden */
  73457. _currentVelocityGradient: Nullable<FactorGradient>;
  73458. /** @hidden */
  73459. _currentVelocity1: number;
  73460. /** @hidden */
  73461. _currentVelocity2: number;
  73462. /** @hidden */
  73463. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  73464. /** @hidden */
  73465. _currentLimitVelocity1: number;
  73466. /** @hidden */
  73467. _currentLimitVelocity2: number;
  73468. /** @hidden */
  73469. _currentDragGradient: Nullable<FactorGradient>;
  73470. /** @hidden */
  73471. _currentDrag1: number;
  73472. /** @hidden */
  73473. _currentDrag2: number;
  73474. /** @hidden */
  73475. _randomNoiseCoordinates1: Vector3;
  73476. /** @hidden */
  73477. _randomNoiseCoordinates2: Vector3;
  73478. /**
  73479. * Creates a new instance Particle
  73480. * @param particleSystem the particle system the particle belongs to
  73481. */
  73482. constructor(
  73483. /**
  73484. * The particle system the particle belongs to.
  73485. */
  73486. particleSystem: ParticleSystem);
  73487. private updateCellInfoFromSystem;
  73488. /**
  73489. * Defines how the sprite cell index is updated for the particle
  73490. */
  73491. updateCellIndex(): void;
  73492. /** @hidden */
  73493. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  73494. /** @hidden */
  73495. _inheritParticleInfoToSubEmitters(): void;
  73496. /** @hidden */
  73497. _reset(): void;
  73498. /**
  73499. * Copy the properties of particle to another one.
  73500. * @param other the particle to copy the information to.
  73501. */
  73502. copyTo(other: Particle): void;
  73503. }
  73504. }
  73505. declare module BABYLON {
  73506. /**
  73507. * Particle emitter represents a volume emitting particles.
  73508. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  73509. */
  73510. export interface IParticleEmitterType {
  73511. /**
  73512. * Called by the particle System when the direction is computed for the created particle.
  73513. * @param worldMatrix is the world matrix of the particle system
  73514. * @param directionToUpdate is the direction vector to update with the result
  73515. * @param particle is the particle we are computed the direction for
  73516. */
  73517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73518. /**
  73519. * Called by the particle System when the position is computed for the created particle.
  73520. * @param worldMatrix is the world matrix of the particle system
  73521. * @param positionToUpdate is the position vector to update with the result
  73522. * @param particle is the particle we are computed the position for
  73523. */
  73524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73525. /**
  73526. * Clones the current emitter and returns a copy of it
  73527. * @returns the new emitter
  73528. */
  73529. clone(): IParticleEmitterType;
  73530. /**
  73531. * Called by the GPUParticleSystem to setup the update shader
  73532. * @param effect defines the update shader
  73533. */
  73534. applyToShader(effect: Effect): void;
  73535. /**
  73536. * Returns a string to use to update the GPU particles update shader
  73537. * @returns the effect defines string
  73538. */
  73539. getEffectDefines(): string;
  73540. /**
  73541. * Returns a string representing the class name
  73542. * @returns a string containing the class name
  73543. */
  73544. getClassName(): string;
  73545. /**
  73546. * Serializes the particle system to a JSON object.
  73547. * @returns the JSON object
  73548. */
  73549. serialize(): any;
  73550. /**
  73551. * Parse properties from a JSON object
  73552. * @param serializationObject defines the JSON object
  73553. */
  73554. parse(serializationObject: any): void;
  73555. }
  73556. }
  73557. declare module BABYLON {
  73558. /**
  73559. * Particle emitter emitting particles from the inside of a box.
  73560. * It emits the particles randomly between 2 given directions.
  73561. */
  73562. export class BoxParticleEmitter implements IParticleEmitterType {
  73563. /**
  73564. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73565. */
  73566. direction1: Vector3;
  73567. /**
  73568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73569. */
  73570. direction2: Vector3;
  73571. /**
  73572. * 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.
  73573. */
  73574. minEmitBox: Vector3;
  73575. /**
  73576. * 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.
  73577. */
  73578. maxEmitBox: Vector3;
  73579. /**
  73580. * Creates a new instance BoxParticleEmitter
  73581. */
  73582. constructor();
  73583. /**
  73584. * Called by the particle System when the direction is computed for the created particle.
  73585. * @param worldMatrix is the world matrix of the particle system
  73586. * @param directionToUpdate is the direction vector to update with the result
  73587. * @param particle is the particle we are computed the direction for
  73588. */
  73589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73590. /**
  73591. * Called by the particle System when the position is computed for the created particle.
  73592. * @param worldMatrix is the world matrix of the particle system
  73593. * @param positionToUpdate is the position vector to update with the result
  73594. * @param particle is the particle we are computed the position for
  73595. */
  73596. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73597. /**
  73598. * Clones the current emitter and returns a copy of it
  73599. * @returns the new emitter
  73600. */
  73601. clone(): BoxParticleEmitter;
  73602. /**
  73603. * Called by the GPUParticleSystem to setup the update shader
  73604. * @param effect defines the update shader
  73605. */
  73606. applyToShader(effect: Effect): void;
  73607. /**
  73608. * Returns a string to use to update the GPU particles update shader
  73609. * @returns a string containng the defines string
  73610. */
  73611. getEffectDefines(): string;
  73612. /**
  73613. * Returns the string "BoxParticleEmitter"
  73614. * @returns a string containing the class name
  73615. */
  73616. getClassName(): string;
  73617. /**
  73618. * Serializes the particle system to a JSON object.
  73619. * @returns the JSON object
  73620. */
  73621. serialize(): any;
  73622. /**
  73623. * Parse properties from a JSON object
  73624. * @param serializationObject defines the JSON object
  73625. */
  73626. parse(serializationObject: any): void;
  73627. }
  73628. }
  73629. declare module BABYLON {
  73630. /**
  73631. * Particle emitter emitting particles from the inside of a cone.
  73632. * It emits the particles alongside the cone volume from the base to the particle.
  73633. * The emission direction might be randomized.
  73634. */
  73635. export class ConeParticleEmitter implements IParticleEmitterType {
  73636. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73637. directionRandomizer: number;
  73638. private _radius;
  73639. private _angle;
  73640. private _height;
  73641. /**
  73642. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  73643. */
  73644. radiusRange: number;
  73645. /**
  73646. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  73647. */
  73648. heightRange: number;
  73649. /**
  73650. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  73651. */
  73652. emitFromSpawnPointOnly: boolean;
  73653. /**
  73654. * Gets or sets the radius of the emission cone
  73655. */
  73656. radius: number;
  73657. /**
  73658. * Gets or sets the angle of the emission cone
  73659. */
  73660. angle: number;
  73661. private _buildHeight;
  73662. /**
  73663. * Creates a new instance ConeParticleEmitter
  73664. * @param radius the radius of the emission cone (1 by default)
  73665. * @param angle the cone base angle (PI by default)
  73666. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  73667. */
  73668. constructor(radius?: number, angle?: number,
  73669. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73670. directionRandomizer?: number);
  73671. /**
  73672. * Called by the particle System when the direction is computed for the created particle.
  73673. * @param worldMatrix is the world matrix of the particle system
  73674. * @param directionToUpdate is the direction vector to update with the result
  73675. * @param particle is the particle we are computed the direction for
  73676. */
  73677. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73678. /**
  73679. * Called by the particle System when the position is computed for the created particle.
  73680. * @param worldMatrix is the world matrix of the particle system
  73681. * @param positionToUpdate is the position vector to update with the result
  73682. * @param particle is the particle we are computed the position for
  73683. */
  73684. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73685. /**
  73686. * Clones the current emitter and returns a copy of it
  73687. * @returns the new emitter
  73688. */
  73689. clone(): ConeParticleEmitter;
  73690. /**
  73691. * Called by the GPUParticleSystem to setup the update shader
  73692. * @param effect defines the update shader
  73693. */
  73694. applyToShader(effect: Effect): void;
  73695. /**
  73696. * Returns a string to use to update the GPU particles update shader
  73697. * @returns a string containng the defines string
  73698. */
  73699. getEffectDefines(): string;
  73700. /**
  73701. * Returns the string "ConeParticleEmitter"
  73702. * @returns a string containing the class name
  73703. */
  73704. getClassName(): string;
  73705. /**
  73706. * Serializes the particle system to a JSON object.
  73707. * @returns the JSON object
  73708. */
  73709. serialize(): any;
  73710. /**
  73711. * Parse properties from a JSON object
  73712. * @param serializationObject defines the JSON object
  73713. */
  73714. parse(serializationObject: any): void;
  73715. }
  73716. }
  73717. declare module BABYLON {
  73718. /**
  73719. * Particle emitter emitting particles from the inside of a cylinder.
  73720. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  73721. */
  73722. export class CylinderParticleEmitter implements IParticleEmitterType {
  73723. /**
  73724. * The radius of the emission cylinder.
  73725. */
  73726. radius: number;
  73727. /**
  73728. * The height of the emission cylinder.
  73729. */
  73730. height: number;
  73731. /**
  73732. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73733. */
  73734. radiusRange: number;
  73735. /**
  73736. * How much to randomize the particle direction [0-1].
  73737. */
  73738. directionRandomizer: number;
  73739. /**
  73740. * Creates a new instance CylinderParticleEmitter
  73741. * @param radius the radius of the emission cylinder (1 by default)
  73742. * @param height the height of the emission cylinder (1 by default)
  73743. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73744. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73745. */
  73746. constructor(
  73747. /**
  73748. * The radius of the emission cylinder.
  73749. */
  73750. radius?: number,
  73751. /**
  73752. * The height of the emission cylinder.
  73753. */
  73754. height?: number,
  73755. /**
  73756. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73757. */
  73758. radiusRange?: number,
  73759. /**
  73760. * How much to randomize the particle direction [0-1].
  73761. */
  73762. directionRandomizer?: number);
  73763. /**
  73764. * Called by the particle System when the direction is computed for the created particle.
  73765. * @param worldMatrix is the world matrix of the particle system
  73766. * @param directionToUpdate is the direction vector to update with the result
  73767. * @param particle is the particle we are computed the direction for
  73768. */
  73769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73770. /**
  73771. * Called by the particle System when the position is computed for the created particle.
  73772. * @param worldMatrix is the world matrix of the particle system
  73773. * @param positionToUpdate is the position vector to update with the result
  73774. * @param particle is the particle we are computed the position for
  73775. */
  73776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73777. /**
  73778. * Clones the current emitter and returns a copy of it
  73779. * @returns the new emitter
  73780. */
  73781. clone(): CylinderParticleEmitter;
  73782. /**
  73783. * Called by the GPUParticleSystem to setup the update shader
  73784. * @param effect defines the update shader
  73785. */
  73786. applyToShader(effect: Effect): void;
  73787. /**
  73788. * Returns a string to use to update the GPU particles update shader
  73789. * @returns a string containng the defines string
  73790. */
  73791. getEffectDefines(): string;
  73792. /**
  73793. * Returns the string "CylinderParticleEmitter"
  73794. * @returns a string containing the class name
  73795. */
  73796. getClassName(): string;
  73797. /**
  73798. * Serializes the particle system to a JSON object.
  73799. * @returns the JSON object
  73800. */
  73801. serialize(): any;
  73802. /**
  73803. * Parse properties from a JSON object
  73804. * @param serializationObject defines the JSON object
  73805. */
  73806. parse(serializationObject: any): void;
  73807. }
  73808. /**
  73809. * Particle emitter emitting particles from the inside of a cylinder.
  73810. * It emits the particles randomly between two vectors.
  73811. */
  73812. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  73813. /**
  73814. * The min limit of the emission direction.
  73815. */
  73816. direction1: Vector3;
  73817. /**
  73818. * The max limit of the emission direction.
  73819. */
  73820. direction2: Vector3;
  73821. /**
  73822. * Creates a new instance CylinderDirectedParticleEmitter
  73823. * @param radius the radius of the emission cylinder (1 by default)
  73824. * @param height the height of the emission cylinder (1 by default)
  73825. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73826. * @param direction1 the min limit of the emission direction (up vector by default)
  73827. * @param direction2 the max limit of the emission direction (up vector by default)
  73828. */
  73829. constructor(radius?: number, height?: number, radiusRange?: number,
  73830. /**
  73831. * The min limit of the emission direction.
  73832. */
  73833. direction1?: Vector3,
  73834. /**
  73835. * The max limit of the emission direction.
  73836. */
  73837. direction2?: Vector3);
  73838. /**
  73839. * Called by the particle System when the direction is computed for the created particle.
  73840. * @param worldMatrix is the world matrix of the particle system
  73841. * @param directionToUpdate is the direction vector to update with the result
  73842. * @param particle is the particle we are computed the direction for
  73843. */
  73844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73845. /**
  73846. * Clones the current emitter and returns a copy of it
  73847. * @returns the new emitter
  73848. */
  73849. clone(): CylinderDirectedParticleEmitter;
  73850. /**
  73851. * Called by the GPUParticleSystem to setup the update shader
  73852. * @param effect defines the update shader
  73853. */
  73854. applyToShader(effect: Effect): void;
  73855. /**
  73856. * Returns a string to use to update the GPU particles update shader
  73857. * @returns a string containng the defines string
  73858. */
  73859. getEffectDefines(): string;
  73860. /**
  73861. * Returns the string "CylinderDirectedParticleEmitter"
  73862. * @returns a string containing the class name
  73863. */
  73864. getClassName(): string;
  73865. /**
  73866. * Serializes the particle system to a JSON object.
  73867. * @returns the JSON object
  73868. */
  73869. serialize(): any;
  73870. /**
  73871. * Parse properties from a JSON object
  73872. * @param serializationObject defines the JSON object
  73873. */
  73874. parse(serializationObject: any): void;
  73875. }
  73876. }
  73877. declare module BABYLON {
  73878. /**
  73879. * Particle emitter emitting particles from the inside of a hemisphere.
  73880. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73881. */
  73882. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73883. /**
  73884. * The radius of the emission hemisphere.
  73885. */
  73886. radius: number;
  73887. /**
  73888. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73889. */
  73890. radiusRange: number;
  73891. /**
  73892. * How much to randomize the particle direction [0-1].
  73893. */
  73894. directionRandomizer: number;
  73895. /**
  73896. * Creates a new instance HemisphericParticleEmitter
  73897. * @param radius the radius of the emission hemisphere (1 by default)
  73898. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73899. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73900. */
  73901. constructor(
  73902. /**
  73903. * The radius of the emission hemisphere.
  73904. */
  73905. radius?: number,
  73906. /**
  73907. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73908. */
  73909. radiusRange?: number,
  73910. /**
  73911. * How much to randomize the particle direction [0-1].
  73912. */
  73913. directionRandomizer?: number);
  73914. /**
  73915. * Called by the particle System when the direction is computed for the created particle.
  73916. * @param worldMatrix is the world matrix of the particle system
  73917. * @param directionToUpdate is the direction vector to update with the result
  73918. * @param particle is the particle we are computed the direction for
  73919. */
  73920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73921. /**
  73922. * Called by the particle System when the position is computed for the created particle.
  73923. * @param worldMatrix is the world matrix of the particle system
  73924. * @param positionToUpdate is the position vector to update with the result
  73925. * @param particle is the particle we are computed the position for
  73926. */
  73927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73928. /**
  73929. * Clones the current emitter and returns a copy of it
  73930. * @returns the new emitter
  73931. */
  73932. clone(): HemisphericParticleEmitter;
  73933. /**
  73934. * Called by the GPUParticleSystem to setup the update shader
  73935. * @param effect defines the update shader
  73936. */
  73937. applyToShader(effect: Effect): void;
  73938. /**
  73939. * Returns a string to use to update the GPU particles update shader
  73940. * @returns a string containng the defines string
  73941. */
  73942. getEffectDefines(): string;
  73943. /**
  73944. * Returns the string "HemisphericParticleEmitter"
  73945. * @returns a string containing the class name
  73946. */
  73947. getClassName(): string;
  73948. /**
  73949. * Serializes the particle system to a JSON object.
  73950. * @returns the JSON object
  73951. */
  73952. serialize(): any;
  73953. /**
  73954. * Parse properties from a JSON object
  73955. * @param serializationObject defines the JSON object
  73956. */
  73957. parse(serializationObject: any): void;
  73958. }
  73959. }
  73960. declare module BABYLON {
  73961. /**
  73962. * Particle emitter emitting particles from a point.
  73963. * It emits the particles randomly between 2 given directions.
  73964. */
  73965. export class PointParticleEmitter implements IParticleEmitterType {
  73966. /**
  73967. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73968. */
  73969. direction1: Vector3;
  73970. /**
  73971. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73972. */
  73973. direction2: Vector3;
  73974. /**
  73975. * Creates a new instance PointParticleEmitter
  73976. */
  73977. constructor();
  73978. /**
  73979. * Called by the particle System when the direction is computed for the created particle.
  73980. * @param worldMatrix is the world matrix of the particle system
  73981. * @param directionToUpdate is the direction vector to update with the result
  73982. * @param particle is the particle we are computed the direction for
  73983. */
  73984. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73985. /**
  73986. * Called by the particle System when the position is computed for the created particle.
  73987. * @param worldMatrix is the world matrix of the particle system
  73988. * @param positionToUpdate is the position vector to update with the result
  73989. * @param particle is the particle we are computed the position for
  73990. */
  73991. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73992. /**
  73993. * Clones the current emitter and returns a copy of it
  73994. * @returns the new emitter
  73995. */
  73996. clone(): PointParticleEmitter;
  73997. /**
  73998. * Called by the GPUParticleSystem to setup the update shader
  73999. * @param effect defines the update shader
  74000. */
  74001. applyToShader(effect: Effect): void;
  74002. /**
  74003. * Returns a string to use to update the GPU particles update shader
  74004. * @returns a string containng the defines string
  74005. */
  74006. getEffectDefines(): string;
  74007. /**
  74008. * Returns the string "PointParticleEmitter"
  74009. * @returns a string containing the class name
  74010. */
  74011. getClassName(): string;
  74012. /**
  74013. * Serializes the particle system to a JSON object.
  74014. * @returns the JSON object
  74015. */
  74016. serialize(): any;
  74017. /**
  74018. * Parse properties from a JSON object
  74019. * @param serializationObject defines the JSON object
  74020. */
  74021. parse(serializationObject: any): void;
  74022. }
  74023. }
  74024. declare module BABYLON {
  74025. /**
  74026. * Particle emitter emitting particles from the inside of a sphere.
  74027. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  74028. */
  74029. export class SphereParticleEmitter implements IParticleEmitterType {
  74030. /**
  74031. * The radius of the emission sphere.
  74032. */
  74033. radius: number;
  74034. /**
  74035. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74036. */
  74037. radiusRange: number;
  74038. /**
  74039. * How much to randomize the particle direction [0-1].
  74040. */
  74041. directionRandomizer: number;
  74042. /**
  74043. * Creates a new instance SphereParticleEmitter
  74044. * @param radius the radius of the emission sphere (1 by default)
  74045. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74046. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74047. */
  74048. constructor(
  74049. /**
  74050. * The radius of the emission sphere.
  74051. */
  74052. radius?: number,
  74053. /**
  74054. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74055. */
  74056. radiusRange?: number,
  74057. /**
  74058. * How much to randomize the particle direction [0-1].
  74059. */
  74060. directionRandomizer?: number);
  74061. /**
  74062. * Called by the particle System when the direction is computed for the created particle.
  74063. * @param worldMatrix is the world matrix of the particle system
  74064. * @param directionToUpdate is the direction vector to update with the result
  74065. * @param particle is the particle we are computed the direction for
  74066. */
  74067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74068. /**
  74069. * Called by the particle System when the position is computed for the created particle.
  74070. * @param worldMatrix is the world matrix of the particle system
  74071. * @param positionToUpdate is the position vector to update with the result
  74072. * @param particle is the particle we are computed the position for
  74073. */
  74074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74075. /**
  74076. * Clones the current emitter and returns a copy of it
  74077. * @returns the new emitter
  74078. */
  74079. clone(): SphereParticleEmitter;
  74080. /**
  74081. * Called by the GPUParticleSystem to setup the update shader
  74082. * @param effect defines the update shader
  74083. */
  74084. applyToShader(effect: Effect): void;
  74085. /**
  74086. * Returns a string to use to update the GPU particles update shader
  74087. * @returns a string containng the defines string
  74088. */
  74089. getEffectDefines(): string;
  74090. /**
  74091. * Returns the string "SphereParticleEmitter"
  74092. * @returns a string containing the class name
  74093. */
  74094. getClassName(): string;
  74095. /**
  74096. * Serializes the particle system to a JSON object.
  74097. * @returns the JSON object
  74098. */
  74099. serialize(): any;
  74100. /**
  74101. * Parse properties from a JSON object
  74102. * @param serializationObject defines the JSON object
  74103. */
  74104. parse(serializationObject: any): void;
  74105. }
  74106. /**
  74107. * Particle emitter emitting particles from the inside of a sphere.
  74108. * It emits the particles randomly between two vectors.
  74109. */
  74110. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74111. /**
  74112. * The min limit of the emission direction.
  74113. */
  74114. direction1: Vector3;
  74115. /**
  74116. * The max limit of the emission direction.
  74117. */
  74118. direction2: Vector3;
  74119. /**
  74120. * Creates a new instance SphereDirectedParticleEmitter
  74121. * @param radius the radius of the emission sphere (1 by default)
  74122. * @param direction1 the min limit of the emission direction (up vector by default)
  74123. * @param direction2 the max limit of the emission direction (up vector by default)
  74124. */
  74125. constructor(radius?: number,
  74126. /**
  74127. * The min limit of the emission direction.
  74128. */
  74129. direction1?: Vector3,
  74130. /**
  74131. * The max limit of the emission direction.
  74132. */
  74133. direction2?: Vector3);
  74134. /**
  74135. * Called by the particle System when the direction is computed for the created particle.
  74136. * @param worldMatrix is the world matrix of the particle system
  74137. * @param directionToUpdate is the direction vector to update with the result
  74138. * @param particle is the particle we are computed the direction for
  74139. */
  74140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74141. /**
  74142. * Clones the current emitter and returns a copy of it
  74143. * @returns the new emitter
  74144. */
  74145. clone(): SphereDirectedParticleEmitter;
  74146. /**
  74147. * Called by the GPUParticleSystem to setup the update shader
  74148. * @param effect defines the update shader
  74149. */
  74150. applyToShader(effect: Effect): void;
  74151. /**
  74152. * Returns a string to use to update the GPU particles update shader
  74153. * @returns a string containng the defines string
  74154. */
  74155. getEffectDefines(): string;
  74156. /**
  74157. * Returns the string "SphereDirectedParticleEmitter"
  74158. * @returns a string containing the class name
  74159. */
  74160. getClassName(): string;
  74161. /**
  74162. * Serializes the particle system to a JSON object.
  74163. * @returns the JSON object
  74164. */
  74165. serialize(): any;
  74166. /**
  74167. * Parse properties from a JSON object
  74168. * @param serializationObject defines the JSON object
  74169. */
  74170. parse(serializationObject: any): void;
  74171. }
  74172. }
  74173. declare module BABYLON {
  74174. /**
  74175. * Interface representing a particle system in Babylon.js.
  74176. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  74177. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  74178. */
  74179. export interface IParticleSystem {
  74180. /**
  74181. * List of animations used by the particle system.
  74182. */
  74183. animations: Animation[];
  74184. /**
  74185. * The id of the Particle system.
  74186. */
  74187. id: string;
  74188. /**
  74189. * The name of the Particle system.
  74190. */
  74191. name: string;
  74192. /**
  74193. * The emitter represents the Mesh or position we are attaching the particle system to.
  74194. */
  74195. emitter: Nullable<AbstractMesh | Vector3>;
  74196. /**
  74197. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74198. */
  74199. isBillboardBased: boolean;
  74200. /**
  74201. * The rendering group used by the Particle system to chose when to render.
  74202. */
  74203. renderingGroupId: number;
  74204. /**
  74205. * The layer mask we are rendering the particles through.
  74206. */
  74207. layerMask: number;
  74208. /**
  74209. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74210. */
  74211. updateSpeed: number;
  74212. /**
  74213. * The amount of time the particle system is running (depends of the overall update speed).
  74214. */
  74215. targetStopDuration: number;
  74216. /**
  74217. * The texture used to render each particle. (this can be a spritesheet)
  74218. */
  74219. particleTexture: Nullable<Texture>;
  74220. /**
  74221. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  74222. */
  74223. blendMode: number;
  74224. /**
  74225. * Minimum life time of emitting particles.
  74226. */
  74227. minLifeTime: number;
  74228. /**
  74229. * Maximum life time of emitting particles.
  74230. */
  74231. maxLifeTime: number;
  74232. /**
  74233. * Minimum Size of emitting particles.
  74234. */
  74235. minSize: number;
  74236. /**
  74237. * Maximum Size of emitting particles.
  74238. */
  74239. maxSize: number;
  74240. /**
  74241. * Minimum scale of emitting particles on X axis.
  74242. */
  74243. minScaleX: number;
  74244. /**
  74245. * Maximum scale of emitting particles on X axis.
  74246. */
  74247. maxScaleX: number;
  74248. /**
  74249. * Minimum scale of emitting particles on Y axis.
  74250. */
  74251. minScaleY: number;
  74252. /**
  74253. * Maximum scale of emitting particles on Y axis.
  74254. */
  74255. maxScaleY: number;
  74256. /**
  74257. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74258. */
  74259. color1: Color4;
  74260. /**
  74261. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74262. */
  74263. color2: Color4;
  74264. /**
  74265. * Color the particle will have at the end of its lifetime.
  74266. */
  74267. colorDead: Color4;
  74268. /**
  74269. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  74270. */
  74271. emitRate: number;
  74272. /**
  74273. * You can use gravity if you want to give an orientation to your particles.
  74274. */
  74275. gravity: Vector3;
  74276. /**
  74277. * Minimum power of emitting particles.
  74278. */
  74279. minEmitPower: number;
  74280. /**
  74281. * Maximum power of emitting particles.
  74282. */
  74283. maxEmitPower: number;
  74284. /**
  74285. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74286. */
  74287. minAngularSpeed: number;
  74288. /**
  74289. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74290. */
  74291. maxAngularSpeed: number;
  74292. /**
  74293. * Gets or sets the minimal initial rotation in radians.
  74294. */
  74295. minInitialRotation: number;
  74296. /**
  74297. * Gets or sets the maximal initial rotation in radians.
  74298. */
  74299. maxInitialRotation: number;
  74300. /**
  74301. * The particle emitter type defines the emitter used by the particle system.
  74302. * It can be for example box, sphere, or cone...
  74303. */
  74304. particleEmitterType: Nullable<IParticleEmitterType>;
  74305. /**
  74306. * Defines the delay in milliseconds before starting the system (0 by default)
  74307. */
  74308. startDelay: number;
  74309. /**
  74310. * 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
  74311. */
  74312. preWarmCycles: number;
  74313. /**
  74314. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  74315. */
  74316. preWarmStepOffset: number;
  74317. /**
  74318. * 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)
  74319. */
  74320. spriteCellChangeSpeed: number;
  74321. /**
  74322. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74323. */
  74324. startSpriteCellID: number;
  74325. /**
  74326. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74327. */
  74328. endSpriteCellID: number;
  74329. /**
  74330. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74331. */
  74332. spriteCellWidth: number;
  74333. /**
  74334. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74335. */
  74336. spriteCellHeight: number;
  74337. /**
  74338. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74339. */
  74340. spriteRandomStartCell: boolean;
  74341. /**
  74342. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  74343. */
  74344. isAnimationSheetEnabled: boolean;
  74345. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74346. translationPivot: Vector2;
  74347. /**
  74348. * Gets or sets a texture used to add random noise to particle positions
  74349. */
  74350. noiseTexture: Nullable<BaseTexture>;
  74351. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74352. noiseStrength: Vector3;
  74353. /**
  74354. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74355. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74356. */
  74357. billboardMode: number;
  74358. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74359. limitVelocityDamping: number;
  74360. /**
  74361. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74362. */
  74363. beginAnimationOnStart: boolean;
  74364. /**
  74365. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74366. */
  74367. beginAnimationFrom: number;
  74368. /**
  74369. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74370. */
  74371. beginAnimationTo: number;
  74372. /**
  74373. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74374. */
  74375. beginAnimationLoop: boolean;
  74376. /**
  74377. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74378. */
  74379. disposeOnStop: boolean;
  74380. /**
  74381. * Gets the maximum number of particles active at the same time.
  74382. * @returns The max number of active particles.
  74383. */
  74384. getCapacity(): number;
  74385. /**
  74386. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74387. * @returns True if it has been started, otherwise false.
  74388. */
  74389. isStarted(): boolean;
  74390. /**
  74391. * Animates the particle system for this frame.
  74392. */
  74393. animate(): void;
  74394. /**
  74395. * Renders the particle system in its current state.
  74396. * @returns the current number of particles
  74397. */
  74398. render(): number;
  74399. /**
  74400. * Dispose the particle system and frees its associated resources.
  74401. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74402. */
  74403. dispose(disposeTexture?: boolean): void;
  74404. /**
  74405. * Clones the particle system.
  74406. * @param name The name of the cloned object
  74407. * @param newEmitter The new emitter to use
  74408. * @returns the cloned particle system
  74409. */
  74410. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  74411. /**
  74412. * Serializes the particle system to a JSON object.
  74413. * @returns the JSON object
  74414. */
  74415. serialize(): any;
  74416. /**
  74417. * Rebuild the particle system
  74418. */
  74419. rebuild(): void;
  74420. /**
  74421. * Starts the particle system and begins to emit
  74422. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  74423. */
  74424. start(delay?: number): void;
  74425. /**
  74426. * Stops the particle system.
  74427. */
  74428. stop(): void;
  74429. /**
  74430. * Remove all active particles
  74431. */
  74432. reset(): void;
  74433. /**
  74434. * Is this system ready to be used/rendered
  74435. * @return true if the system is ready
  74436. */
  74437. isReady(): boolean;
  74438. /**
  74439. * Adds a new color gradient
  74440. * @param gradient defines the gradient to use (between 0 and 1)
  74441. * @param color1 defines the color to affect to the specified gradient
  74442. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74443. * @returns the current particle system
  74444. */
  74445. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74446. /**
  74447. * Remove a specific color gradient
  74448. * @param gradient defines the gradient to remove
  74449. * @returns the current particle system
  74450. */
  74451. removeColorGradient(gradient: number): IParticleSystem;
  74452. /**
  74453. * Adds a new size gradient
  74454. * @param gradient defines the gradient to use (between 0 and 1)
  74455. * @param factor defines the size factor to affect to the specified gradient
  74456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74457. * @returns the current particle system
  74458. */
  74459. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74460. /**
  74461. * Remove a specific size gradient
  74462. * @param gradient defines the gradient to remove
  74463. * @returns the current particle system
  74464. */
  74465. removeSizeGradient(gradient: number): IParticleSystem;
  74466. /**
  74467. * Gets the current list of color gradients.
  74468. * You must use addColorGradient and removeColorGradient to udpate this list
  74469. * @returns the list of color gradients
  74470. */
  74471. getColorGradients(): Nullable<Array<ColorGradient>>;
  74472. /**
  74473. * Gets the current list of size gradients.
  74474. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74475. * @returns the list of size gradients
  74476. */
  74477. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74478. /**
  74479. * Gets the current list of angular speed gradients.
  74480. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74481. * @returns the list of angular speed gradients
  74482. */
  74483. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74484. /**
  74485. * Adds a new angular speed gradient
  74486. * @param gradient defines the gradient to use (between 0 and 1)
  74487. * @param factor defines the angular speed to affect to the specified gradient
  74488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74489. * @returns the current particle system
  74490. */
  74491. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74492. /**
  74493. * Remove a specific angular speed gradient
  74494. * @param gradient defines the gradient to remove
  74495. * @returns the current particle system
  74496. */
  74497. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74498. /**
  74499. * Gets the current list of velocity gradients.
  74500. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74501. * @returns the list of velocity gradients
  74502. */
  74503. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74504. /**
  74505. * Adds a new velocity gradient
  74506. * @param gradient defines the gradient to use (between 0 and 1)
  74507. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74512. /**
  74513. * Remove a specific velocity gradient
  74514. * @param gradient defines the gradient to remove
  74515. * @returns the current particle system
  74516. */
  74517. removeVelocityGradient(gradient: number): IParticleSystem;
  74518. /**
  74519. * Gets the current list of limit velocity gradients.
  74520. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74521. * @returns the list of limit velocity gradients
  74522. */
  74523. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74524. /**
  74525. * Adds a new limit velocity gradient
  74526. * @param gradient defines the gradient to use (between 0 and 1)
  74527. * @param factor defines the limit velocity to affect to the specified gradient
  74528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74529. * @returns the current particle system
  74530. */
  74531. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74532. /**
  74533. * Remove a specific limit velocity gradient
  74534. * @param gradient defines the gradient to remove
  74535. * @returns the current particle system
  74536. */
  74537. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74538. /**
  74539. * Adds a new drag gradient
  74540. * @param gradient defines the gradient to use (between 0 and 1)
  74541. * @param factor defines the drag to affect to the specified gradient
  74542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74543. * @returns the current particle system
  74544. */
  74545. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74546. /**
  74547. * Remove a specific drag gradient
  74548. * @param gradient defines the gradient to remove
  74549. * @returns the current particle system
  74550. */
  74551. removeDragGradient(gradient: number): IParticleSystem;
  74552. /**
  74553. * Gets the current list of drag gradients.
  74554. * You must use addDragGradient and removeDragGradient to udpate this list
  74555. * @returns the list of drag gradients
  74556. */
  74557. getDragGradients(): Nullable<Array<FactorGradient>>;
  74558. /**
  74559. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74560. * @param gradient defines the gradient to use (between 0 and 1)
  74561. * @param factor defines the emit rate to affect to the specified gradient
  74562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74563. * @returns the current particle system
  74564. */
  74565. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74566. /**
  74567. * Remove a specific emit rate gradient
  74568. * @param gradient defines the gradient to remove
  74569. * @returns the current particle system
  74570. */
  74571. removeEmitRateGradient(gradient: number): IParticleSystem;
  74572. /**
  74573. * Gets the current list of emit rate gradients.
  74574. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74575. * @returns the list of emit rate gradients
  74576. */
  74577. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74578. /**
  74579. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74580. * @param gradient defines the gradient to use (between 0 and 1)
  74581. * @param factor defines the start size to affect to the specified gradient
  74582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74583. * @returns the current particle system
  74584. */
  74585. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74586. /**
  74587. * Remove a specific start size gradient
  74588. * @param gradient defines the gradient to remove
  74589. * @returns the current particle system
  74590. */
  74591. removeStartSizeGradient(gradient: number): IParticleSystem;
  74592. /**
  74593. * Gets the current list of start size gradients.
  74594. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74595. * @returns the list of start size gradients
  74596. */
  74597. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74598. /**
  74599. * Adds a new life time gradient
  74600. * @param gradient defines the gradient to use (between 0 and 1)
  74601. * @param factor defines the life time factor to affect to the specified gradient
  74602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74603. * @returns the current particle system
  74604. */
  74605. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74606. /**
  74607. * Remove a specific life time gradient
  74608. * @param gradient defines the gradient to remove
  74609. * @returns the current particle system
  74610. */
  74611. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74612. /**
  74613. * Gets the current list of life time gradients.
  74614. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74615. * @returns the list of life time gradients
  74616. */
  74617. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74618. /**
  74619. * Gets the current list of color gradients.
  74620. * You must use addColorGradient and removeColorGradient to udpate this list
  74621. * @returns the list of color gradients
  74622. */
  74623. getColorGradients(): Nullable<Array<ColorGradient>>;
  74624. /**
  74625. * Adds a new ramp gradient used to remap particle colors
  74626. * @param gradient defines the gradient to use (between 0 and 1)
  74627. * @param color defines the color to affect to the specified gradient
  74628. * @returns the current particle system
  74629. */
  74630. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  74631. /**
  74632. * Gets the current list of ramp gradients.
  74633. * You must use addRampGradient and removeRampGradient to udpate this list
  74634. * @returns the list of ramp gradients
  74635. */
  74636. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74637. /** Gets or sets a boolean indicating that ramp gradients must be used
  74638. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74639. */
  74640. useRampGradients: boolean;
  74641. /**
  74642. * Adds a new color remap gradient
  74643. * @param gradient defines the gradient to use (between 0 and 1)
  74644. * @param min defines the color remap minimal range
  74645. * @param max defines the color remap maximal range
  74646. * @returns the current particle system
  74647. */
  74648. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74649. /**
  74650. * Gets the current list of color remap gradients.
  74651. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74652. * @returns the list of color remap gradients
  74653. */
  74654. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74655. /**
  74656. * Adds a new alpha remap gradient
  74657. * @param gradient defines the gradient to use (between 0 and 1)
  74658. * @param min defines the alpha remap minimal range
  74659. * @param max defines the alpha remap maximal range
  74660. * @returns the current particle system
  74661. */
  74662. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74663. /**
  74664. * Gets the current list of alpha remap gradients.
  74665. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74666. * @returns the list of alpha remap gradients
  74667. */
  74668. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74669. /**
  74670. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74671. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74672. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74673. * @returns the emitter
  74674. */
  74675. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74676. /**
  74677. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74678. * @param radius The radius of the hemisphere to emit from
  74679. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74680. * @returns the emitter
  74681. */
  74682. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  74683. /**
  74684. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74685. * @param radius The radius of the sphere to emit from
  74686. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74687. * @returns the emitter
  74688. */
  74689. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  74690. /**
  74691. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74692. * @param radius The radius of the sphere to emit from
  74693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74695. * @returns the emitter
  74696. */
  74697. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74698. /**
  74699. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74700. * @param radius The radius of the emission cylinder
  74701. * @param height The height of the emission cylinder
  74702. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74703. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74704. * @returns the emitter
  74705. */
  74706. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  74707. /**
  74708. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74709. * @param radius The radius of the cylinder to emit from
  74710. * @param height The height of the emission cylinder
  74711. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74712. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74713. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74714. * @returns the emitter
  74715. */
  74716. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74717. /**
  74718. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74719. * @param radius The radius of the cone to emit from
  74720. * @param angle The base angle of the cone
  74721. * @returns the emitter
  74722. */
  74723. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  74724. /**
  74725. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74728. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74729. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74730. * @returns the emitter
  74731. */
  74732. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74733. /**
  74734. * Get hosting scene
  74735. * @returns the scene
  74736. */
  74737. getScene(): Scene;
  74738. }
  74739. }
  74740. declare module BABYLON {
  74741. /**
  74742. * Creates an instance based on a source mesh.
  74743. */
  74744. export class InstancedMesh extends AbstractMesh {
  74745. private _sourceMesh;
  74746. private _currentLOD;
  74747. /** @hidden */
  74748. _indexInSourceMeshInstanceArray: number;
  74749. constructor(name: string, source: Mesh);
  74750. /**
  74751. * Returns the string "InstancedMesh".
  74752. */
  74753. getClassName(): string;
  74754. /**
  74755. * If the source mesh receives shadows
  74756. */
  74757. readonly receiveShadows: boolean;
  74758. /**
  74759. * The material of the source mesh
  74760. */
  74761. readonly material: Nullable<Material>;
  74762. /**
  74763. * Visibility of the source mesh
  74764. */
  74765. readonly visibility: number;
  74766. /**
  74767. * Skeleton of the source mesh
  74768. */
  74769. readonly skeleton: Nullable<Skeleton>;
  74770. /**
  74771. * Rendering ground id of the source mesh
  74772. */
  74773. renderingGroupId: number;
  74774. /**
  74775. * Returns the total number of vertices (integer).
  74776. */
  74777. getTotalVertices(): number;
  74778. /**
  74779. * Returns a positive integer : the total number of indices in this mesh geometry.
  74780. * @returns the numner of indices or zero if the mesh has no geometry.
  74781. */
  74782. getTotalIndices(): number;
  74783. /**
  74784. * The source mesh of the instance
  74785. */
  74786. readonly sourceMesh: Mesh;
  74787. /**
  74788. * Is this node ready to be used/rendered
  74789. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74790. * @return {boolean} is it ready
  74791. */
  74792. isReady(completeCheck?: boolean): boolean;
  74793. /**
  74794. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74795. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74796. * @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.
  74797. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74798. */
  74799. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74800. /**
  74801. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74802. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74803. * The `data` are either a numeric array either a Float32Array.
  74804. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74805. * 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).
  74806. * Note that a new underlying VertexBuffer object is created each call.
  74807. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74808. *
  74809. * Possible `kind` values :
  74810. * - VertexBuffer.PositionKind
  74811. * - VertexBuffer.UVKind
  74812. * - VertexBuffer.UV2Kind
  74813. * - VertexBuffer.UV3Kind
  74814. * - VertexBuffer.UV4Kind
  74815. * - VertexBuffer.UV5Kind
  74816. * - VertexBuffer.UV6Kind
  74817. * - VertexBuffer.ColorKind
  74818. * - VertexBuffer.MatricesIndicesKind
  74819. * - VertexBuffer.MatricesIndicesExtraKind
  74820. * - VertexBuffer.MatricesWeightsKind
  74821. * - VertexBuffer.MatricesWeightsExtraKind
  74822. *
  74823. * Returns the Mesh.
  74824. */
  74825. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74826. /**
  74827. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74828. * If the mesh has no geometry, it is simply returned as it is.
  74829. * The `data` are either a numeric array either a Float32Array.
  74830. * No new underlying VertexBuffer object is created.
  74831. * 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.
  74832. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74833. *
  74834. * Possible `kind` values :
  74835. * - VertexBuffer.PositionKind
  74836. * - VertexBuffer.UVKind
  74837. * - VertexBuffer.UV2Kind
  74838. * - VertexBuffer.UV3Kind
  74839. * - VertexBuffer.UV4Kind
  74840. * - VertexBuffer.UV5Kind
  74841. * - VertexBuffer.UV6Kind
  74842. * - VertexBuffer.ColorKind
  74843. * - VertexBuffer.MatricesIndicesKind
  74844. * - VertexBuffer.MatricesIndicesExtraKind
  74845. * - VertexBuffer.MatricesWeightsKind
  74846. * - VertexBuffer.MatricesWeightsExtraKind
  74847. *
  74848. * Returns the Mesh.
  74849. */
  74850. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74851. /**
  74852. * Sets the mesh indices.
  74853. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74854. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74855. * This method creates a new index buffer each call.
  74856. * Returns the Mesh.
  74857. */
  74858. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74859. /**
  74860. * Boolean : True if the mesh owns the requested kind of data.
  74861. */
  74862. isVerticesDataPresent(kind: string): boolean;
  74863. /**
  74864. * Returns an array of indices (IndicesArray).
  74865. */
  74866. getIndices(): Nullable<IndicesArray>;
  74867. readonly _positions: Nullable<Vector3[]>;
  74868. /**
  74869. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74870. * This means the mesh underlying bounding box and sphere are recomputed.
  74871. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74872. * @returns the current mesh
  74873. */
  74874. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74875. /** @hidden */
  74876. _preActivate(): InstancedMesh;
  74877. /** @hidden */
  74878. _activate(renderId: number): InstancedMesh;
  74879. /**
  74880. * Returns the current associated LOD AbstractMesh.
  74881. */
  74882. getLOD(camera: Camera): AbstractMesh;
  74883. /** @hidden */
  74884. _syncSubMeshes(): InstancedMesh;
  74885. /** @hidden */
  74886. _generatePointsArray(): boolean;
  74887. /**
  74888. * Creates a new InstancedMesh from the current mesh.
  74889. * - name (string) : the cloned mesh name
  74890. * - newParent (optional Node) : the optional Node to parent the clone to.
  74891. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74892. *
  74893. * Returns the clone.
  74894. */
  74895. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74896. /**
  74897. * Disposes the InstancedMesh.
  74898. * Returns nothing.
  74899. */
  74900. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74901. }
  74902. }
  74903. declare module BABYLON {
  74904. /**
  74905. * Defines the options associated with the creation of a shader material.
  74906. */
  74907. export interface IShaderMaterialOptions {
  74908. /**
  74909. * Does the material work in alpha blend mode
  74910. */
  74911. needAlphaBlending: boolean;
  74912. /**
  74913. * Does the material work in alpha test mode
  74914. */
  74915. needAlphaTesting: boolean;
  74916. /**
  74917. * The list of attribute names used in the shader
  74918. */
  74919. attributes: string[];
  74920. /**
  74921. * The list of unifrom names used in the shader
  74922. */
  74923. uniforms: string[];
  74924. /**
  74925. * The list of UBO names used in the shader
  74926. */
  74927. uniformBuffers: string[];
  74928. /**
  74929. * The list of sampler names used in the shader
  74930. */
  74931. samplers: string[];
  74932. /**
  74933. * The list of defines used in the shader
  74934. */
  74935. defines: string[];
  74936. }
  74937. /**
  74938. * 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.
  74939. *
  74940. * This returned material effects how the mesh will look based on the code in the shaders.
  74941. *
  74942. * @see http://doc.babylonjs.com/how_to/shader_material
  74943. */
  74944. export class ShaderMaterial extends Material {
  74945. private _shaderPath;
  74946. private _options;
  74947. private _textures;
  74948. private _textureArrays;
  74949. private _floats;
  74950. private _ints;
  74951. private _floatsArrays;
  74952. private _colors3;
  74953. private _colors3Arrays;
  74954. private _colors4;
  74955. private _vectors2;
  74956. private _vectors3;
  74957. private _vectors4;
  74958. private _matrices;
  74959. private _matrices3x3;
  74960. private _matrices2x2;
  74961. private _vectors2Arrays;
  74962. private _vectors3Arrays;
  74963. private _cachedWorldViewMatrix;
  74964. private _renderId;
  74965. /**
  74966. * Instantiate a new shader material.
  74967. * 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.
  74968. * This returned material effects how the mesh will look based on the code in the shaders.
  74969. * @see http://doc.babylonjs.com/how_to/shader_material
  74970. * @param name Define the name of the material in the scene
  74971. * @param scene Define the scene the material belongs to
  74972. * @param shaderPath Defines the route to the shader code in one of three ways:
  74973. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74974. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74975. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74976. * @param options Define the options used to create the shader
  74977. */
  74978. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74979. /**
  74980. * Gets the options used to compile the shader.
  74981. * They can be modified to trigger a new compilation
  74982. */
  74983. readonly options: IShaderMaterialOptions;
  74984. /**
  74985. * Gets the current class name of the material e.g. "ShaderMaterial"
  74986. * Mainly use in serialization.
  74987. * @returns the class name
  74988. */
  74989. getClassName(): string;
  74990. /**
  74991. * Specifies if the material will require alpha blending
  74992. * @returns a boolean specifying if alpha blending is needed
  74993. */
  74994. needAlphaBlending(): boolean;
  74995. /**
  74996. * Specifies if this material should be rendered in alpha test mode
  74997. * @returns a boolean specifying if an alpha test is needed.
  74998. */
  74999. needAlphaTesting(): boolean;
  75000. private _checkUniform;
  75001. /**
  75002. * Set a texture in the shader.
  75003. * @param name Define the name of the uniform samplers as defined in the shader
  75004. * @param texture Define the texture to bind to this sampler
  75005. * @return the material itself allowing "fluent" like uniform updates
  75006. */
  75007. setTexture(name: string, texture: Texture): ShaderMaterial;
  75008. /**
  75009. * Set a texture array in the shader.
  75010. * @param name Define the name of the uniform sampler array as defined in the shader
  75011. * @param textures Define the list of textures to bind to this sampler
  75012. * @return the material itself allowing "fluent" like uniform updates
  75013. */
  75014. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75015. /**
  75016. * Set a float in the shader.
  75017. * @param name Define the name of the uniform as defined in the shader
  75018. * @param value Define the value to give to the uniform
  75019. * @return the material itself allowing "fluent" like uniform updates
  75020. */
  75021. setFloat(name: string, value: number): ShaderMaterial;
  75022. /**
  75023. * Set a int in the shader.
  75024. * @param name Define the name of the uniform as defined in the shader
  75025. * @param value Define the value to give to the uniform
  75026. * @return the material itself allowing "fluent" like uniform updates
  75027. */
  75028. setInt(name: string, value: number): ShaderMaterial;
  75029. /**
  75030. * Set an array of floats in the shader.
  75031. * @param name Define the name of the uniform as defined in the shader
  75032. * @param value Define the value to give to the uniform
  75033. * @return the material itself allowing "fluent" like uniform updates
  75034. */
  75035. setFloats(name: string, value: number[]): ShaderMaterial;
  75036. /**
  75037. * Set a vec3 in the shader from a Color3.
  75038. * @param name Define the name of the uniform as defined in the shader
  75039. * @param value Define the value to give to the uniform
  75040. * @return the material itself allowing "fluent" like uniform updates
  75041. */
  75042. setColor3(name: string, value: Color3): ShaderMaterial;
  75043. /**
  75044. * Set a vec3 array in the shader from a Color3 array.
  75045. * @param name Define the name of the uniform as defined in the shader
  75046. * @param value Define the value to give to the uniform
  75047. * @return the material itself allowing "fluent" like uniform updates
  75048. */
  75049. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75050. /**
  75051. * Set a vec4 in the shader from a Color4.
  75052. * @param name Define the name of the uniform as defined in the shader
  75053. * @param value Define the value to give to the uniform
  75054. * @return the material itself allowing "fluent" like uniform updates
  75055. */
  75056. setColor4(name: string, value: Color4): ShaderMaterial;
  75057. /**
  75058. * Set a vec2 in the shader from a Vector2.
  75059. * @param name Define the name of the uniform as defined in the shader
  75060. * @param value Define the value to give to the uniform
  75061. * @return the material itself allowing "fluent" like uniform updates
  75062. */
  75063. setVector2(name: string, value: Vector2): ShaderMaterial;
  75064. /**
  75065. * Set a vec3 in the shader from a Vector3.
  75066. * @param name Define the name of the uniform as defined in the shader
  75067. * @param value Define the value to give to the uniform
  75068. * @return the material itself allowing "fluent" like uniform updates
  75069. */
  75070. setVector3(name: string, value: Vector3): ShaderMaterial;
  75071. /**
  75072. * Set a vec4 in the shader from a Vector4.
  75073. * @param name Define the name of the uniform as defined in the shader
  75074. * @param value Define the value to give to the uniform
  75075. * @return the material itself allowing "fluent" like uniform updates
  75076. */
  75077. setVector4(name: string, value: Vector4): ShaderMaterial;
  75078. /**
  75079. * Set a mat4 in the shader from a Matrix.
  75080. * @param name Define the name of the uniform as defined in the shader
  75081. * @param value Define the value to give to the uniform
  75082. * @return the material itself allowing "fluent" like uniform updates
  75083. */
  75084. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75085. /**
  75086. * Set a mat3 in the shader from a Float32Array.
  75087. * @param name Define the name of the uniform as defined in the shader
  75088. * @param value Define the value to give to the uniform
  75089. * @return the material itself allowing "fluent" like uniform updates
  75090. */
  75091. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75092. /**
  75093. * Set a mat2 in the shader from a Float32Array.
  75094. * @param name Define the name of the uniform as defined in the shader
  75095. * @param value Define the value to give to the uniform
  75096. * @return the material itself allowing "fluent" like uniform updates
  75097. */
  75098. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75099. /**
  75100. * Set a vec2 array in the shader from a number array.
  75101. * @param name Define the name of the uniform as defined in the shader
  75102. * @param value Define the value to give to the uniform
  75103. * @return the material itself allowing "fluent" like uniform updates
  75104. */
  75105. setArray2(name: string, value: number[]): ShaderMaterial;
  75106. /**
  75107. * Set a vec3 array in the shader from a number array.
  75108. * @param name Define the name of the uniform as defined in the shader
  75109. * @param value Define the value to give to the uniform
  75110. * @return the material itself allowing "fluent" like uniform updates
  75111. */
  75112. setArray3(name: string, value: number[]): ShaderMaterial;
  75113. private _checkCache;
  75114. /**
  75115. * Checks if the material is ready to render the requested mesh
  75116. * @param mesh Define the mesh to render
  75117. * @param useInstances Define whether or not the material is used with instances
  75118. * @returns true if ready, otherwise false
  75119. */
  75120. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75121. /**
  75122. * Binds the world matrix to the material
  75123. * @param world defines the world transformation matrix
  75124. */
  75125. bindOnlyWorldMatrix(world: Matrix): void;
  75126. /**
  75127. * Binds the material to the mesh
  75128. * @param world defines the world transformation matrix
  75129. * @param mesh defines the mesh to bind the material to
  75130. */
  75131. bind(world: Matrix, mesh?: Mesh): void;
  75132. /**
  75133. * Gets the active textures from the material
  75134. * @returns an array of textures
  75135. */
  75136. getActiveTextures(): BaseTexture[];
  75137. /**
  75138. * Specifies if the material uses a texture
  75139. * @param texture defines the texture to check against the material
  75140. * @returns a boolean specifying if the material uses the texture
  75141. */
  75142. hasTexture(texture: BaseTexture): boolean;
  75143. /**
  75144. * Makes a duplicate of the material, and gives it a new name
  75145. * @param name defines the new name for the duplicated material
  75146. * @returns the cloned material
  75147. */
  75148. clone(name: string): ShaderMaterial;
  75149. /**
  75150. * Disposes the material
  75151. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75152. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75153. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75154. */
  75155. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75156. /**
  75157. * Serializes this material in a JSON representation
  75158. * @returns the serialized material object
  75159. */
  75160. serialize(): any;
  75161. /**
  75162. * Creates a shader material from parsed shader material data
  75163. * @param source defines the JSON represnetation of the material
  75164. * @param scene defines the hosting scene
  75165. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75166. * @returns a new material
  75167. */
  75168. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75169. }
  75170. }
  75171. declare module BABYLON {
  75172. /** @hidden */
  75173. export var colorPixelShader: {
  75174. name: string;
  75175. shader: string;
  75176. };
  75177. }
  75178. declare module BABYLON {
  75179. /** @hidden */
  75180. export var colorVertexShader: {
  75181. name: string;
  75182. shader: string;
  75183. };
  75184. }
  75185. declare module BABYLON {
  75186. /**
  75187. * Line mesh
  75188. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75189. */
  75190. export class LinesMesh extends Mesh {
  75191. /**
  75192. * If vertex color should be applied to the mesh
  75193. */
  75194. useVertexColor?: boolean | undefined;
  75195. /**
  75196. * If vertex alpha should be applied to the mesh
  75197. */
  75198. useVertexAlpha?: boolean | undefined;
  75199. /**
  75200. * Color of the line (Default: White)
  75201. */
  75202. color: Color3;
  75203. /**
  75204. * Alpha of the line (Default: 1)
  75205. */
  75206. alpha: number;
  75207. /**
  75208. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75209. * This margin is expressed in world space coordinates, so its value may vary.
  75210. * Default value is 0.1
  75211. */
  75212. intersectionThreshold: number;
  75213. private _colorShader;
  75214. /**
  75215. * Creates a new LinesMesh
  75216. * @param name defines the name
  75217. * @param scene defines the hosting scene
  75218. * @param parent defines the parent mesh if any
  75219. * @param source defines the optional source LinesMesh used to clone data from
  75220. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75221. * When false, achieved by calling a clone(), also passing False.
  75222. * This will make creation of children, recursive.
  75223. * @param useVertexColor defines if this LinesMesh supports vertex color
  75224. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75225. */
  75226. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75227. /**
  75228. * If vertex color should be applied to the mesh
  75229. */
  75230. useVertexColor?: boolean | undefined,
  75231. /**
  75232. * If vertex alpha should be applied to the mesh
  75233. */
  75234. useVertexAlpha?: boolean | undefined);
  75235. private _addClipPlaneDefine;
  75236. private _removeClipPlaneDefine;
  75237. isReady(): boolean;
  75238. /**
  75239. * Returns the string "LineMesh"
  75240. */
  75241. getClassName(): string;
  75242. /**
  75243. * @hidden
  75244. */
  75245. /**
  75246. * @hidden
  75247. */
  75248. material: Material;
  75249. /**
  75250. * @hidden
  75251. */
  75252. readonly checkCollisions: boolean;
  75253. /** @hidden */
  75254. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75255. /** @hidden */
  75256. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75257. /**
  75258. * Disposes of the line mesh
  75259. * @param doNotRecurse If children should be disposed
  75260. */
  75261. dispose(doNotRecurse?: boolean): void;
  75262. /**
  75263. * Returns a new LineMesh object cloned from the current one.
  75264. */
  75265. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75266. /**
  75267. * Creates a new InstancedLinesMesh object from the mesh model.
  75268. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75269. * @param name defines the name of the new instance
  75270. * @returns a new InstancedLinesMesh
  75271. */
  75272. createInstance(name: string): InstancedLinesMesh;
  75273. }
  75274. /**
  75275. * Creates an instance based on a source LinesMesh
  75276. */
  75277. export class InstancedLinesMesh extends InstancedMesh {
  75278. /**
  75279. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75280. * This margin is expressed in world space coordinates, so its value may vary.
  75281. * Initilized with the intersectionThreshold value of the source LinesMesh
  75282. */
  75283. intersectionThreshold: number;
  75284. constructor(name: string, source: LinesMesh);
  75285. /**
  75286. * Returns the string "InstancedLinesMesh".
  75287. */
  75288. getClassName(): string;
  75289. }
  75290. }
  75291. declare module BABYLON {
  75292. /** @hidden */
  75293. export var linePixelShader: {
  75294. name: string;
  75295. shader: string;
  75296. };
  75297. }
  75298. declare module BABYLON {
  75299. /** @hidden */
  75300. export var lineVertexShader: {
  75301. name: string;
  75302. shader: string;
  75303. };
  75304. }
  75305. declare module BABYLON {
  75306. interface AbstractMesh {
  75307. /**
  75308. * Disables the mesh edge rendering mode
  75309. * @returns the currentAbstractMesh
  75310. */
  75311. disableEdgesRendering(): AbstractMesh;
  75312. /**
  75313. * Enables the edge rendering mode on the mesh.
  75314. * This mode makes the mesh edges visible
  75315. * @param epsilon defines the maximal distance between two angles to detect a face
  75316. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75317. * @returns the currentAbstractMesh
  75318. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75319. */
  75320. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75321. /**
  75322. * Gets the edgesRenderer associated with the mesh
  75323. */
  75324. edgesRenderer: Nullable<EdgesRenderer>;
  75325. }
  75326. interface LinesMesh {
  75327. /**
  75328. * Enables the edge rendering mode on the mesh.
  75329. * This mode makes the mesh edges visible
  75330. * @param epsilon defines the maximal distance between two angles to detect a face
  75331. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75332. * @returns the currentAbstractMesh
  75333. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75334. */
  75335. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75336. }
  75337. interface InstancedLinesMesh {
  75338. /**
  75339. * Enables the edge rendering mode on the mesh.
  75340. * This mode makes the mesh edges visible
  75341. * @param epsilon defines the maximal distance between two angles to detect a face
  75342. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75343. * @returns the current InstancedLinesMesh
  75344. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75345. */
  75346. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  75347. }
  75348. /**
  75349. * Defines the minimum contract an Edges renderer should follow.
  75350. */
  75351. export interface IEdgesRenderer extends IDisposable {
  75352. /**
  75353. * Gets or sets a boolean indicating if the edgesRenderer is active
  75354. */
  75355. isEnabled: boolean;
  75356. /**
  75357. * Renders the edges of the attached mesh,
  75358. */
  75359. render(): void;
  75360. /**
  75361. * Checks wether or not the edges renderer is ready to render.
  75362. * @return true if ready, otherwise false.
  75363. */
  75364. isReady(): boolean;
  75365. }
  75366. /**
  75367. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  75368. */
  75369. export class EdgesRenderer implements IEdgesRenderer {
  75370. /**
  75371. * Define the size of the edges with an orthographic camera
  75372. */
  75373. edgesWidthScalerForOrthographic: number;
  75374. /**
  75375. * Define the size of the edges with a perspective camera
  75376. */
  75377. edgesWidthScalerForPerspective: number;
  75378. protected _source: AbstractMesh;
  75379. protected _linesPositions: number[];
  75380. protected _linesNormals: number[];
  75381. protected _linesIndices: number[];
  75382. protected _epsilon: number;
  75383. protected _indicesCount: number;
  75384. protected _lineShader: ShaderMaterial;
  75385. protected _ib: WebGLBuffer;
  75386. protected _buffers: {
  75387. [key: string]: Nullable<VertexBuffer>;
  75388. };
  75389. protected _checkVerticesInsteadOfIndices: boolean;
  75390. private _meshRebuildObserver;
  75391. private _meshDisposeObserver;
  75392. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  75393. isEnabled: boolean;
  75394. /**
  75395. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  75396. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  75397. * @param source Mesh used to create edges
  75398. * @param epsilon sum of angles in adjacency to check for edge
  75399. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  75400. * @param generateEdgesLines - should generate Lines or only prepare resources.
  75401. */
  75402. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  75403. protected _prepareRessources(): void;
  75404. /** @hidden */
  75405. _rebuild(): void;
  75406. /**
  75407. * Releases the required resources for the edges renderer
  75408. */
  75409. dispose(): void;
  75410. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  75411. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  75412. /**
  75413. * Checks if the pair of p0 and p1 is en edge
  75414. * @param faceIndex
  75415. * @param edge
  75416. * @param faceNormals
  75417. * @param p0
  75418. * @param p1
  75419. * @private
  75420. */
  75421. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  75422. /**
  75423. * push line into the position, normal and index buffer
  75424. * @protected
  75425. */
  75426. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  75427. /**
  75428. * Generates lines edges from adjacencjes
  75429. * @private
  75430. */
  75431. _generateEdgesLines(): void;
  75432. /**
  75433. * Checks wether or not the edges renderer is ready to render.
  75434. * @return true if ready, otherwise false.
  75435. */
  75436. isReady(): boolean;
  75437. /**
  75438. * Renders the edges of the attached mesh,
  75439. */
  75440. render(): void;
  75441. }
  75442. /**
  75443. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  75444. */
  75445. export class LineEdgesRenderer extends EdgesRenderer {
  75446. /**
  75447. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  75448. * @param source LineMesh used to generate edges
  75449. * @param epsilon not important (specified angle for edge detection)
  75450. * @param checkVerticesInsteadOfIndices not important for LineMesh
  75451. */
  75452. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  75453. /**
  75454. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  75455. */
  75456. _generateEdgesLines(): void;
  75457. }
  75458. }
  75459. declare module BABYLON {
  75460. /**
  75461. * This represents the object necessary to create a rendering group.
  75462. * This is exclusively used and created by the rendering manager.
  75463. * To modify the behavior, you use the available helpers in your scene or meshes.
  75464. * @hidden
  75465. */
  75466. export class RenderingGroup {
  75467. index: number;
  75468. private _scene;
  75469. private _opaqueSubMeshes;
  75470. private _transparentSubMeshes;
  75471. private _alphaTestSubMeshes;
  75472. private _depthOnlySubMeshes;
  75473. private _particleSystems;
  75474. private _spriteManagers;
  75475. private _opaqueSortCompareFn;
  75476. private _alphaTestSortCompareFn;
  75477. private _transparentSortCompareFn;
  75478. private _renderOpaque;
  75479. private _renderAlphaTest;
  75480. private _renderTransparent;
  75481. private _edgesRenderers;
  75482. onBeforeTransparentRendering: () => void;
  75483. /**
  75484. * Set the opaque sort comparison function.
  75485. * If null the sub meshes will be render in the order they were created
  75486. */
  75487. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75488. /**
  75489. * Set the alpha test sort comparison function.
  75490. * If null the sub meshes will be render in the order they were created
  75491. */
  75492. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75493. /**
  75494. * Set the transparent sort comparison function.
  75495. * If null the sub meshes will be render in the order they were created
  75496. */
  75497. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75498. /**
  75499. * Creates a new rendering group.
  75500. * @param index The rendering group index
  75501. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  75502. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  75503. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  75504. */
  75505. 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>);
  75506. /**
  75507. * Render all the sub meshes contained in the group.
  75508. * @param customRenderFunction Used to override the default render behaviour of the group.
  75509. * @returns true if rendered some submeshes.
  75510. */
  75511. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  75512. /**
  75513. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  75514. * @param subMeshes The submeshes to render
  75515. */
  75516. private renderOpaqueSorted;
  75517. /**
  75518. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  75519. * @param subMeshes The submeshes to render
  75520. */
  75521. private renderAlphaTestSorted;
  75522. /**
  75523. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  75524. * @param subMeshes The submeshes to render
  75525. */
  75526. private renderTransparentSorted;
  75527. /**
  75528. * Renders the submeshes in a specified order.
  75529. * @param subMeshes The submeshes to sort before render
  75530. * @param sortCompareFn The comparison function use to sort
  75531. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  75532. * @param transparent Specifies to activate blending if true
  75533. */
  75534. private static renderSorted;
  75535. /**
  75536. * Renders the submeshes in the order they were dispatched (no sort applied).
  75537. * @param subMeshes The submeshes to render
  75538. */
  75539. private static renderUnsorted;
  75540. /**
  75541. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75542. * are rendered back to front if in the same alpha index.
  75543. *
  75544. * @param a The first submesh
  75545. * @param b The second submesh
  75546. * @returns The result of the comparison
  75547. */
  75548. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  75549. /**
  75550. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75551. * are rendered back to front.
  75552. *
  75553. * @param a The first submesh
  75554. * @param b The second submesh
  75555. * @returns The result of the comparison
  75556. */
  75557. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  75558. /**
  75559. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75560. * are rendered front to back (prevent overdraw).
  75561. *
  75562. * @param a The first submesh
  75563. * @param b The second submesh
  75564. * @returns The result of the comparison
  75565. */
  75566. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  75567. /**
  75568. * Resets the different lists of submeshes to prepare a new frame.
  75569. */
  75570. prepare(): void;
  75571. dispose(): void;
  75572. /**
  75573. * Inserts the submesh in its correct queue depending on its material.
  75574. * @param subMesh The submesh to dispatch
  75575. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75576. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75577. */
  75578. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75579. dispatchSprites(spriteManager: ISpriteManager): void;
  75580. dispatchParticles(particleSystem: IParticleSystem): void;
  75581. private _renderParticles;
  75582. private _renderSprites;
  75583. }
  75584. }
  75585. declare module BABYLON {
  75586. /**
  75587. * Interface describing the different options available in the rendering manager
  75588. * regarding Auto Clear between groups.
  75589. */
  75590. export interface IRenderingManagerAutoClearSetup {
  75591. /**
  75592. * Defines whether or not autoclear is enable.
  75593. */
  75594. autoClear: boolean;
  75595. /**
  75596. * Defines whether or not to autoclear the depth buffer.
  75597. */
  75598. depth: boolean;
  75599. /**
  75600. * Defines whether or not to autoclear the stencil buffer.
  75601. */
  75602. stencil: boolean;
  75603. }
  75604. /**
  75605. * This class is used by the onRenderingGroupObservable
  75606. */
  75607. export class RenderingGroupInfo {
  75608. /**
  75609. * The Scene that being rendered
  75610. */
  75611. scene: Scene;
  75612. /**
  75613. * The camera currently used for the rendering pass
  75614. */
  75615. camera: Nullable<Camera>;
  75616. /**
  75617. * The ID of the renderingGroup being processed
  75618. */
  75619. renderingGroupId: number;
  75620. }
  75621. /**
  75622. * This is the manager responsible of all the rendering for meshes sprites and particles.
  75623. * It is enable to manage the different groups as well as the different necessary sort functions.
  75624. * This should not be used directly aside of the few static configurations
  75625. */
  75626. export class RenderingManager {
  75627. /**
  75628. * The max id used for rendering groups (not included)
  75629. */
  75630. static MAX_RENDERINGGROUPS: number;
  75631. /**
  75632. * The min id used for rendering groups (included)
  75633. */
  75634. static MIN_RENDERINGGROUPS: number;
  75635. /**
  75636. * Used to globally prevent autoclearing scenes.
  75637. */
  75638. static AUTOCLEAR: boolean;
  75639. /**
  75640. * @hidden
  75641. */
  75642. _useSceneAutoClearSetup: boolean;
  75643. private _scene;
  75644. private _renderingGroups;
  75645. private _depthStencilBufferAlreadyCleaned;
  75646. private _autoClearDepthStencil;
  75647. private _customOpaqueSortCompareFn;
  75648. private _customAlphaTestSortCompareFn;
  75649. private _customTransparentSortCompareFn;
  75650. private _renderingGroupInfo;
  75651. /**
  75652. * Instantiates a new rendering group for a particular scene
  75653. * @param scene Defines the scene the groups belongs to
  75654. */
  75655. constructor(scene: Scene);
  75656. private _clearDepthStencilBuffer;
  75657. /**
  75658. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  75659. * @hidden
  75660. */
  75661. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  75662. /**
  75663. * Resets the different information of the group to prepare a new frame
  75664. * @hidden
  75665. */
  75666. reset(): void;
  75667. /**
  75668. * Dispose and release the group and its associated resources.
  75669. * @hidden
  75670. */
  75671. dispose(): void;
  75672. /**
  75673. * Clear the info related to rendering groups preventing retention points during dispose.
  75674. */
  75675. freeRenderingGroups(): void;
  75676. private _prepareRenderingGroup;
  75677. /**
  75678. * Add a sprite manager to the rendering manager in order to render it this frame.
  75679. * @param spriteManager Define the sprite manager to render
  75680. */
  75681. dispatchSprites(spriteManager: ISpriteManager): void;
  75682. /**
  75683. * Add a particle system to the rendering manager in order to render it this frame.
  75684. * @param particleSystem Define the particle system to render
  75685. */
  75686. dispatchParticles(particleSystem: IParticleSystem): void;
  75687. /**
  75688. * Add a submesh to the manager in order to render it this frame
  75689. * @param subMesh The submesh to dispatch
  75690. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75691. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75692. */
  75693. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75694. /**
  75695. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75696. * This allowed control for front to back rendering or reversly depending of the special needs.
  75697. *
  75698. * @param renderingGroupId The rendering group id corresponding to its index
  75699. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75700. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75701. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75702. */
  75703. 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;
  75704. /**
  75705. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75706. *
  75707. * @param renderingGroupId The rendering group id corresponding to its index
  75708. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75709. * @param depth Automatically clears depth between groups if true and autoClear is true.
  75710. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  75711. */
  75712. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  75713. /**
  75714. * Gets the current auto clear configuration for one rendering group of the rendering
  75715. * manager.
  75716. * @param index the rendering group index to get the information for
  75717. * @returns The auto clear setup for the requested rendering group
  75718. */
  75719. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  75720. }
  75721. }
  75722. declare module BABYLON {
  75723. /**
  75724. * This Helps creating a texture that will be created from a camera in your scene.
  75725. * It is basically a dynamic texture that could be used to create special effects for instance.
  75726. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  75727. */
  75728. export class RenderTargetTexture extends Texture {
  75729. isCube: boolean;
  75730. /**
  75731. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  75732. */
  75733. static readonly REFRESHRATE_RENDER_ONCE: number;
  75734. /**
  75735. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  75736. */
  75737. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  75738. /**
  75739. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  75740. * the central point of your effect and can save a lot of performances.
  75741. */
  75742. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  75743. /**
  75744. * Use this predicate to dynamically define the list of mesh you want to render.
  75745. * If set, the renderList property will be overwritten.
  75746. */
  75747. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  75748. private _renderList;
  75749. /**
  75750. * Use this list to define the list of mesh you want to render.
  75751. */
  75752. renderList: Nullable<Array<AbstractMesh>>;
  75753. private _hookArray;
  75754. /**
  75755. * Define if particles should be rendered in your texture.
  75756. */
  75757. renderParticles: boolean;
  75758. /**
  75759. * Define if sprites should be rendered in your texture.
  75760. */
  75761. renderSprites: boolean;
  75762. /**
  75763. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  75764. */
  75765. coordinatesMode: number;
  75766. /**
  75767. * Define the camera used to render the texture.
  75768. */
  75769. activeCamera: Nullable<Camera>;
  75770. /**
  75771. * Override the render function of the texture with your own one.
  75772. */
  75773. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  75774. /**
  75775. * Define if camera post processes should be use while rendering the texture.
  75776. */
  75777. useCameraPostProcesses: boolean;
  75778. /**
  75779. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  75780. */
  75781. ignoreCameraViewport: boolean;
  75782. private _postProcessManager;
  75783. private _postProcesses;
  75784. private _resizeObserver;
  75785. /**
  75786. * An event triggered when the texture is unbind.
  75787. */
  75788. onBeforeBindObservable: Observable<RenderTargetTexture>;
  75789. /**
  75790. * An event triggered when the texture is unbind.
  75791. */
  75792. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  75793. private _onAfterUnbindObserver;
  75794. /**
  75795. * Set a after unbind callback in the texture.
  75796. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  75797. */
  75798. onAfterUnbind: () => void;
  75799. /**
  75800. * An event triggered before rendering the texture
  75801. */
  75802. onBeforeRenderObservable: Observable<number>;
  75803. private _onBeforeRenderObserver;
  75804. /**
  75805. * Set a before render callback in the texture.
  75806. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  75807. */
  75808. onBeforeRender: (faceIndex: number) => void;
  75809. /**
  75810. * An event triggered after rendering the texture
  75811. */
  75812. onAfterRenderObservable: Observable<number>;
  75813. private _onAfterRenderObserver;
  75814. /**
  75815. * Set a after render callback in the texture.
  75816. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  75817. */
  75818. onAfterRender: (faceIndex: number) => void;
  75819. /**
  75820. * An event triggered after the texture clear
  75821. */
  75822. onClearObservable: Observable<Engine>;
  75823. private _onClearObserver;
  75824. /**
  75825. * Set a clear callback in the texture.
  75826. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  75827. */
  75828. onClear: (Engine: Engine) => void;
  75829. /**
  75830. * Define the clear color of the Render Target if it should be different from the scene.
  75831. */
  75832. clearColor: Color4;
  75833. protected _size: number | {
  75834. width: number;
  75835. height: number;
  75836. };
  75837. protected _initialSizeParameter: number | {
  75838. width: number;
  75839. height: number;
  75840. } | {
  75841. ratio: number;
  75842. };
  75843. protected _sizeRatio: Nullable<number>;
  75844. /** @hidden */
  75845. _generateMipMaps: boolean;
  75846. protected _renderingManager: RenderingManager;
  75847. /** @hidden */
  75848. _waitingRenderList: string[];
  75849. protected _doNotChangeAspectRatio: boolean;
  75850. protected _currentRefreshId: number;
  75851. protected _refreshRate: number;
  75852. protected _textureMatrix: Matrix;
  75853. protected _samples: number;
  75854. protected _renderTargetOptions: RenderTargetCreationOptions;
  75855. /**
  75856. * Gets render target creation options that were used.
  75857. */
  75858. readonly renderTargetOptions: RenderTargetCreationOptions;
  75859. protected _engine: Engine;
  75860. protected _onRatioRescale(): void;
  75861. /**
  75862. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  75863. * It must define where the camera used to render the texture is set
  75864. */
  75865. boundingBoxPosition: Vector3;
  75866. private _boundingBoxSize;
  75867. /**
  75868. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  75869. * When defined, the cubemap will switch to local mode
  75870. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75871. * @example https://www.babylonjs-playground.com/#RNASML
  75872. */
  75873. boundingBoxSize: Vector3;
  75874. /**
  75875. * In case the RTT has been created with a depth texture, get the associated
  75876. * depth texture.
  75877. * Otherwise, return null.
  75878. */
  75879. depthStencilTexture: Nullable<InternalTexture>;
  75880. /**
  75881. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75882. * or used a shadow, depth texture...
  75883. * @param name The friendly name of the texture
  75884. * @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)
  75885. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75886. * @param generateMipMaps True if mip maps need to be generated after render.
  75887. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75888. * @param type The type of the buffer in the RTT (int, half float, float...)
  75889. * @param isCube True if a cube texture needs to be created
  75890. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75891. * @param generateDepthBuffer True to generate a depth buffer
  75892. * @param generateStencilBuffer True to generate a stencil buffer
  75893. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75894. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75895. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75896. */
  75897. constructor(name: string, size: number | {
  75898. width: number;
  75899. height: number;
  75900. } | {
  75901. ratio: number;
  75902. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  75903. /**
  75904. * Creates a depth stencil texture.
  75905. * This is only available in WebGL 2 or with the depth texture extension available.
  75906. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  75907. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  75908. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  75909. */
  75910. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  75911. private _processSizeParameter;
  75912. /**
  75913. * Define the number of samples to use in case of MSAA.
  75914. * It defaults to one meaning no MSAA has been enabled.
  75915. */
  75916. samples: number;
  75917. /**
  75918. * Resets the refresh counter of the texture and start bak from scratch.
  75919. * Could be useful to regenerate the texture if it is setup to render only once.
  75920. */
  75921. resetRefreshCounter(): void;
  75922. /**
  75923. * Define the refresh rate of the texture or the rendering frequency.
  75924. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  75925. */
  75926. refreshRate: number;
  75927. /**
  75928. * Adds a post process to the render target rendering passes.
  75929. * @param postProcess define the post process to add
  75930. */
  75931. addPostProcess(postProcess: PostProcess): void;
  75932. /**
  75933. * Clear all the post processes attached to the render target
  75934. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75935. */
  75936. clearPostProcesses(dispose?: boolean): void;
  75937. /**
  75938. * Remove one of the post process from the list of attached post processes to the texture
  75939. * @param postProcess define the post process to remove from the list
  75940. */
  75941. removePostProcess(postProcess: PostProcess): void;
  75942. /** @hidden */
  75943. _shouldRender(): boolean;
  75944. /**
  75945. * Gets the actual render size of the texture.
  75946. * @returns the width of the render size
  75947. */
  75948. getRenderSize(): number;
  75949. /**
  75950. * Gets the actual render width of the texture.
  75951. * @returns the width of the render size
  75952. */
  75953. getRenderWidth(): number;
  75954. /**
  75955. * Gets the actual render height of the texture.
  75956. * @returns the height of the render size
  75957. */
  75958. getRenderHeight(): number;
  75959. /**
  75960. * Get if the texture can be rescaled or not.
  75961. */
  75962. readonly canRescale: boolean;
  75963. /**
  75964. * Resize the texture using a ratio.
  75965. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75966. */
  75967. scale(ratio: number): void;
  75968. /**
  75969. * Get the texture reflection matrix used to rotate/transform the reflection.
  75970. * @returns the reflection matrix
  75971. */
  75972. getReflectionTextureMatrix(): Matrix;
  75973. /**
  75974. * Resize the texture to a new desired size.
  75975. * Be carrefull as it will recreate all the data in the new texture.
  75976. * @param size Define the new size. It can be:
  75977. * - a number for squared texture,
  75978. * - an object containing { width: number, height: number }
  75979. * - or an object containing a ratio { ratio: number }
  75980. */
  75981. resize(size: number | {
  75982. width: number;
  75983. height: number;
  75984. } | {
  75985. ratio: number;
  75986. }): void;
  75987. /**
  75988. * Renders all the objects from the render list into the texture.
  75989. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75990. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75991. */
  75992. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75993. private _bestReflectionRenderTargetDimension;
  75994. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75995. private renderToTarget;
  75996. /**
  75997. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75998. * This allowed control for front to back rendering or reversly depending of the special needs.
  75999. *
  76000. * @param renderingGroupId The rendering group id corresponding to its index
  76001. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76002. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76003. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76004. */
  76005. 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;
  76006. /**
  76007. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76008. *
  76009. * @param renderingGroupId The rendering group id corresponding to its index
  76010. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76011. */
  76012. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  76013. /**
  76014. * Clones the texture.
  76015. * @returns the cloned texture
  76016. */
  76017. clone(): RenderTargetTexture;
  76018. /**
  76019. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76020. * @returns The JSON representation of the texture
  76021. */
  76022. serialize(): any;
  76023. /**
  76024. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  76025. */
  76026. disposeFramebufferObjects(): void;
  76027. /**
  76028. * Dispose the texture and release its associated resources.
  76029. */
  76030. dispose(): void;
  76031. /** @hidden */
  76032. _rebuild(): void;
  76033. /**
  76034. * Clear the info related to rendering groups preventing retention point in material dispose.
  76035. */
  76036. freeRenderingGroups(): void;
  76037. }
  76038. }
  76039. declare module BABYLON {
  76040. /**
  76041. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76042. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76043. * You can then easily use it as a reflectionTexture on a flat surface.
  76044. * In case the surface is not a plane, please consider relying on reflection probes.
  76045. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76046. */
  76047. export class MirrorTexture extends RenderTargetTexture {
  76048. private scene;
  76049. /**
  76050. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76051. * 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.
  76052. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76053. */
  76054. mirrorPlane: Plane;
  76055. /**
  76056. * Define the blur ratio used to blur the reflection if needed.
  76057. */
  76058. blurRatio: number;
  76059. /**
  76060. * Define the adaptive blur kernel used to blur the reflection if needed.
  76061. * This will autocompute the closest best match for the `blurKernel`
  76062. */
  76063. adaptiveBlurKernel: number;
  76064. /**
  76065. * Define the blur kernel used to blur the reflection if needed.
  76066. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76067. */
  76068. blurKernel: number;
  76069. /**
  76070. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76071. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76072. */
  76073. blurKernelX: number;
  76074. /**
  76075. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76076. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76077. */
  76078. blurKernelY: number;
  76079. private _autoComputeBlurKernel;
  76080. protected _onRatioRescale(): void;
  76081. private _updateGammaSpace;
  76082. private _imageProcessingConfigChangeObserver;
  76083. private _transformMatrix;
  76084. private _mirrorMatrix;
  76085. private _savedViewMatrix;
  76086. private _blurX;
  76087. private _blurY;
  76088. private _adaptiveBlurKernel;
  76089. private _blurKernelX;
  76090. private _blurKernelY;
  76091. private _blurRatio;
  76092. /**
  76093. * Instantiates a Mirror Texture.
  76094. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76095. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76096. * You can then easily use it as a reflectionTexture on a flat surface.
  76097. * In case the surface is not a plane, please consider relying on reflection probes.
  76098. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76099. * @param name
  76100. * @param size
  76101. * @param scene
  76102. * @param generateMipMaps
  76103. * @param type
  76104. * @param samplingMode
  76105. * @param generateDepthBuffer
  76106. */
  76107. constructor(name: string, size: number | {
  76108. width: number;
  76109. height: number;
  76110. } | {
  76111. ratio: number;
  76112. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76113. private _preparePostProcesses;
  76114. /**
  76115. * Clone the mirror texture.
  76116. * @returns the cloned texture
  76117. */
  76118. clone(): MirrorTexture;
  76119. /**
  76120. * Serialize the texture to a JSON representation you could use in Parse later on
  76121. * @returns the serialized JSON representation
  76122. */
  76123. serialize(): any;
  76124. /**
  76125. * Dispose the texture and release its associated resources.
  76126. */
  76127. dispose(): void;
  76128. }
  76129. }
  76130. declare module BABYLON {
  76131. /**
  76132. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76133. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76134. */
  76135. export class Texture extends BaseTexture {
  76136. /** @hidden */
  76137. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  76138. /** @hidden */
  76139. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  76140. /** @hidden */
  76141. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  76142. /** nearest is mag = nearest and min = nearest and mip = linear */
  76143. static readonly NEAREST_SAMPLINGMODE: number;
  76144. /** nearest is mag = nearest and min = nearest and mip = linear */
  76145. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  76146. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76147. static readonly BILINEAR_SAMPLINGMODE: number;
  76148. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76149. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  76150. /** Trilinear is mag = linear and min = linear and mip = linear */
  76151. static readonly TRILINEAR_SAMPLINGMODE: number;
  76152. /** Trilinear is mag = linear and min = linear and mip = linear */
  76153. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  76154. /** mag = nearest and min = nearest and mip = nearest */
  76155. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  76156. /** mag = nearest and min = linear and mip = nearest */
  76157. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  76158. /** mag = nearest and min = linear and mip = linear */
  76159. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  76160. /** mag = nearest and min = linear and mip = none */
  76161. static readonly NEAREST_LINEAR: number;
  76162. /** mag = nearest and min = nearest and mip = none */
  76163. static readonly NEAREST_NEAREST: number;
  76164. /** mag = linear and min = nearest and mip = nearest */
  76165. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  76166. /** mag = linear and min = nearest and mip = linear */
  76167. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  76168. /** mag = linear and min = linear and mip = none */
  76169. static readonly LINEAR_LINEAR: number;
  76170. /** mag = linear and min = nearest and mip = none */
  76171. static readonly LINEAR_NEAREST: number;
  76172. /** Explicit coordinates mode */
  76173. static readonly EXPLICIT_MODE: number;
  76174. /** Spherical coordinates mode */
  76175. static readonly SPHERICAL_MODE: number;
  76176. /** Planar coordinates mode */
  76177. static readonly PLANAR_MODE: number;
  76178. /** Cubic coordinates mode */
  76179. static readonly CUBIC_MODE: number;
  76180. /** Projection coordinates mode */
  76181. static readonly PROJECTION_MODE: number;
  76182. /** Inverse Cubic coordinates mode */
  76183. static readonly SKYBOX_MODE: number;
  76184. /** Inverse Cubic coordinates mode */
  76185. static readonly INVCUBIC_MODE: number;
  76186. /** Equirectangular coordinates mode */
  76187. static readonly EQUIRECTANGULAR_MODE: number;
  76188. /** Equirectangular Fixed coordinates mode */
  76189. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  76190. /** Equirectangular Fixed Mirrored coordinates mode */
  76191. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76192. /** Texture is not repeating outside of 0..1 UVs */
  76193. static readonly CLAMP_ADDRESSMODE: number;
  76194. /** Texture is repeating outside of 0..1 UVs */
  76195. static readonly WRAP_ADDRESSMODE: number;
  76196. /** Texture is repeating and mirrored */
  76197. static readonly MIRROR_ADDRESSMODE: number;
  76198. /**
  76199. * 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
  76200. */
  76201. static UseSerializedUrlIfAny: boolean;
  76202. /**
  76203. * Define the url of the texture.
  76204. */
  76205. url: Nullable<string>;
  76206. /**
  76207. * Define an offset on the texture to offset the u coordinates of the UVs
  76208. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76209. */
  76210. uOffset: number;
  76211. /**
  76212. * Define an offset on the texture to offset the v coordinates of the UVs
  76213. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76214. */
  76215. vOffset: number;
  76216. /**
  76217. * Define an offset on the texture to scale the u coordinates of the UVs
  76218. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76219. */
  76220. uScale: number;
  76221. /**
  76222. * Define an offset on the texture to scale the v coordinates of the UVs
  76223. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76224. */
  76225. vScale: number;
  76226. /**
  76227. * Define an offset on the texture to rotate around the u coordinates of the UVs
  76228. * @see http://doc.babylonjs.com/how_to/more_materials
  76229. */
  76230. uAng: number;
  76231. /**
  76232. * Define an offset on the texture to rotate around the v coordinates of the UVs
  76233. * @see http://doc.babylonjs.com/how_to/more_materials
  76234. */
  76235. vAng: number;
  76236. /**
  76237. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  76238. * @see http://doc.babylonjs.com/how_to/more_materials
  76239. */
  76240. wAng: number;
  76241. /**
  76242. * Defines the center of rotation (U)
  76243. */
  76244. uRotationCenter: number;
  76245. /**
  76246. * Defines the center of rotation (V)
  76247. */
  76248. vRotationCenter: number;
  76249. /**
  76250. * Defines the center of rotation (W)
  76251. */
  76252. wRotationCenter: number;
  76253. /**
  76254. * Are mip maps generated for this texture or not.
  76255. */
  76256. readonly noMipmap: boolean;
  76257. /**
  76258. * List of inspectable custom properties (used by the Inspector)
  76259. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76260. */
  76261. inspectableCustomProperties: IInspectable[];
  76262. private _noMipmap;
  76263. /** @hidden */
  76264. _invertY: boolean;
  76265. private _rowGenerationMatrix;
  76266. private _cachedTextureMatrix;
  76267. private _projectionModeMatrix;
  76268. private _t0;
  76269. private _t1;
  76270. private _t2;
  76271. private _cachedUOffset;
  76272. private _cachedVOffset;
  76273. private _cachedUScale;
  76274. private _cachedVScale;
  76275. private _cachedUAng;
  76276. private _cachedVAng;
  76277. private _cachedWAng;
  76278. private _cachedProjectionMatrixId;
  76279. private _cachedCoordinatesMode;
  76280. /** @hidden */
  76281. protected _initialSamplingMode: number;
  76282. /** @hidden */
  76283. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  76284. private _deleteBuffer;
  76285. protected _format: Nullable<number>;
  76286. private _delayedOnLoad;
  76287. private _delayedOnError;
  76288. /**
  76289. * Observable triggered once the texture has been loaded.
  76290. */
  76291. onLoadObservable: Observable<Texture>;
  76292. protected _isBlocking: boolean;
  76293. /**
  76294. * Is the texture preventing material to render while loading.
  76295. * If false, a default texture will be used instead of the loading one during the preparation step.
  76296. */
  76297. isBlocking: boolean;
  76298. /**
  76299. * Get the current sampling mode associated with the texture.
  76300. */
  76301. readonly samplingMode: number;
  76302. /**
  76303. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  76304. */
  76305. readonly invertY: boolean;
  76306. /**
  76307. * Instantiates a new texture.
  76308. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76309. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76310. * @param url define the url of the picture to load as a texture
  76311. * @param scene define the scene the texture will belong to
  76312. * @param noMipmap define if the texture will require mip maps or not
  76313. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76314. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76315. * @param onLoad define a callback triggered when the texture has been loaded
  76316. * @param onError define a callback triggered when an error occurred during the loading session
  76317. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76318. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76319. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76320. */
  76321. 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);
  76322. /**
  76323. * Update the url (and optional buffer) of this texture if url was null during construction.
  76324. * @param url the url of the texture
  76325. * @param buffer the buffer of the texture (defaults to null)
  76326. * @param onLoad callback called when the texture is loaded (defaults to null)
  76327. */
  76328. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  76329. /**
  76330. * Finish the loading sequence of a texture flagged as delayed load.
  76331. * @hidden
  76332. */
  76333. delayLoad(): void;
  76334. private _prepareRowForTextureGeneration;
  76335. /**
  76336. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  76337. * @returns the transform matrix of the texture.
  76338. */
  76339. getTextureMatrix(): Matrix;
  76340. /**
  76341. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  76342. * @returns The reflection texture transform
  76343. */
  76344. getReflectionTextureMatrix(): Matrix;
  76345. /**
  76346. * Clones the texture.
  76347. * @returns the cloned texture
  76348. */
  76349. clone(): Texture;
  76350. /**
  76351. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76352. * @returns The JSON representation of the texture
  76353. */
  76354. serialize(): any;
  76355. /**
  76356. * Get the current class name of the texture useful for serialization or dynamic coding.
  76357. * @returns "Texture"
  76358. */
  76359. getClassName(): string;
  76360. /**
  76361. * Dispose the texture and release its associated resources.
  76362. */
  76363. dispose(): void;
  76364. /**
  76365. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  76366. * @param parsedTexture Define the JSON representation of the texture
  76367. * @param scene Define the scene the parsed texture should be instantiated in
  76368. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  76369. * @returns The parsed texture if successful
  76370. */
  76371. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  76372. /**
  76373. * Creates a texture from its base 64 representation.
  76374. * @param data Define the base64 payload without the data: prefix
  76375. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76376. * @param scene Define the scene the texture should belong to
  76377. * @param noMipmap Forces the texture to not create mip map information if true
  76378. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76379. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76380. * @param onLoad define a callback triggered when the texture has been loaded
  76381. * @param onError define a callback triggered when an error occurred during the loading session
  76382. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76383. * @returns the created texture
  76384. */
  76385. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  76386. /**
  76387. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  76388. * @param data Define the base64 payload without the data: prefix
  76389. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76390. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76391. * @param scene Define the scene the texture should belong to
  76392. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76393. * @param noMipmap Forces the texture to not create mip map information if true
  76394. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76395. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76396. * @param onLoad define a callback triggered when the texture has been loaded
  76397. * @param onError define a callback triggered when an error occurred during the loading session
  76398. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76399. * @returns the created texture
  76400. */
  76401. 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;
  76402. }
  76403. }
  76404. declare module BABYLON {
  76405. /**
  76406. * Raw texture can help creating a texture directly from an array of data.
  76407. * This can be super useful if you either get the data from an uncompressed source or
  76408. * if you wish to create your texture pixel by pixel.
  76409. */
  76410. export class RawTexture extends Texture {
  76411. /**
  76412. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76413. */
  76414. format: number;
  76415. private _engine;
  76416. /**
  76417. * Instantiates a new RawTexture.
  76418. * Raw texture can help creating a texture directly from an array of data.
  76419. * This can be super useful if you either get the data from an uncompressed source or
  76420. * if you wish to create your texture pixel by pixel.
  76421. * @param data define the array of data to use to create the texture
  76422. * @param width define the width of the texture
  76423. * @param height define the height of the texture
  76424. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76425. * @param scene define the scene the texture belongs to
  76426. * @param generateMipMaps define whether mip maps should be generated or not
  76427. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76428. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76429. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76430. */
  76431. constructor(data: ArrayBufferView, width: number, height: number,
  76432. /**
  76433. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76434. */
  76435. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76436. /**
  76437. * Updates the texture underlying data.
  76438. * @param data Define the new data of the texture
  76439. */
  76440. update(data: ArrayBufferView): void;
  76441. /**
  76442. * Creates a luminance texture from some data.
  76443. * @param data Define the texture data
  76444. * @param width Define the width of the texture
  76445. * @param height Define the height of the texture
  76446. * @param scene Define the scene the texture belongs to
  76447. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76448. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76449. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76450. * @returns the luminance texture
  76451. */
  76452. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76453. /**
  76454. * Creates a luminance alpha texture from some data.
  76455. * @param data Define the texture data
  76456. * @param width Define the width of the texture
  76457. * @param height Define the height of the texture
  76458. * @param scene Define the scene the texture belongs to
  76459. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76460. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76461. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76462. * @returns the luminance alpha texture
  76463. */
  76464. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76465. /**
  76466. * Creates an alpha texture from some data.
  76467. * @param data Define the texture data
  76468. * @param width Define the width of the texture
  76469. * @param height Define the height of the texture
  76470. * @param scene Define the scene the texture belongs to
  76471. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76472. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76473. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76474. * @returns the alpha texture
  76475. */
  76476. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76477. /**
  76478. * Creates a RGB texture from some data.
  76479. * @param data Define the texture data
  76480. * @param width Define the width of the texture
  76481. * @param height Define the height of the texture
  76482. * @param scene Define the scene the texture belongs to
  76483. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76484. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76485. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76486. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76487. * @returns the RGB alpha texture
  76488. */
  76489. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76490. /**
  76491. * Creates a RGBA texture from some data.
  76492. * @param data Define the texture data
  76493. * @param width Define the width of the texture
  76494. * @param height Define the height of the texture
  76495. * @param scene Define the scene the texture belongs to
  76496. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76497. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76498. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76499. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76500. * @returns the RGBA texture
  76501. */
  76502. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76503. /**
  76504. * Creates a R texture from some data.
  76505. * @param data Define the texture data
  76506. * @param width Define the width of the texture
  76507. * @param height Define the height of the texture
  76508. * @param scene Define the scene the texture belongs to
  76509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76512. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76513. * @returns the R texture
  76514. */
  76515. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76516. }
  76517. }
  76518. declare module BABYLON {
  76519. /**
  76520. * Defines a runtime animation
  76521. */
  76522. export class RuntimeAnimation {
  76523. private _events;
  76524. /**
  76525. * The current frame of the runtime animation
  76526. */
  76527. private _currentFrame;
  76528. /**
  76529. * The animation used by the runtime animation
  76530. */
  76531. private _animation;
  76532. /**
  76533. * The target of the runtime animation
  76534. */
  76535. private _target;
  76536. /**
  76537. * The initiating animatable
  76538. */
  76539. private _host;
  76540. /**
  76541. * The original value of the runtime animation
  76542. */
  76543. private _originalValue;
  76544. /**
  76545. * The original blend value of the runtime animation
  76546. */
  76547. private _originalBlendValue;
  76548. /**
  76549. * The offsets cache of the runtime animation
  76550. */
  76551. private _offsetsCache;
  76552. /**
  76553. * The high limits cache of the runtime animation
  76554. */
  76555. private _highLimitsCache;
  76556. /**
  76557. * Specifies if the runtime animation has been stopped
  76558. */
  76559. private _stopped;
  76560. /**
  76561. * The blending factor of the runtime animation
  76562. */
  76563. private _blendingFactor;
  76564. /**
  76565. * The BabylonJS scene
  76566. */
  76567. private _scene;
  76568. /**
  76569. * The current value of the runtime animation
  76570. */
  76571. private _currentValue;
  76572. /** @hidden */
  76573. _workValue: any;
  76574. /**
  76575. * The active target of the runtime animation
  76576. */
  76577. private _activeTarget;
  76578. /**
  76579. * The target path of the runtime animation
  76580. */
  76581. private _targetPath;
  76582. /**
  76583. * The weight of the runtime animation
  76584. */
  76585. private _weight;
  76586. /**
  76587. * The ratio offset of the runtime animation
  76588. */
  76589. private _ratioOffset;
  76590. /**
  76591. * The previous delay of the runtime animation
  76592. */
  76593. private _previousDelay;
  76594. /**
  76595. * The previous ratio of the runtime animation
  76596. */
  76597. private _previousRatio;
  76598. /**
  76599. * Gets the current frame of the runtime animation
  76600. */
  76601. readonly currentFrame: number;
  76602. /**
  76603. * Gets the weight of the runtime animation
  76604. */
  76605. readonly weight: number;
  76606. /**
  76607. * Gets the current value of the runtime animation
  76608. */
  76609. readonly currentValue: any;
  76610. /**
  76611. * Gets the target path of the runtime animation
  76612. */
  76613. readonly targetPath: string;
  76614. /**
  76615. * Gets the actual target of the runtime animation
  76616. */
  76617. readonly target: any;
  76618. /**
  76619. * Create a new RuntimeAnimation object
  76620. * @param target defines the target of the animation
  76621. * @param animation defines the source animation object
  76622. * @param scene defines the hosting scene
  76623. * @param host defines the initiating Animatable
  76624. */
  76625. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76626. /**
  76627. * Gets the animation from the runtime animation
  76628. */
  76629. readonly animation: Animation;
  76630. /**
  76631. * Resets the runtime animation to the beginning
  76632. * @param restoreOriginal defines whether to restore the target property to the original value
  76633. */
  76634. reset(restoreOriginal?: boolean): void;
  76635. /**
  76636. * Specifies if the runtime animation is stopped
  76637. * @returns Boolean specifying if the runtime animation is stopped
  76638. */
  76639. isStopped(): boolean;
  76640. /**
  76641. * Disposes of the runtime animation
  76642. */
  76643. dispose(): void;
  76644. /**
  76645. * Interpolates the animation from the current frame
  76646. * @param currentFrame The frame to interpolate the animation to
  76647. * @param repeatCount The number of times that the animation should loop
  76648. * @param loopMode The type of looping mode to use
  76649. * @param offsetValue Animation offset value
  76650. * @param highLimitValue The high limit value
  76651. * @returns The interpolated value
  76652. */
  76653. private _interpolate;
  76654. /**
  76655. * Apply the interpolated value to the target
  76656. * @param currentValue defines the value computed by the animation
  76657. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76658. */
  76659. setValue(currentValue: any, weight?: number): void;
  76660. private _setValue;
  76661. /**
  76662. * Gets the loop pmode of the runtime animation
  76663. * @returns Loop Mode
  76664. */
  76665. private _getCorrectLoopMode;
  76666. /**
  76667. * Move the current animation to a given frame
  76668. * @param frame defines the frame to move to
  76669. */
  76670. goToFrame(frame: number): void;
  76671. /**
  76672. * @hidden Internal use only
  76673. */
  76674. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76675. /**
  76676. * Execute the current animation
  76677. * @param delay defines the delay to add to the current frame
  76678. * @param from defines the lower bound of the animation range
  76679. * @param to defines the upper bound of the animation range
  76680. * @param loop defines if the current animation must loop
  76681. * @param speedRatio defines the current speed ratio
  76682. * @param weight defines the weight of the animation (default is -1 so no weight)
  76683. * @param onLoop optional callback called when animation loops
  76684. * @returns a boolean indicating if the animation is running
  76685. */
  76686. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  76687. }
  76688. }
  76689. declare module BABYLON {
  76690. /**
  76691. * Class used to store an actual running animation
  76692. */
  76693. export class Animatable {
  76694. /** defines the target object */
  76695. target: any;
  76696. /** defines the starting frame number (default is 0) */
  76697. fromFrame: number;
  76698. /** defines the ending frame number (default is 100) */
  76699. toFrame: number;
  76700. /** defines if the animation must loop (default is false) */
  76701. loopAnimation: boolean;
  76702. /** defines a callback to call when animation ends if it is not looping */
  76703. onAnimationEnd?: (() => void) | null | undefined;
  76704. /** defines a callback to call when animation loops */
  76705. onAnimationLoop?: (() => void) | null | undefined;
  76706. private _localDelayOffset;
  76707. private _pausedDelay;
  76708. private _runtimeAnimations;
  76709. private _paused;
  76710. private _scene;
  76711. private _speedRatio;
  76712. private _weight;
  76713. private _syncRoot;
  76714. /**
  76715. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76716. * This will only apply for non looping animation (default is true)
  76717. */
  76718. disposeOnEnd: boolean;
  76719. /**
  76720. * Gets a boolean indicating if the animation has started
  76721. */
  76722. animationStarted: boolean;
  76723. /**
  76724. * Observer raised when the animation ends
  76725. */
  76726. onAnimationEndObservable: Observable<Animatable>;
  76727. /**
  76728. * Observer raised when the animation loops
  76729. */
  76730. onAnimationLoopObservable: Observable<Animatable>;
  76731. /**
  76732. * Gets the root Animatable used to synchronize and normalize animations
  76733. */
  76734. readonly syncRoot: Animatable;
  76735. /**
  76736. * Gets the current frame of the first RuntimeAnimation
  76737. * Used to synchronize Animatables
  76738. */
  76739. readonly masterFrame: number;
  76740. /**
  76741. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76742. */
  76743. weight: number;
  76744. /**
  76745. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76746. */
  76747. speedRatio: number;
  76748. /**
  76749. * Creates a new Animatable
  76750. * @param scene defines the hosting scene
  76751. * @param target defines the target object
  76752. * @param fromFrame defines the starting frame number (default is 0)
  76753. * @param toFrame defines the ending frame number (default is 100)
  76754. * @param loopAnimation defines if the animation must loop (default is false)
  76755. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76756. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76757. * @param animations defines a group of animation to add to the new Animatable
  76758. * @param onAnimationLoop defines a callback to call when animation loops
  76759. */
  76760. constructor(scene: Scene,
  76761. /** defines the target object */
  76762. target: any,
  76763. /** defines the starting frame number (default is 0) */
  76764. fromFrame?: number,
  76765. /** defines the ending frame number (default is 100) */
  76766. toFrame?: number,
  76767. /** defines if the animation must loop (default is false) */
  76768. loopAnimation?: boolean, speedRatio?: number,
  76769. /** defines a callback to call when animation ends if it is not looping */
  76770. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76771. /** defines a callback to call when animation loops */
  76772. onAnimationLoop?: (() => void) | null | undefined);
  76773. /**
  76774. * Synchronize and normalize current Animatable with a source Animatable
  76775. * This is useful when using animation weights and when animations are not of the same length
  76776. * @param root defines the root Animatable to synchronize with
  76777. * @returns the current Animatable
  76778. */
  76779. syncWith(root: Animatable): Animatable;
  76780. /**
  76781. * Gets the list of runtime animations
  76782. * @returns an array of RuntimeAnimation
  76783. */
  76784. getAnimations(): RuntimeAnimation[];
  76785. /**
  76786. * Adds more animations to the current animatable
  76787. * @param target defines the target of the animations
  76788. * @param animations defines the new animations to add
  76789. */
  76790. appendAnimations(target: any, animations: Animation[]): void;
  76791. /**
  76792. * Gets the source animation for a specific property
  76793. * @param property defines the propertyu to look for
  76794. * @returns null or the source animation for the given property
  76795. */
  76796. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76797. /**
  76798. * Gets the runtime animation for a specific property
  76799. * @param property defines the propertyu to look for
  76800. * @returns null or the runtime animation for the given property
  76801. */
  76802. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76803. /**
  76804. * Resets the animatable to its original state
  76805. */
  76806. reset(): void;
  76807. /**
  76808. * Allows the animatable to blend with current running animations
  76809. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76810. * @param blendingSpeed defines the blending speed to use
  76811. */
  76812. enableBlending(blendingSpeed: number): void;
  76813. /**
  76814. * Disable animation blending
  76815. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76816. */
  76817. disableBlending(): void;
  76818. /**
  76819. * Jump directly to a given frame
  76820. * @param frame defines the frame to jump to
  76821. */
  76822. goToFrame(frame: number): void;
  76823. /**
  76824. * Pause the animation
  76825. */
  76826. pause(): void;
  76827. /**
  76828. * Restart the animation
  76829. */
  76830. restart(): void;
  76831. private _raiseOnAnimationEnd;
  76832. /**
  76833. * Stop and delete the current animation
  76834. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76835. * @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)
  76836. */
  76837. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76838. /**
  76839. * Wait asynchronously for the animation to end
  76840. * @returns a promise which will be fullfilled when the animation ends
  76841. */
  76842. waitAsync(): Promise<Animatable>;
  76843. /** @hidden */
  76844. _animate(delay: number): boolean;
  76845. }
  76846. interface Scene {
  76847. /** @hidden */
  76848. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76849. /** @hidden */
  76850. _processLateAnimationBindingsForMatrices(holder: {
  76851. totalWeight: number;
  76852. animations: RuntimeAnimation[];
  76853. originalValue: Matrix;
  76854. }): any;
  76855. /** @hidden */
  76856. _processLateAnimationBindingsForQuaternions(holder: {
  76857. totalWeight: number;
  76858. animations: RuntimeAnimation[];
  76859. originalValue: Quaternion;
  76860. }, refQuaternion: Quaternion): Quaternion;
  76861. /** @hidden */
  76862. _processLateAnimationBindings(): void;
  76863. /**
  76864. * Will start the animation sequence of a given target
  76865. * @param target defines the target
  76866. * @param from defines from which frame should animation start
  76867. * @param to defines until which frame should animation run.
  76868. * @param weight defines the weight to apply to the animation (1.0 by default)
  76869. * @param loop defines if the animation loops
  76870. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76871. * @param onAnimationEnd defines the function to be executed when the animation ends
  76872. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76873. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76874. * @param onAnimationLoop defines the callback to call when an animation loops
  76875. * @returns the animatable object created for this animation
  76876. */
  76877. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76878. /**
  76879. * Will start the animation sequence of a given target
  76880. * @param target defines the target
  76881. * @param from defines from which frame should animation start
  76882. * @param to defines until which frame should animation run.
  76883. * @param loop defines if the animation loops
  76884. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76885. * @param onAnimationEnd defines the function to be executed when the animation ends
  76886. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76887. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76888. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76889. * @param onAnimationLoop defines the callback to call when an animation loops
  76890. * @returns the animatable object created for this animation
  76891. */
  76892. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76893. /**
  76894. * Will start the animation sequence of a given target and its hierarchy
  76895. * @param target defines the target
  76896. * @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.
  76897. * @param from defines from which frame should animation start
  76898. * @param to defines until which frame should animation run.
  76899. * @param loop defines if the animation loops
  76900. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76901. * @param onAnimationEnd defines the function to be executed when the animation ends
  76902. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76903. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76904. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76905. * @param onAnimationLoop defines the callback to call when an animation loops
  76906. * @returns the list of created animatables
  76907. */
  76908. 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[];
  76909. /**
  76910. * Begin a new animation on a given node
  76911. * @param target defines the target where the animation will take place
  76912. * @param animations defines the list of animations to start
  76913. * @param from defines the initial value
  76914. * @param to defines the final value
  76915. * @param loop defines if you want animation to loop (off by default)
  76916. * @param speedRatio defines the speed ratio to apply to all animations
  76917. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76918. * @param onAnimationLoop defines the callback to call when an animation loops
  76919. * @returns the list of created animatables
  76920. */
  76921. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76922. /**
  76923. * Begin a new animation on a given node and its hierarchy
  76924. * @param target defines the root node where the animation will take place
  76925. * @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.
  76926. * @param animations defines the list of animations to start
  76927. * @param from defines the initial value
  76928. * @param to defines the final value
  76929. * @param loop defines if you want animation to loop (off by default)
  76930. * @param speedRatio defines the speed ratio to apply to all animations
  76931. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76932. * @param onAnimationLoop defines the callback to call when an animation loops
  76933. * @returns the list of animatables created for all nodes
  76934. */
  76935. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76936. /**
  76937. * Gets the animatable associated with a specific target
  76938. * @param target defines the target of the animatable
  76939. * @returns the required animatable if found
  76940. */
  76941. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76942. /**
  76943. * Gets all animatables associated with a given target
  76944. * @param target defines the target to look animatables for
  76945. * @returns an array of Animatables
  76946. */
  76947. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76948. /**
  76949. * Will stop the animation of the given target
  76950. * @param target - the target
  76951. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76952. * @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)
  76953. */
  76954. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76955. /**
  76956. * Stops and removes all animations that have been applied to the scene
  76957. */
  76958. stopAllAnimations(): void;
  76959. }
  76960. interface Bone {
  76961. /**
  76962. * Copy an animation range from another bone
  76963. * @param source defines the source bone
  76964. * @param rangeName defines the range name to copy
  76965. * @param frameOffset defines the frame offset
  76966. * @param rescaleAsRequired defines if rescaling must be applied if required
  76967. * @param skelDimensionsRatio defines the scaling ratio
  76968. * @returns true if operation was successful
  76969. */
  76970. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76971. }
  76972. }
  76973. declare module BABYLON {
  76974. /**
  76975. * Class used to handle skinning animations
  76976. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76977. */
  76978. export class Skeleton implements IAnimatable {
  76979. /** defines the skeleton name */
  76980. name: string;
  76981. /** defines the skeleton Id */
  76982. id: string;
  76983. /**
  76984. * Defines the list of child bones
  76985. */
  76986. bones: Bone[];
  76987. /**
  76988. * Defines an estimate of the dimension of the skeleton at rest
  76989. */
  76990. dimensionsAtRest: Vector3;
  76991. /**
  76992. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76993. */
  76994. needInitialSkinMatrix: boolean;
  76995. /**
  76996. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76997. */
  76998. overrideMesh: Nullable<AbstractMesh>;
  76999. /**
  77000. * Gets the list of animations attached to this skeleton
  77001. */
  77002. animations: Array<Animation>;
  77003. private _scene;
  77004. private _isDirty;
  77005. private _transformMatrices;
  77006. private _transformMatrixTexture;
  77007. private _meshesWithPoseMatrix;
  77008. private _animatables;
  77009. private _identity;
  77010. private _synchronizedWithMesh;
  77011. private _ranges;
  77012. private _lastAbsoluteTransformsUpdateId;
  77013. private _canUseTextureForBones;
  77014. private _uniqueId;
  77015. /** @hidden */
  77016. _numBonesWithLinkedTransformNode: number;
  77017. /**
  77018. * Specifies if the skeleton should be serialized
  77019. */
  77020. doNotSerialize: boolean;
  77021. private _useTextureToStoreBoneMatrices;
  77022. /**
  77023. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77024. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  77025. */
  77026. useTextureToStoreBoneMatrices: boolean;
  77027. private _animationPropertiesOverride;
  77028. /**
  77029. * Gets or sets the animation properties override
  77030. */
  77031. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77032. /**
  77033. * List of inspectable custom properties (used by the Inspector)
  77034. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77035. */
  77036. inspectableCustomProperties: IInspectable[];
  77037. /**
  77038. * An observable triggered before computing the skeleton's matrices
  77039. */
  77040. onBeforeComputeObservable: Observable<Skeleton>;
  77041. /**
  77042. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77043. */
  77044. readonly isUsingTextureForMatrices: boolean;
  77045. /**
  77046. * Gets the unique ID of this skeleton
  77047. */
  77048. readonly uniqueId: number;
  77049. /**
  77050. * Creates a new skeleton
  77051. * @param name defines the skeleton name
  77052. * @param id defines the skeleton Id
  77053. * @param scene defines the hosting scene
  77054. */
  77055. constructor(
  77056. /** defines the skeleton name */
  77057. name: string,
  77058. /** defines the skeleton Id */
  77059. id: string, scene: Scene);
  77060. /**
  77061. * Gets the current object class name.
  77062. * @return the class name
  77063. */
  77064. getClassName(): string;
  77065. /**
  77066. * Returns an array containing the root bones
  77067. * @returns an array containing the root bones
  77068. */
  77069. getChildren(): Array<Bone>;
  77070. /**
  77071. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77072. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77073. * @returns a Float32Array containing matrices data
  77074. */
  77075. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77076. /**
  77077. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77078. * @returns a raw texture containing the data
  77079. */
  77080. getTransformMatrixTexture(): Nullable<RawTexture>;
  77081. /**
  77082. * Gets the current hosting scene
  77083. * @returns a scene object
  77084. */
  77085. getScene(): Scene;
  77086. /**
  77087. * Gets a string representing the current skeleton data
  77088. * @param fullDetails defines a boolean indicating if we want a verbose version
  77089. * @returns a string representing the current skeleton data
  77090. */
  77091. toString(fullDetails?: boolean): string;
  77092. /**
  77093. * Get bone's index searching by name
  77094. * @param name defines bone's name to search for
  77095. * @return the indice of the bone. Returns -1 if not found
  77096. */
  77097. getBoneIndexByName(name: string): number;
  77098. /**
  77099. * Creater a new animation range
  77100. * @param name defines the name of the range
  77101. * @param from defines the start key
  77102. * @param to defines the end key
  77103. */
  77104. createAnimationRange(name: string, from: number, to: number): void;
  77105. /**
  77106. * Delete a specific animation range
  77107. * @param name defines the name of the range
  77108. * @param deleteFrames defines if frames must be removed as well
  77109. */
  77110. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77111. /**
  77112. * Gets a specific animation range
  77113. * @param name defines the name of the range to look for
  77114. * @returns the requested animation range or null if not found
  77115. */
  77116. getAnimationRange(name: string): Nullable<AnimationRange>;
  77117. /**
  77118. * Gets the list of all animation ranges defined on this skeleton
  77119. * @returns an array
  77120. */
  77121. getAnimationRanges(): Nullable<AnimationRange>[];
  77122. /**
  77123. * Copy animation range from a source skeleton.
  77124. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77125. * @param source defines the source skeleton
  77126. * @param name defines the name of the range to copy
  77127. * @param rescaleAsRequired defines if rescaling must be applied if required
  77128. * @returns true if operation was successful
  77129. */
  77130. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77131. /**
  77132. * Forces the skeleton to go to rest pose
  77133. */
  77134. returnToRest(): void;
  77135. private _getHighestAnimationFrame;
  77136. /**
  77137. * Begin a specific animation range
  77138. * @param name defines the name of the range to start
  77139. * @param loop defines if looping must be turned on (false by default)
  77140. * @param speedRatio defines the speed ratio to apply (1 by default)
  77141. * @param onAnimationEnd defines a callback which will be called when animation will end
  77142. * @returns a new animatable
  77143. */
  77144. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77145. /** @hidden */
  77146. _markAsDirty(): void;
  77147. /** @hidden */
  77148. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77149. /** @hidden */
  77150. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77151. private _computeTransformMatrices;
  77152. /**
  77153. * Build all resources required to render a skeleton
  77154. */
  77155. prepare(): void;
  77156. /**
  77157. * Gets the list of animatables currently running for this skeleton
  77158. * @returns an array of animatables
  77159. */
  77160. getAnimatables(): IAnimatable[];
  77161. /**
  77162. * Clone the current skeleton
  77163. * @param name defines the name of the new skeleton
  77164. * @param id defines the id of the enw skeleton
  77165. * @returns the new skeleton
  77166. */
  77167. clone(name: string, id: string): Skeleton;
  77168. /**
  77169. * Enable animation blending for this skeleton
  77170. * @param blendingSpeed defines the blending speed to apply
  77171. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77172. */
  77173. enableBlending(blendingSpeed?: number): void;
  77174. /**
  77175. * Releases all resources associated with the current skeleton
  77176. */
  77177. dispose(): void;
  77178. /**
  77179. * Serialize the skeleton in a JSON object
  77180. * @returns a JSON object
  77181. */
  77182. serialize(): any;
  77183. /**
  77184. * Creates a new skeleton from serialized data
  77185. * @param parsedSkeleton defines the serialized data
  77186. * @param scene defines the hosting scene
  77187. * @returns a new skeleton
  77188. */
  77189. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77190. /**
  77191. * Compute all node absolute transforms
  77192. * @param forceUpdate defines if computation must be done even if cache is up to date
  77193. */
  77194. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77195. /**
  77196. * Gets the root pose matrix
  77197. * @returns a matrix
  77198. */
  77199. getPoseMatrix(): Nullable<Matrix>;
  77200. /**
  77201. * Sorts bones per internal index
  77202. */
  77203. sortBones(): void;
  77204. private _sortBones;
  77205. }
  77206. }
  77207. declare module BABYLON {
  77208. /**
  77209. * Defines a target to use with MorphTargetManager
  77210. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77211. */
  77212. export class MorphTarget implements IAnimatable {
  77213. /** defines the name of the target */
  77214. name: string;
  77215. /**
  77216. * Gets or sets the list of animations
  77217. */
  77218. animations: Animation[];
  77219. private _scene;
  77220. private _positions;
  77221. private _normals;
  77222. private _tangents;
  77223. private _influence;
  77224. /**
  77225. * Observable raised when the influence changes
  77226. */
  77227. onInfluenceChanged: Observable<boolean>;
  77228. /** @hidden */
  77229. _onDataLayoutChanged: Observable<void>;
  77230. /**
  77231. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  77232. */
  77233. influence: number;
  77234. /**
  77235. * Gets or sets the id of the morph Target
  77236. */
  77237. id: string;
  77238. private _animationPropertiesOverride;
  77239. /**
  77240. * Gets or sets the animation properties override
  77241. */
  77242. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77243. /**
  77244. * Creates a new MorphTarget
  77245. * @param name defines the name of the target
  77246. * @param influence defines the influence to use
  77247. * @param scene defines the scene the morphtarget belongs to
  77248. */
  77249. constructor(
  77250. /** defines the name of the target */
  77251. name: string, influence?: number, scene?: Nullable<Scene>);
  77252. /**
  77253. * Gets a boolean defining if the target contains position data
  77254. */
  77255. readonly hasPositions: boolean;
  77256. /**
  77257. * Gets a boolean defining if the target contains normal data
  77258. */
  77259. readonly hasNormals: boolean;
  77260. /**
  77261. * Gets a boolean defining if the target contains tangent data
  77262. */
  77263. readonly hasTangents: boolean;
  77264. /**
  77265. * Affects position data to this target
  77266. * @param data defines the position data to use
  77267. */
  77268. setPositions(data: Nullable<FloatArray>): void;
  77269. /**
  77270. * Gets the position data stored in this target
  77271. * @returns a FloatArray containing the position data (or null if not present)
  77272. */
  77273. getPositions(): Nullable<FloatArray>;
  77274. /**
  77275. * Affects normal data to this target
  77276. * @param data defines the normal data to use
  77277. */
  77278. setNormals(data: Nullable<FloatArray>): void;
  77279. /**
  77280. * Gets the normal data stored in this target
  77281. * @returns a FloatArray containing the normal data (or null if not present)
  77282. */
  77283. getNormals(): Nullable<FloatArray>;
  77284. /**
  77285. * Affects tangent data to this target
  77286. * @param data defines the tangent data to use
  77287. */
  77288. setTangents(data: Nullable<FloatArray>): void;
  77289. /**
  77290. * Gets the tangent data stored in this target
  77291. * @returns a FloatArray containing the tangent data (or null if not present)
  77292. */
  77293. getTangents(): Nullable<FloatArray>;
  77294. /**
  77295. * Serializes the current target into a Serialization object
  77296. * @returns the serialized object
  77297. */
  77298. serialize(): any;
  77299. /**
  77300. * Returns the string "MorphTarget"
  77301. * @returns "MorphTarget"
  77302. */
  77303. getClassName(): string;
  77304. /**
  77305. * Creates a new target from serialized data
  77306. * @param serializationObject defines the serialized data to use
  77307. * @returns a new MorphTarget
  77308. */
  77309. static Parse(serializationObject: any): MorphTarget;
  77310. /**
  77311. * Creates a MorphTarget from mesh data
  77312. * @param mesh defines the source mesh
  77313. * @param name defines the name to use for the new target
  77314. * @param influence defines the influence to attach to the target
  77315. * @returns a new MorphTarget
  77316. */
  77317. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  77318. }
  77319. }
  77320. declare module BABYLON {
  77321. /**
  77322. * This class is used to deform meshes using morphing between different targets
  77323. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77324. */
  77325. export class MorphTargetManager {
  77326. private _targets;
  77327. private _targetInfluenceChangedObservers;
  77328. private _targetDataLayoutChangedObservers;
  77329. private _activeTargets;
  77330. private _scene;
  77331. private _influences;
  77332. private _supportsNormals;
  77333. private _supportsTangents;
  77334. private _vertexCount;
  77335. private _uniqueId;
  77336. private _tempInfluences;
  77337. /**
  77338. * Creates a new MorphTargetManager
  77339. * @param scene defines the current scene
  77340. */
  77341. constructor(scene?: Nullable<Scene>);
  77342. /**
  77343. * Gets the unique ID of this manager
  77344. */
  77345. readonly uniqueId: number;
  77346. /**
  77347. * Gets the number of vertices handled by this manager
  77348. */
  77349. readonly vertexCount: number;
  77350. /**
  77351. * Gets a boolean indicating if this manager supports morphing of normals
  77352. */
  77353. readonly supportsNormals: boolean;
  77354. /**
  77355. * Gets a boolean indicating if this manager supports morphing of tangents
  77356. */
  77357. readonly supportsTangents: boolean;
  77358. /**
  77359. * Gets the number of targets stored in this manager
  77360. */
  77361. readonly numTargets: number;
  77362. /**
  77363. * Gets the number of influencers (ie. the number of targets with influences > 0)
  77364. */
  77365. readonly numInfluencers: number;
  77366. /**
  77367. * Gets the list of influences (one per target)
  77368. */
  77369. readonly influences: Float32Array;
  77370. /**
  77371. * Gets the active target at specified index. An active target is a target with an influence > 0
  77372. * @param index defines the index to check
  77373. * @returns the requested target
  77374. */
  77375. getActiveTarget(index: number): MorphTarget;
  77376. /**
  77377. * Gets the target at specified index
  77378. * @param index defines the index to check
  77379. * @returns the requested target
  77380. */
  77381. getTarget(index: number): MorphTarget;
  77382. /**
  77383. * Add a new target to this manager
  77384. * @param target defines the target to add
  77385. */
  77386. addTarget(target: MorphTarget): void;
  77387. /**
  77388. * Removes a target from the manager
  77389. * @param target defines the target to remove
  77390. */
  77391. removeTarget(target: MorphTarget): void;
  77392. /**
  77393. * Serializes the current manager into a Serialization object
  77394. * @returns the serialized object
  77395. */
  77396. serialize(): any;
  77397. private _syncActiveTargets;
  77398. /**
  77399. * Syncrhonize the targets with all the meshes using this morph target manager
  77400. */
  77401. synchronize(): void;
  77402. /**
  77403. * Creates a new MorphTargetManager from serialized data
  77404. * @param serializationObject defines the serialized data
  77405. * @param scene defines the hosting scene
  77406. * @returns the new MorphTargetManager
  77407. */
  77408. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  77409. }
  77410. }
  77411. declare module BABYLON {
  77412. /**
  77413. * Mesh representing the gorund
  77414. */
  77415. export class GroundMesh extends Mesh {
  77416. /** If octree should be generated */
  77417. generateOctree: boolean;
  77418. private _heightQuads;
  77419. /** @hidden */
  77420. _subdivisionsX: number;
  77421. /** @hidden */
  77422. _subdivisionsY: number;
  77423. /** @hidden */
  77424. _width: number;
  77425. /** @hidden */
  77426. _height: number;
  77427. /** @hidden */
  77428. _minX: number;
  77429. /** @hidden */
  77430. _maxX: number;
  77431. /** @hidden */
  77432. _minZ: number;
  77433. /** @hidden */
  77434. _maxZ: number;
  77435. constructor(name: string, scene: Scene);
  77436. /**
  77437. * "GroundMesh"
  77438. * @returns "GroundMesh"
  77439. */
  77440. getClassName(): string;
  77441. /**
  77442. * The minimum of x and y subdivisions
  77443. */
  77444. readonly subdivisions: number;
  77445. /**
  77446. * X subdivisions
  77447. */
  77448. readonly subdivisionsX: number;
  77449. /**
  77450. * Y subdivisions
  77451. */
  77452. readonly subdivisionsY: number;
  77453. /**
  77454. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  77455. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  77456. * @param chunksCount the number of subdivisions for x and y
  77457. * @param octreeBlocksSize (Default: 32)
  77458. */
  77459. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  77460. /**
  77461. * Returns a height (y) value in the Worl system :
  77462. * the ground altitude at the coordinates (x, z) expressed in the World system.
  77463. * @param x x coordinate
  77464. * @param z z coordinate
  77465. * @returns the ground y position if (x, z) are outside the ground surface.
  77466. */
  77467. getHeightAtCoordinates(x: number, z: number): number;
  77468. /**
  77469. * Returns a normalized vector (Vector3) orthogonal to the ground
  77470. * at the ground coordinates (x, z) expressed in the World system.
  77471. * @param x x coordinate
  77472. * @param z z coordinate
  77473. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  77474. */
  77475. getNormalAtCoordinates(x: number, z: number): Vector3;
  77476. /**
  77477. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  77478. * at the ground coordinates (x, z) expressed in the World system.
  77479. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  77480. * @param x x coordinate
  77481. * @param z z coordinate
  77482. * @param ref vector to store the result
  77483. * @returns the GroundMesh.
  77484. */
  77485. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  77486. /**
  77487. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  77488. * if the ground has been updated.
  77489. * This can be used in the render loop.
  77490. * @returns the GroundMesh.
  77491. */
  77492. updateCoordinateHeights(): GroundMesh;
  77493. private _getFacetAt;
  77494. private _initHeightQuads;
  77495. private _computeHeightQuads;
  77496. /**
  77497. * Serializes this ground mesh
  77498. * @param serializationObject object to write serialization to
  77499. */
  77500. serialize(serializationObject: any): void;
  77501. /**
  77502. * Parses a serialized ground mesh
  77503. * @param parsedMesh the serialized mesh
  77504. * @param scene the scene to create the ground mesh in
  77505. * @returns the created ground mesh
  77506. */
  77507. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  77508. }
  77509. }
  77510. declare module BABYLON {
  77511. /**
  77512. * Interface for Physics-Joint data
  77513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77514. */
  77515. export interface PhysicsJointData {
  77516. /**
  77517. * The main pivot of the joint
  77518. */
  77519. mainPivot?: Vector3;
  77520. /**
  77521. * The connected pivot of the joint
  77522. */
  77523. connectedPivot?: Vector3;
  77524. /**
  77525. * The main axis of the joint
  77526. */
  77527. mainAxis?: Vector3;
  77528. /**
  77529. * The connected axis of the joint
  77530. */
  77531. connectedAxis?: Vector3;
  77532. /**
  77533. * The collision of the joint
  77534. */
  77535. collision?: boolean;
  77536. /**
  77537. * Native Oimo/Cannon/Energy data
  77538. */
  77539. nativeParams?: any;
  77540. }
  77541. /**
  77542. * This is a holder class for the physics joint created by the physics plugin
  77543. * It holds a set of functions to control the underlying joint
  77544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77545. */
  77546. export class PhysicsJoint {
  77547. /**
  77548. * The type of the physics joint
  77549. */
  77550. type: number;
  77551. /**
  77552. * The data for the physics joint
  77553. */
  77554. jointData: PhysicsJointData;
  77555. private _physicsJoint;
  77556. protected _physicsPlugin: IPhysicsEnginePlugin;
  77557. /**
  77558. * Initializes the physics joint
  77559. * @param type The type of the physics joint
  77560. * @param jointData The data for the physics joint
  77561. */
  77562. constructor(
  77563. /**
  77564. * The type of the physics joint
  77565. */
  77566. type: number,
  77567. /**
  77568. * The data for the physics joint
  77569. */
  77570. jointData: PhysicsJointData);
  77571. /**
  77572. * Gets the physics joint
  77573. */
  77574. /**
  77575. * Sets the physics joint
  77576. */
  77577. physicsJoint: any;
  77578. /**
  77579. * Sets the physics plugin
  77580. */
  77581. physicsPlugin: IPhysicsEnginePlugin;
  77582. /**
  77583. * Execute a function that is physics-plugin specific.
  77584. * @param {Function} func the function that will be executed.
  77585. * It accepts two parameters: the physics world and the physics joint
  77586. */
  77587. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  77588. /**
  77589. * Distance-Joint type
  77590. */
  77591. static DistanceJoint: number;
  77592. /**
  77593. * Hinge-Joint type
  77594. */
  77595. static HingeJoint: number;
  77596. /**
  77597. * Ball-and-Socket joint type
  77598. */
  77599. static BallAndSocketJoint: number;
  77600. /**
  77601. * Wheel-Joint type
  77602. */
  77603. static WheelJoint: number;
  77604. /**
  77605. * Slider-Joint type
  77606. */
  77607. static SliderJoint: number;
  77608. /**
  77609. * Prismatic-Joint type
  77610. */
  77611. static PrismaticJoint: number;
  77612. /**
  77613. * Universal-Joint type
  77614. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  77615. */
  77616. static UniversalJoint: number;
  77617. /**
  77618. * Hinge-Joint 2 type
  77619. */
  77620. static Hinge2Joint: number;
  77621. /**
  77622. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  77623. */
  77624. static PointToPointJoint: number;
  77625. /**
  77626. * Spring-Joint type
  77627. */
  77628. static SpringJoint: number;
  77629. /**
  77630. * Lock-Joint type
  77631. */
  77632. static LockJoint: number;
  77633. }
  77634. /**
  77635. * A class representing a physics distance joint
  77636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77637. */
  77638. export class DistanceJoint extends PhysicsJoint {
  77639. /**
  77640. *
  77641. * @param jointData The data for the Distance-Joint
  77642. */
  77643. constructor(jointData: DistanceJointData);
  77644. /**
  77645. * Update the predefined distance.
  77646. * @param maxDistance The maximum preferred distance
  77647. * @param minDistance The minimum preferred distance
  77648. */
  77649. updateDistance(maxDistance: number, minDistance?: number): void;
  77650. }
  77651. /**
  77652. * Represents a Motor-Enabled Joint
  77653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77654. */
  77655. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  77656. /**
  77657. * Initializes the Motor-Enabled Joint
  77658. * @param type The type of the joint
  77659. * @param jointData The physica joint data for the joint
  77660. */
  77661. constructor(type: number, jointData: PhysicsJointData);
  77662. /**
  77663. * Set the motor values.
  77664. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77665. * @param force the force to apply
  77666. * @param maxForce max force for this motor.
  77667. */
  77668. setMotor(force?: number, maxForce?: number): void;
  77669. /**
  77670. * Set the motor's limits.
  77671. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77672. * @param upperLimit The upper limit of the motor
  77673. * @param lowerLimit The lower limit of the motor
  77674. */
  77675. setLimit(upperLimit: number, lowerLimit?: number): void;
  77676. }
  77677. /**
  77678. * This class represents a single physics Hinge-Joint
  77679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77680. */
  77681. export class HingeJoint extends MotorEnabledJoint {
  77682. /**
  77683. * Initializes the Hinge-Joint
  77684. * @param jointData The joint data for the Hinge-Joint
  77685. */
  77686. constructor(jointData: PhysicsJointData);
  77687. /**
  77688. * Set the motor values.
  77689. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77690. * @param {number} force the force to apply
  77691. * @param {number} maxForce max force for this motor.
  77692. */
  77693. setMotor(force?: number, maxForce?: number): void;
  77694. /**
  77695. * Set the motor's limits.
  77696. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77697. * @param upperLimit The upper limit of the motor
  77698. * @param lowerLimit The lower limit of the motor
  77699. */
  77700. setLimit(upperLimit: number, lowerLimit?: number): void;
  77701. }
  77702. /**
  77703. * This class represents a dual hinge physics joint (same as wheel joint)
  77704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77705. */
  77706. export class Hinge2Joint extends MotorEnabledJoint {
  77707. /**
  77708. * Initializes the Hinge2-Joint
  77709. * @param jointData The joint data for the Hinge2-Joint
  77710. */
  77711. constructor(jointData: PhysicsJointData);
  77712. /**
  77713. * Set the motor values.
  77714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77715. * @param {number} targetSpeed the speed the motor is to reach
  77716. * @param {number} maxForce max force for this motor.
  77717. * @param {motorIndex} the motor's index, 0 or 1.
  77718. */
  77719. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  77720. /**
  77721. * Set the motor limits.
  77722. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77723. * @param {number} upperLimit the upper limit
  77724. * @param {number} lowerLimit lower limit
  77725. * @param {motorIndex} the motor's index, 0 or 1.
  77726. */
  77727. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77728. }
  77729. /**
  77730. * Interface for a motor enabled joint
  77731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77732. */
  77733. export interface IMotorEnabledJoint {
  77734. /**
  77735. * Physics joint
  77736. */
  77737. physicsJoint: any;
  77738. /**
  77739. * Sets the motor of the motor-enabled joint
  77740. * @param force The force of the motor
  77741. * @param maxForce The maximum force of the motor
  77742. * @param motorIndex The index of the motor
  77743. */
  77744. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  77745. /**
  77746. * Sets the limit of the motor
  77747. * @param upperLimit The upper limit of the motor
  77748. * @param lowerLimit The lower limit of the motor
  77749. * @param motorIndex The index of the motor
  77750. */
  77751. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77752. }
  77753. /**
  77754. * Joint data for a Distance-Joint
  77755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77756. */
  77757. export interface DistanceJointData extends PhysicsJointData {
  77758. /**
  77759. * Max distance the 2 joint objects can be apart
  77760. */
  77761. maxDistance: number;
  77762. }
  77763. /**
  77764. * Joint data from a spring joint
  77765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77766. */
  77767. export interface SpringJointData extends PhysicsJointData {
  77768. /**
  77769. * Length of the spring
  77770. */
  77771. length: number;
  77772. /**
  77773. * Stiffness of the spring
  77774. */
  77775. stiffness: number;
  77776. /**
  77777. * Damping of the spring
  77778. */
  77779. damping: number;
  77780. /** this callback will be called when applying the force to the impostors. */
  77781. forceApplicationCallback: () => void;
  77782. }
  77783. }
  77784. declare module BABYLON {
  77785. /**
  77786. * Holds the data for the raycast result
  77787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77788. */
  77789. export class PhysicsRaycastResult {
  77790. private _hasHit;
  77791. private _hitDistance;
  77792. private _hitNormalWorld;
  77793. private _hitPointWorld;
  77794. private _rayFromWorld;
  77795. private _rayToWorld;
  77796. /**
  77797. * Gets if there was a hit
  77798. */
  77799. readonly hasHit: boolean;
  77800. /**
  77801. * Gets the distance from the hit
  77802. */
  77803. readonly hitDistance: number;
  77804. /**
  77805. * Gets the hit normal/direction in the world
  77806. */
  77807. readonly hitNormalWorld: Vector3;
  77808. /**
  77809. * Gets the hit point in the world
  77810. */
  77811. readonly hitPointWorld: Vector3;
  77812. /**
  77813. * Gets the ray "start point" of the ray in the world
  77814. */
  77815. readonly rayFromWorld: Vector3;
  77816. /**
  77817. * Gets the ray "end point" of the ray in the world
  77818. */
  77819. readonly rayToWorld: Vector3;
  77820. /**
  77821. * Sets the hit data (normal & point in world space)
  77822. * @param hitNormalWorld defines the normal in world space
  77823. * @param hitPointWorld defines the point in world space
  77824. */
  77825. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  77826. /**
  77827. * Sets the distance from the start point to the hit point
  77828. * @param distance
  77829. */
  77830. setHitDistance(distance: number): void;
  77831. /**
  77832. * Calculates the distance manually
  77833. */
  77834. calculateHitDistance(): void;
  77835. /**
  77836. * Resets all the values to default
  77837. * @param from The from point on world space
  77838. * @param to The to point on world space
  77839. */
  77840. reset(from?: Vector3, to?: Vector3): void;
  77841. }
  77842. /**
  77843. * Interface for the size containing width and height
  77844. */
  77845. interface IXYZ {
  77846. /**
  77847. * X
  77848. */
  77849. x: number;
  77850. /**
  77851. * Y
  77852. */
  77853. y: number;
  77854. /**
  77855. * Z
  77856. */
  77857. z: number;
  77858. }
  77859. }
  77860. declare module BABYLON {
  77861. /**
  77862. * Interface used to describe a physics joint
  77863. */
  77864. export interface PhysicsImpostorJoint {
  77865. /** Defines the main impostor to which the joint is linked */
  77866. mainImpostor: PhysicsImpostor;
  77867. /** Defines the impostor that is connected to the main impostor using this joint */
  77868. connectedImpostor: PhysicsImpostor;
  77869. /** Defines the joint itself */
  77870. joint: PhysicsJoint;
  77871. }
  77872. /** @hidden */
  77873. export interface IPhysicsEnginePlugin {
  77874. world: any;
  77875. name: string;
  77876. setGravity(gravity: Vector3): void;
  77877. setTimeStep(timeStep: number): void;
  77878. getTimeStep(): number;
  77879. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  77880. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77881. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77882. generatePhysicsBody(impostor: PhysicsImpostor): void;
  77883. removePhysicsBody(impostor: PhysicsImpostor): void;
  77884. generateJoint(joint: PhysicsImpostorJoint): void;
  77885. removeJoint(joint: PhysicsImpostorJoint): void;
  77886. isSupported(): boolean;
  77887. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  77888. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  77889. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77890. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77891. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77892. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77893. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  77894. getBodyMass(impostor: PhysicsImpostor): number;
  77895. getBodyFriction(impostor: PhysicsImpostor): number;
  77896. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  77897. getBodyRestitution(impostor: PhysicsImpostor): number;
  77898. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  77899. getBodyPressure?(impostor: PhysicsImpostor): number;
  77900. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  77901. getBodyStiffness?(impostor: PhysicsImpostor): number;
  77902. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  77903. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  77904. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  77905. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  77906. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  77907. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  77908. sleepBody(impostor: PhysicsImpostor): void;
  77909. wakeUpBody(impostor: PhysicsImpostor): void;
  77910. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  77911. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  77912. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  77913. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77914. getRadius(impostor: PhysicsImpostor): number;
  77915. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  77916. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  77917. dispose(): void;
  77918. }
  77919. /**
  77920. * Interface used to define a physics engine
  77921. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  77922. */
  77923. export interface IPhysicsEngine {
  77924. /**
  77925. * Gets the gravity vector used by the simulation
  77926. */
  77927. gravity: Vector3;
  77928. /**
  77929. * Sets the gravity vector used by the simulation
  77930. * @param gravity defines the gravity vector to use
  77931. */
  77932. setGravity(gravity: Vector3): void;
  77933. /**
  77934. * Set the time step of the physics engine.
  77935. * Default is 1/60.
  77936. * To slow it down, enter 1/600 for example.
  77937. * To speed it up, 1/30
  77938. * @param newTimeStep the new timestep to apply to this world.
  77939. */
  77940. setTimeStep(newTimeStep: number): void;
  77941. /**
  77942. * Get the time step of the physics engine.
  77943. * @returns the current time step
  77944. */
  77945. getTimeStep(): number;
  77946. /**
  77947. * Release all resources
  77948. */
  77949. dispose(): void;
  77950. /**
  77951. * Gets the name of the current physics plugin
  77952. * @returns the name of the plugin
  77953. */
  77954. getPhysicsPluginName(): string;
  77955. /**
  77956. * Adding a new impostor for the impostor tracking.
  77957. * This will be done by the impostor itself.
  77958. * @param impostor the impostor to add
  77959. */
  77960. addImpostor(impostor: PhysicsImpostor): void;
  77961. /**
  77962. * Remove an impostor from the engine.
  77963. * This impostor and its mesh will not longer be updated by the physics engine.
  77964. * @param impostor the impostor to remove
  77965. */
  77966. removeImpostor(impostor: PhysicsImpostor): void;
  77967. /**
  77968. * Add a joint to the physics engine
  77969. * @param mainImpostor defines the main impostor to which the joint is added.
  77970. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  77971. * @param joint defines the joint that will connect both impostors.
  77972. */
  77973. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77974. /**
  77975. * Removes a joint from the simulation
  77976. * @param mainImpostor defines the impostor used with the joint
  77977. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  77978. * @param joint defines the joint to remove
  77979. */
  77980. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77981. /**
  77982. * Gets the current plugin used to run the simulation
  77983. * @returns current plugin
  77984. */
  77985. getPhysicsPlugin(): IPhysicsEnginePlugin;
  77986. /**
  77987. * Gets the list of physic impostors
  77988. * @returns an array of PhysicsImpostor
  77989. */
  77990. getImpostors(): Array<PhysicsImpostor>;
  77991. /**
  77992. * Gets the impostor for a physics enabled object
  77993. * @param object defines the object impersonated by the impostor
  77994. * @returns the PhysicsImpostor or null if not found
  77995. */
  77996. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77997. /**
  77998. * Gets the impostor for a physics body object
  77999. * @param body defines physics body used by the impostor
  78000. * @returns the PhysicsImpostor or null if not found
  78001. */
  78002. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  78003. /**
  78004. * Does a raycast in the physics world
  78005. * @param from when should the ray start?
  78006. * @param to when should the ray end?
  78007. * @returns PhysicsRaycastResult
  78008. */
  78009. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78010. /**
  78011. * Called by the scene. No need to call it.
  78012. * @param delta defines the timespam between frames
  78013. */
  78014. _step(delta: number): void;
  78015. }
  78016. }
  78017. declare module BABYLON {
  78018. /**
  78019. * The interface for the physics imposter parameters
  78020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78021. */
  78022. export interface PhysicsImpostorParameters {
  78023. /**
  78024. * The mass of the physics imposter
  78025. */
  78026. mass: number;
  78027. /**
  78028. * The friction of the physics imposter
  78029. */
  78030. friction?: number;
  78031. /**
  78032. * The coefficient of restitution of the physics imposter
  78033. */
  78034. restitution?: number;
  78035. /**
  78036. * The native options of the physics imposter
  78037. */
  78038. nativeOptions?: any;
  78039. /**
  78040. * Specifies if the parent should be ignored
  78041. */
  78042. ignoreParent?: boolean;
  78043. /**
  78044. * Specifies if bi-directional transformations should be disabled
  78045. */
  78046. disableBidirectionalTransformation?: boolean;
  78047. /**
  78048. * The pressure inside the physics imposter, soft object only
  78049. */
  78050. pressure?: number;
  78051. /**
  78052. * The stiffness the physics imposter, soft object only
  78053. */
  78054. stiffness?: number;
  78055. /**
  78056. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78057. */
  78058. velocityIterations?: number;
  78059. /**
  78060. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78061. */
  78062. positionIterations?: number;
  78063. /**
  78064. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78065. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78066. * Add to fix multiple points
  78067. */
  78068. fixedPoints?: number;
  78069. /**
  78070. * The collision margin around a soft object
  78071. */
  78072. margin?: number;
  78073. /**
  78074. * The collision margin around a soft object
  78075. */
  78076. damping?: number;
  78077. }
  78078. /**
  78079. * Interface for a physics-enabled object
  78080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78081. */
  78082. export interface IPhysicsEnabledObject {
  78083. /**
  78084. * The position of the physics-enabled object
  78085. */
  78086. position: Vector3;
  78087. /**
  78088. * The rotation of the physics-enabled object
  78089. */
  78090. rotationQuaternion: Nullable<Quaternion>;
  78091. /**
  78092. * The scale of the physics-enabled object
  78093. */
  78094. scaling: Vector3;
  78095. /**
  78096. * The rotation of the physics-enabled object
  78097. */
  78098. rotation?: Vector3;
  78099. /**
  78100. * The parent of the physics-enabled object
  78101. */
  78102. parent?: any;
  78103. /**
  78104. * The bounding info of the physics-enabled object
  78105. * @returns The bounding info of the physics-enabled object
  78106. */
  78107. getBoundingInfo(): BoundingInfo;
  78108. /**
  78109. * Computes the world matrix
  78110. * @param force Specifies if the world matrix should be computed by force
  78111. * @returns A world matrix
  78112. */
  78113. computeWorldMatrix(force: boolean): Matrix;
  78114. /**
  78115. * Gets the world matrix
  78116. * @returns A world matrix
  78117. */
  78118. getWorldMatrix?(): Matrix;
  78119. /**
  78120. * Gets the child meshes
  78121. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78122. * @returns An array of abstract meshes
  78123. */
  78124. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78125. /**
  78126. * Gets the vertex data
  78127. * @param kind The type of vertex data
  78128. * @returns A nullable array of numbers, or a float32 array
  78129. */
  78130. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  78131. /**
  78132. * Gets the indices from the mesh
  78133. * @returns A nullable array of index arrays
  78134. */
  78135. getIndices?(): Nullable<IndicesArray>;
  78136. /**
  78137. * Gets the scene from the mesh
  78138. * @returns the indices array or null
  78139. */
  78140. getScene?(): Scene;
  78141. /**
  78142. * Gets the absolute position from the mesh
  78143. * @returns the absolute position
  78144. */
  78145. getAbsolutePosition(): Vector3;
  78146. /**
  78147. * Gets the absolute pivot point from the mesh
  78148. * @returns the absolute pivot point
  78149. */
  78150. getAbsolutePivotPoint(): Vector3;
  78151. /**
  78152. * Rotates the mesh
  78153. * @param axis The axis of rotation
  78154. * @param amount The amount of rotation
  78155. * @param space The space of the rotation
  78156. * @returns The rotation transform node
  78157. */
  78158. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78159. /**
  78160. * Translates the mesh
  78161. * @param axis The axis of translation
  78162. * @param distance The distance of translation
  78163. * @param space The space of the translation
  78164. * @returns The transform node
  78165. */
  78166. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78167. /**
  78168. * Sets the absolute position of the mesh
  78169. * @param absolutePosition The absolute position of the mesh
  78170. * @returns The transform node
  78171. */
  78172. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78173. /**
  78174. * Gets the class name of the mesh
  78175. * @returns The class name
  78176. */
  78177. getClassName(): string;
  78178. }
  78179. /**
  78180. * Represents a physics imposter
  78181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78182. */
  78183. export class PhysicsImpostor {
  78184. /**
  78185. * The physics-enabled object used as the physics imposter
  78186. */
  78187. object: IPhysicsEnabledObject;
  78188. /**
  78189. * The type of the physics imposter
  78190. */
  78191. type: number;
  78192. private _options;
  78193. private _scene?;
  78194. /**
  78195. * The default object size of the imposter
  78196. */
  78197. static DEFAULT_OBJECT_SIZE: Vector3;
  78198. /**
  78199. * The identity quaternion of the imposter
  78200. */
  78201. static IDENTITY_QUATERNION: Quaternion;
  78202. /** @hidden */
  78203. _pluginData: any;
  78204. private _physicsEngine;
  78205. private _physicsBody;
  78206. private _bodyUpdateRequired;
  78207. private _onBeforePhysicsStepCallbacks;
  78208. private _onAfterPhysicsStepCallbacks;
  78209. /** @hidden */
  78210. _onPhysicsCollideCallbacks: Array<{
  78211. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  78212. otherImpostors: Array<PhysicsImpostor>;
  78213. }>;
  78214. private _deltaPosition;
  78215. private _deltaRotation;
  78216. private _deltaRotationConjugated;
  78217. private _parent;
  78218. private _isDisposed;
  78219. private static _tmpVecs;
  78220. private static _tmpQuat;
  78221. /**
  78222. * Specifies if the physics imposter is disposed
  78223. */
  78224. readonly isDisposed: boolean;
  78225. /**
  78226. * Gets the mass of the physics imposter
  78227. */
  78228. mass: number;
  78229. /**
  78230. * Gets the coefficient of friction
  78231. */
  78232. /**
  78233. * Sets the coefficient of friction
  78234. */
  78235. friction: number;
  78236. /**
  78237. * Gets the coefficient of restitution
  78238. */
  78239. /**
  78240. * Sets the coefficient of restitution
  78241. */
  78242. restitution: number;
  78243. /**
  78244. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  78245. */
  78246. /**
  78247. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  78248. */
  78249. pressure: number;
  78250. /**
  78251. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78252. */
  78253. /**
  78254. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78255. */
  78256. stiffness: number;
  78257. /**
  78258. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78259. */
  78260. /**
  78261. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78262. */
  78263. velocityIterations: number;
  78264. /**
  78265. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78266. */
  78267. /**
  78268. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78269. */
  78270. positionIterations: number;
  78271. /**
  78272. * The unique id of the physics imposter
  78273. * set by the physics engine when adding this impostor to the array
  78274. */
  78275. uniqueId: number;
  78276. /**
  78277. * @hidden
  78278. */
  78279. soft: boolean;
  78280. /**
  78281. * @hidden
  78282. */
  78283. segments: number;
  78284. private _joints;
  78285. /**
  78286. * Initializes the physics imposter
  78287. * @param object The physics-enabled object used as the physics imposter
  78288. * @param type The type of the physics imposter
  78289. * @param _options The options for the physics imposter
  78290. * @param _scene The Babylon scene
  78291. */
  78292. constructor(
  78293. /**
  78294. * The physics-enabled object used as the physics imposter
  78295. */
  78296. object: IPhysicsEnabledObject,
  78297. /**
  78298. * The type of the physics imposter
  78299. */
  78300. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  78301. /**
  78302. * This function will completly initialize this impostor.
  78303. * It will create a new body - but only if this mesh has no parent.
  78304. * If it has, this impostor will not be used other than to define the impostor
  78305. * of the child mesh.
  78306. * @hidden
  78307. */
  78308. _init(): void;
  78309. private _getPhysicsParent;
  78310. /**
  78311. * Should a new body be generated.
  78312. * @returns boolean specifying if body initialization is required
  78313. */
  78314. isBodyInitRequired(): boolean;
  78315. /**
  78316. * Sets the updated scaling
  78317. * @param updated Specifies if the scaling is updated
  78318. */
  78319. setScalingUpdated(): void;
  78320. /**
  78321. * Force a regeneration of this or the parent's impostor's body.
  78322. * Use under cautious - This will remove all joints already implemented.
  78323. */
  78324. forceUpdate(): void;
  78325. /**
  78326. * Gets the body that holds this impostor. Either its own, or its parent.
  78327. */
  78328. /**
  78329. * Set the physics body. Used mainly by the physics engine/plugin
  78330. */
  78331. physicsBody: any;
  78332. /**
  78333. * Get the parent of the physics imposter
  78334. * @returns Physics imposter or null
  78335. */
  78336. /**
  78337. * Sets the parent of the physics imposter
  78338. */
  78339. parent: Nullable<PhysicsImpostor>;
  78340. /**
  78341. * Resets the update flags
  78342. */
  78343. resetUpdateFlags(): void;
  78344. /**
  78345. * Gets the object extend size
  78346. * @returns the object extend size
  78347. */
  78348. getObjectExtendSize(): Vector3;
  78349. /**
  78350. * Gets the object center
  78351. * @returns The object center
  78352. */
  78353. getObjectCenter(): Vector3;
  78354. /**
  78355. * Get a specific parametes from the options parameter
  78356. * @param paramName The object parameter name
  78357. * @returns The object parameter
  78358. */
  78359. getParam(paramName: string): any;
  78360. /**
  78361. * Sets a specific parameter in the options given to the physics plugin
  78362. * @param paramName The parameter name
  78363. * @param value The value of the parameter
  78364. */
  78365. setParam(paramName: string, value: number): void;
  78366. /**
  78367. * Specifically change the body's mass option. Won't recreate the physics body object
  78368. * @param mass The mass of the physics imposter
  78369. */
  78370. setMass(mass: number): void;
  78371. /**
  78372. * Gets the linear velocity
  78373. * @returns linear velocity or null
  78374. */
  78375. getLinearVelocity(): Nullable<Vector3>;
  78376. /**
  78377. * Sets the linear velocity
  78378. * @param velocity linear velocity or null
  78379. */
  78380. setLinearVelocity(velocity: Nullable<Vector3>): void;
  78381. /**
  78382. * Gets the angular velocity
  78383. * @returns angular velocity or null
  78384. */
  78385. getAngularVelocity(): Nullable<Vector3>;
  78386. /**
  78387. * Sets the angular velocity
  78388. * @param velocity The velocity or null
  78389. */
  78390. setAngularVelocity(velocity: Nullable<Vector3>): void;
  78391. /**
  78392. * Execute a function with the physics plugin native code
  78393. * Provide a function the will have two variables - the world object and the physics body object
  78394. * @param func The function to execute with the physics plugin native code
  78395. */
  78396. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  78397. /**
  78398. * Register a function that will be executed before the physics world is stepping forward
  78399. * @param func The function to execute before the physics world is stepped forward
  78400. */
  78401. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78402. /**
  78403. * Unregister a function that will be executed before the physics world is stepping forward
  78404. * @param func The function to execute before the physics world is stepped forward
  78405. */
  78406. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78407. /**
  78408. * Register a function that will be executed after the physics step
  78409. * @param func The function to execute after physics step
  78410. */
  78411. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78412. /**
  78413. * Unregisters a function that will be executed after the physics step
  78414. * @param func The function to execute after physics step
  78415. */
  78416. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78417. /**
  78418. * register a function that will be executed when this impostor collides against a different body
  78419. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  78420. * @param func Callback that is executed on collision
  78421. */
  78422. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  78423. /**
  78424. * Unregisters the physics imposter on contact
  78425. * @param collideAgainst The physics object to collide against
  78426. * @param func Callback to execute on collision
  78427. */
  78428. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  78429. private _tmpQuat;
  78430. private _tmpQuat2;
  78431. /**
  78432. * Get the parent rotation
  78433. * @returns The parent rotation
  78434. */
  78435. getParentsRotation(): Quaternion;
  78436. /**
  78437. * this function is executed by the physics engine.
  78438. */
  78439. beforeStep: () => void;
  78440. /**
  78441. * this function is executed by the physics engine
  78442. */
  78443. afterStep: () => void;
  78444. /**
  78445. * Legacy collision detection event support
  78446. */
  78447. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  78448. /**
  78449. * event and body object due to cannon's event-based architecture.
  78450. */
  78451. onCollide: (e: {
  78452. body: any;
  78453. }) => void;
  78454. /**
  78455. * Apply a force
  78456. * @param force The force to apply
  78457. * @param contactPoint The contact point for the force
  78458. * @returns The physics imposter
  78459. */
  78460. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78461. /**
  78462. * Apply an impulse
  78463. * @param force The impulse force
  78464. * @param contactPoint The contact point for the impulse force
  78465. * @returns The physics imposter
  78466. */
  78467. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78468. /**
  78469. * A help function to create a joint
  78470. * @param otherImpostor A physics imposter used to create a joint
  78471. * @param jointType The type of joint
  78472. * @param jointData The data for the joint
  78473. * @returns The physics imposter
  78474. */
  78475. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  78476. /**
  78477. * Add a joint to this impostor with a different impostor
  78478. * @param otherImpostor A physics imposter used to add a joint
  78479. * @param joint The joint to add
  78480. * @returns The physics imposter
  78481. */
  78482. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  78483. /**
  78484. * Add an anchor to a soft impostor
  78485. * @param otherImpostor rigid impostor as the anchor
  78486. * @param width ratio across width from 0 to 1
  78487. * @param height ratio up height from 0 to 1
  78488. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, no strech
  78489. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  78490. * @returns impostor the soft imposter
  78491. */
  78492. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  78493. /**
  78494. * Will keep this body still, in a sleep mode.
  78495. * @returns the physics imposter
  78496. */
  78497. sleep(): PhysicsImpostor;
  78498. /**
  78499. * Wake the body up.
  78500. * @returns The physics imposter
  78501. */
  78502. wakeUp(): PhysicsImpostor;
  78503. /**
  78504. * Clones the physics imposter
  78505. * @param newObject The physics imposter clones to this physics-enabled object
  78506. * @returns A nullable physics imposter
  78507. */
  78508. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78509. /**
  78510. * Disposes the physics imposter
  78511. */
  78512. dispose(): void;
  78513. /**
  78514. * Sets the delta position
  78515. * @param position The delta position amount
  78516. */
  78517. setDeltaPosition(position: Vector3): void;
  78518. /**
  78519. * Sets the delta rotation
  78520. * @param rotation The delta rotation amount
  78521. */
  78522. setDeltaRotation(rotation: Quaternion): void;
  78523. /**
  78524. * Gets the box size of the physics imposter and stores the result in the input parameter
  78525. * @param result Stores the box size
  78526. * @returns The physics imposter
  78527. */
  78528. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  78529. /**
  78530. * Gets the radius of the physics imposter
  78531. * @returns Radius of the physics imposter
  78532. */
  78533. getRadius(): number;
  78534. /**
  78535. * Sync a bone with this impostor
  78536. * @param bone The bone to sync to the impostor.
  78537. * @param boneMesh The mesh that the bone is influencing.
  78538. * @param jointPivot The pivot of the joint / bone in local space.
  78539. * @param distToJoint Optional distance from the impostor to the joint.
  78540. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78541. */
  78542. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  78543. /**
  78544. * Sync impostor to a bone
  78545. * @param bone The bone that the impostor will be synced to.
  78546. * @param boneMesh The mesh that the bone is influencing.
  78547. * @param jointPivot The pivot of the joint / bone in local space.
  78548. * @param distToJoint Optional distance from the impostor to the joint.
  78549. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78550. * @param boneAxis Optional vector3 axis the bone is aligned with
  78551. */
  78552. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  78553. /**
  78554. * No-Imposter type
  78555. */
  78556. static NoImpostor: number;
  78557. /**
  78558. * Sphere-Imposter type
  78559. */
  78560. static SphereImpostor: number;
  78561. /**
  78562. * Box-Imposter type
  78563. */
  78564. static BoxImpostor: number;
  78565. /**
  78566. * Plane-Imposter type
  78567. */
  78568. static PlaneImpostor: number;
  78569. /**
  78570. * Mesh-imposter type
  78571. */
  78572. static MeshImpostor: number;
  78573. /**
  78574. * Cylinder-Imposter type
  78575. */
  78576. static CylinderImpostor: number;
  78577. /**
  78578. * Particle-Imposter type
  78579. */
  78580. static ParticleImpostor: number;
  78581. /**
  78582. * Heightmap-Imposter type
  78583. */
  78584. static HeightmapImpostor: number;
  78585. /**
  78586. * ConvexHull-Impostor type (Ammo.js plugin only)
  78587. */
  78588. static ConvexHullImpostor: number;
  78589. /**
  78590. * Rope-Imposter type
  78591. */
  78592. static RopeImpostor: number;
  78593. /**
  78594. * Cloth-Imposter type
  78595. */
  78596. static ClothImpostor: number;
  78597. /**
  78598. * Softbody-Imposter type
  78599. */
  78600. static SoftbodyImpostor: number;
  78601. }
  78602. }
  78603. declare module BABYLON {
  78604. /**
  78605. * Class used to represent a specific level of detail of a mesh
  78606. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78607. */
  78608. export class MeshLODLevel {
  78609. /** Defines the distance where this level should star being displayed */
  78610. distance: number;
  78611. /** Defines the mesh to use to render this level */
  78612. mesh: Nullable<Mesh>;
  78613. /**
  78614. * Creates a new LOD level
  78615. * @param distance defines the distance where this level should star being displayed
  78616. * @param mesh defines the mesh to use to render this level
  78617. */
  78618. constructor(
  78619. /** Defines the distance where this level should star being displayed */
  78620. distance: number,
  78621. /** Defines the mesh to use to render this level */
  78622. mesh: Nullable<Mesh>);
  78623. }
  78624. /**
  78625. * @hidden
  78626. **/
  78627. export class _CreationDataStorage {
  78628. closePath?: boolean;
  78629. closeArray?: boolean;
  78630. idx: number[];
  78631. dashSize: number;
  78632. gapSize: number;
  78633. path3D: Path3D;
  78634. pathArray: Vector3[][];
  78635. arc: number;
  78636. radius: number;
  78637. cap: number;
  78638. tessellation: number;
  78639. }
  78640. /**
  78641. * @hidden
  78642. **/
  78643. class _InstanceDataStorage {
  78644. visibleInstances: any;
  78645. renderIdForInstances: number[];
  78646. batchCache: _InstancesBatch;
  78647. instancesBufferSize: number;
  78648. instancesBuffer: Nullable<Buffer>;
  78649. instancesData: Float32Array;
  78650. overridenInstanceCount: number;
  78651. }
  78652. /**
  78653. * @hidden
  78654. **/
  78655. export class _InstancesBatch {
  78656. mustReturn: boolean;
  78657. visibleInstances: Nullable<InstancedMesh[]>[];
  78658. renderSelf: boolean[];
  78659. }
  78660. /**
  78661. * Class used to represent renderable models
  78662. */
  78663. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  78664. /**
  78665. * Mesh side orientation : usually the external or front surface
  78666. */
  78667. static readonly FRONTSIDE: number;
  78668. /**
  78669. * Mesh side orientation : usually the internal or back surface
  78670. */
  78671. static readonly BACKSIDE: number;
  78672. /**
  78673. * Mesh side orientation : both internal and external or front and back surfaces
  78674. */
  78675. static readonly DOUBLESIDE: number;
  78676. /**
  78677. * Mesh side orientation : by default, `FRONTSIDE`
  78678. */
  78679. static readonly DEFAULTSIDE: number;
  78680. /**
  78681. * Mesh cap setting : no cap
  78682. */
  78683. static readonly NO_CAP: number;
  78684. /**
  78685. * Mesh cap setting : one cap at the beginning of the mesh
  78686. */
  78687. static readonly CAP_START: number;
  78688. /**
  78689. * Mesh cap setting : one cap at the end of the mesh
  78690. */
  78691. static readonly CAP_END: number;
  78692. /**
  78693. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  78694. */
  78695. static readonly CAP_ALL: number;
  78696. /**
  78697. * Gets the default side orientation.
  78698. * @param orientation the orientation to value to attempt to get
  78699. * @returns the default orientation
  78700. * @hidden
  78701. */
  78702. static _GetDefaultSideOrientation(orientation?: number): number;
  78703. private _onBeforeRenderObservable;
  78704. private _onBeforeBindObservable;
  78705. private _onAfterRenderObservable;
  78706. private _onBeforeDrawObservable;
  78707. /**
  78708. * An event triggered before rendering the mesh
  78709. */
  78710. readonly onBeforeRenderObservable: Observable<Mesh>;
  78711. /**
  78712. * An event triggered before binding the mesh
  78713. */
  78714. readonly onBeforeBindObservable: Observable<Mesh>;
  78715. /**
  78716. * An event triggered after rendering the mesh
  78717. */
  78718. readonly onAfterRenderObservable: Observable<Mesh>;
  78719. /**
  78720. * An event triggered before drawing the mesh
  78721. */
  78722. readonly onBeforeDrawObservable: Observable<Mesh>;
  78723. private _onBeforeDrawObserver;
  78724. /**
  78725. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  78726. */
  78727. onBeforeDraw: () => void;
  78728. /**
  78729. * Gets the delay loading state of the mesh (when delay loading is turned on)
  78730. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  78731. */
  78732. delayLoadState: number;
  78733. /**
  78734. * Gets the list of instances created from this mesh
  78735. * it is not supposed to be modified manually.
  78736. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  78737. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78738. */
  78739. instances: InstancedMesh[];
  78740. /**
  78741. * Gets the file containing delay loading data for this mesh
  78742. */
  78743. delayLoadingFile: string;
  78744. /** @hidden */
  78745. _binaryInfo: any;
  78746. private _LODLevels;
  78747. /**
  78748. * User defined function used to change how LOD level selection is done
  78749. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78750. */
  78751. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  78752. private _morphTargetManager;
  78753. /**
  78754. * Gets or sets the morph target manager
  78755. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78756. */
  78757. morphTargetManager: Nullable<MorphTargetManager>;
  78758. /** @hidden */
  78759. _creationDataStorage: Nullable<_CreationDataStorage>;
  78760. /** @hidden */
  78761. _geometry: Nullable<Geometry>;
  78762. /** @hidden */
  78763. _delayInfo: Array<string>;
  78764. /** @hidden */
  78765. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  78766. /** @hidden */
  78767. _instanceDataStorage: _InstanceDataStorage;
  78768. private _effectiveMaterial;
  78769. /** @hidden */
  78770. _shouldGenerateFlatShading: boolean;
  78771. private _preActivateId;
  78772. /** @hidden */
  78773. _originalBuilderSideOrientation: number;
  78774. /**
  78775. * Use this property to change the original side orientation defined at construction time
  78776. */
  78777. overrideMaterialSideOrientation: Nullable<number>;
  78778. private _areNormalsFrozen;
  78779. private _sourcePositions;
  78780. private _sourceNormals;
  78781. private _source;
  78782. private meshMap;
  78783. /**
  78784. * Gets the source mesh (the one used to clone this one from)
  78785. */
  78786. readonly source: Nullable<Mesh>;
  78787. /**
  78788. * Gets or sets a boolean indicating that this mesh does not use index buffer
  78789. */
  78790. isUnIndexed: boolean;
  78791. /**
  78792. * @constructor
  78793. * @param name The value used by scene.getMeshByName() to do a lookup.
  78794. * @param scene The scene to add this mesh to.
  78795. * @param parent The parent of this mesh, if it has one
  78796. * @param source An optional Mesh from which geometry is shared, cloned.
  78797. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  78798. * When false, achieved by calling a clone(), also passing False.
  78799. * This will make creation of children, recursive.
  78800. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  78801. */
  78802. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  78803. /**
  78804. * Gets the class name
  78805. * @returns the string "Mesh".
  78806. */
  78807. getClassName(): string;
  78808. /** @hidden */
  78809. readonly _isMesh: boolean;
  78810. /**
  78811. * Returns a description of this mesh
  78812. * @param fullDetails define if full details about this mesh must be used
  78813. * @returns a descriptive string representing this mesh
  78814. */
  78815. toString(fullDetails?: boolean): string;
  78816. /** @hidden */
  78817. _unBindEffect(): void;
  78818. /**
  78819. * Gets a boolean indicating if this mesh has LOD
  78820. */
  78821. readonly hasLODLevels: boolean;
  78822. /**
  78823. * Gets the list of MeshLODLevel associated with the current mesh
  78824. * @returns an array of MeshLODLevel
  78825. */
  78826. getLODLevels(): MeshLODLevel[];
  78827. private _sortLODLevels;
  78828. /**
  78829. * Add a mesh as LOD level triggered at the given distance.
  78830. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78831. * @param distance The distance from the center of the object to show this level
  78832. * @param mesh The mesh to be added as LOD level (can be null)
  78833. * @return This mesh (for chaining)
  78834. */
  78835. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  78836. /**
  78837. * Returns the LOD level mesh at the passed distance or null if not found.
  78838. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78839. * @param distance The distance from the center of the object to show this level
  78840. * @returns a Mesh or `null`
  78841. */
  78842. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  78843. /**
  78844. * Remove a mesh from the LOD array
  78845. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78846. * @param mesh defines the mesh to be removed
  78847. * @return This mesh (for chaining)
  78848. */
  78849. removeLODLevel(mesh: Mesh): Mesh;
  78850. /**
  78851. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  78852. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78853. * @param camera defines the camera to use to compute distance
  78854. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  78855. * @return This mesh (for chaining)
  78856. */
  78857. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  78858. /**
  78859. * Gets the mesh internal Geometry object
  78860. */
  78861. readonly geometry: Nullable<Geometry>;
  78862. /**
  78863. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  78864. * @returns the total number of vertices
  78865. */
  78866. getTotalVertices(): number;
  78867. /**
  78868. * Returns the content of an associated vertex buffer
  78869. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78870. * - VertexBuffer.PositionKind
  78871. * - VertexBuffer.UVKind
  78872. * - VertexBuffer.UV2Kind
  78873. * - VertexBuffer.UV3Kind
  78874. * - VertexBuffer.UV4Kind
  78875. * - VertexBuffer.UV5Kind
  78876. * - VertexBuffer.UV6Kind
  78877. * - VertexBuffer.ColorKind
  78878. * - VertexBuffer.MatricesIndicesKind
  78879. * - VertexBuffer.MatricesIndicesExtraKind
  78880. * - VertexBuffer.MatricesWeightsKind
  78881. * - VertexBuffer.MatricesWeightsExtraKind
  78882. * @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
  78883. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  78884. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  78885. */
  78886. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78887. /**
  78888. * Returns the mesh VertexBuffer object from the requested `kind`
  78889. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78890. * - VertexBuffer.PositionKind
  78891. * - VertexBuffer.UVKind
  78892. * - VertexBuffer.UV2Kind
  78893. * - VertexBuffer.UV3Kind
  78894. * - VertexBuffer.UV4Kind
  78895. * - VertexBuffer.UV5Kind
  78896. * - VertexBuffer.UV6Kind
  78897. * - VertexBuffer.ColorKind
  78898. * - VertexBuffer.MatricesIndicesKind
  78899. * - VertexBuffer.MatricesIndicesExtraKind
  78900. * - VertexBuffer.MatricesWeightsKind
  78901. * - VertexBuffer.MatricesWeightsExtraKind
  78902. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  78903. */
  78904. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78905. /**
  78906. * Tests if a specific vertex buffer is associated with this mesh
  78907. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78908. * - VertexBuffer.PositionKind
  78909. * - VertexBuffer.UVKind
  78910. * - VertexBuffer.UV2Kind
  78911. * - VertexBuffer.UV3Kind
  78912. * - VertexBuffer.UV4Kind
  78913. * - VertexBuffer.UV5Kind
  78914. * - VertexBuffer.UV6Kind
  78915. * - VertexBuffer.ColorKind
  78916. * - VertexBuffer.MatricesIndicesKind
  78917. * - VertexBuffer.MatricesIndicesExtraKind
  78918. * - VertexBuffer.MatricesWeightsKind
  78919. * - VertexBuffer.MatricesWeightsExtraKind
  78920. * @returns a boolean
  78921. */
  78922. isVerticesDataPresent(kind: string): boolean;
  78923. /**
  78924. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  78925. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78926. * - VertexBuffer.PositionKind
  78927. * - VertexBuffer.UVKind
  78928. * - VertexBuffer.UV2Kind
  78929. * - VertexBuffer.UV3Kind
  78930. * - VertexBuffer.UV4Kind
  78931. * - VertexBuffer.UV5Kind
  78932. * - VertexBuffer.UV6Kind
  78933. * - VertexBuffer.ColorKind
  78934. * - VertexBuffer.MatricesIndicesKind
  78935. * - VertexBuffer.MatricesIndicesExtraKind
  78936. * - VertexBuffer.MatricesWeightsKind
  78937. * - VertexBuffer.MatricesWeightsExtraKind
  78938. * @returns a boolean
  78939. */
  78940. isVertexBufferUpdatable(kind: string): boolean;
  78941. /**
  78942. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  78943. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78944. * - VertexBuffer.PositionKind
  78945. * - VertexBuffer.UVKind
  78946. * - VertexBuffer.UV2Kind
  78947. * - VertexBuffer.UV3Kind
  78948. * - VertexBuffer.UV4Kind
  78949. * - VertexBuffer.UV5Kind
  78950. * - VertexBuffer.UV6Kind
  78951. * - VertexBuffer.ColorKind
  78952. * - VertexBuffer.MatricesIndicesKind
  78953. * - VertexBuffer.MatricesIndicesExtraKind
  78954. * - VertexBuffer.MatricesWeightsKind
  78955. * - VertexBuffer.MatricesWeightsExtraKind
  78956. * @returns an array of strings
  78957. */
  78958. getVerticesDataKinds(): string[];
  78959. /**
  78960. * Returns a positive integer : the total number of indices in this mesh geometry.
  78961. * @returns the numner of indices or zero if the mesh has no geometry.
  78962. */
  78963. getTotalIndices(): number;
  78964. /**
  78965. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78966. * @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.
  78967. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78968. * @returns the indices array or an empty array if the mesh has no geometry
  78969. */
  78970. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78971. readonly isBlocked: boolean;
  78972. /**
  78973. * Determine if the current mesh is ready to be rendered
  78974. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  78975. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  78976. * @returns true if all associated assets are ready (material, textures, shaders)
  78977. */
  78978. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  78979. /**
  78980. * 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.
  78981. */
  78982. readonly areNormalsFrozen: boolean;
  78983. /**
  78984. * 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.
  78985. * @returns the current mesh
  78986. */
  78987. freezeNormals(): Mesh;
  78988. /**
  78989. * 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
  78990. * @returns the current mesh
  78991. */
  78992. unfreezeNormals(): Mesh;
  78993. /**
  78994. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  78995. */
  78996. overridenInstanceCount: number;
  78997. /** @hidden */
  78998. _preActivate(): Mesh;
  78999. /** @hidden */
  79000. _preActivateForIntermediateRendering(renderId: number): Mesh;
  79001. /** @hidden */
  79002. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  79003. /**
  79004. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79005. * This means the mesh underlying bounding box and sphere are recomputed.
  79006. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79007. * @returns the current mesh
  79008. */
  79009. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  79010. /** @hidden */
  79011. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  79012. /**
  79013. * This function will subdivide the mesh into multiple submeshes
  79014. * @param count defines the expected number of submeshes
  79015. */
  79016. subdivide(count: number): void;
  79017. /**
  79018. * Copy a FloatArray into a specific associated vertex buffer
  79019. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79020. * - VertexBuffer.PositionKind
  79021. * - VertexBuffer.UVKind
  79022. * - VertexBuffer.UV2Kind
  79023. * - VertexBuffer.UV3Kind
  79024. * - VertexBuffer.UV4Kind
  79025. * - VertexBuffer.UV5Kind
  79026. * - VertexBuffer.UV6Kind
  79027. * - VertexBuffer.ColorKind
  79028. * - VertexBuffer.MatricesIndicesKind
  79029. * - VertexBuffer.MatricesIndicesExtraKind
  79030. * - VertexBuffer.MatricesWeightsKind
  79031. * - VertexBuffer.MatricesWeightsExtraKind
  79032. * @param data defines the data source
  79033. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79034. * @param stride defines the data stride size (can be null)
  79035. * @returns the current mesh
  79036. */
  79037. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79038. /**
  79039. * Flags an associated vertex buffer as updatable
  79040. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  79041. * - VertexBuffer.PositionKind
  79042. * - VertexBuffer.UVKind
  79043. * - VertexBuffer.UV2Kind
  79044. * - VertexBuffer.UV3Kind
  79045. * - VertexBuffer.UV4Kind
  79046. * - VertexBuffer.UV5Kind
  79047. * - VertexBuffer.UV6Kind
  79048. * - VertexBuffer.ColorKind
  79049. * - VertexBuffer.MatricesIndicesKind
  79050. * - VertexBuffer.MatricesIndicesExtraKind
  79051. * - VertexBuffer.MatricesWeightsKind
  79052. * - VertexBuffer.MatricesWeightsExtraKind
  79053. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79054. */
  79055. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  79056. /**
  79057. * Sets the mesh global Vertex Buffer
  79058. * @param buffer defines the buffer to use
  79059. * @returns the current mesh
  79060. */
  79061. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  79062. /**
  79063. * Update a specific associated vertex buffer
  79064. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79065. * - VertexBuffer.PositionKind
  79066. * - VertexBuffer.UVKind
  79067. * - VertexBuffer.UV2Kind
  79068. * - VertexBuffer.UV3Kind
  79069. * - VertexBuffer.UV4Kind
  79070. * - VertexBuffer.UV5Kind
  79071. * - VertexBuffer.UV6Kind
  79072. * - VertexBuffer.ColorKind
  79073. * - VertexBuffer.MatricesIndicesKind
  79074. * - VertexBuffer.MatricesIndicesExtraKind
  79075. * - VertexBuffer.MatricesWeightsKind
  79076. * - VertexBuffer.MatricesWeightsExtraKind
  79077. * @param data defines the data source
  79078. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79079. * @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)
  79080. * @returns the current mesh
  79081. */
  79082. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79083. /**
  79084. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79085. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79086. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79087. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79088. * @returns the current mesh
  79089. */
  79090. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79091. /**
  79092. * Creates a un-shared specific occurence of the geometry for the mesh.
  79093. * @returns the current mesh
  79094. */
  79095. makeGeometryUnique(): Mesh;
  79096. /**
  79097. * Set the index buffer of this mesh
  79098. * @param indices defines the source data
  79099. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79100. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79101. * @returns the current mesh
  79102. */
  79103. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79104. /**
  79105. * Update the current index buffer
  79106. * @param indices defines the source data
  79107. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79108. * @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)
  79109. * @returns the current mesh
  79110. */
  79111. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79112. /**
  79113. * Invert the geometry to move from a right handed system to a left handed one.
  79114. * @returns the current mesh
  79115. */
  79116. toLeftHanded(): Mesh;
  79117. /** @hidden */
  79118. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  79119. /** @hidden */
  79120. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  79121. /**
  79122. * Registers for this mesh a javascript function called just before the rendering process
  79123. * @param func defines the function to call before rendering this mesh
  79124. * @returns the current mesh
  79125. */
  79126. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79127. /**
  79128. * Disposes a previously registered javascript function called before the rendering
  79129. * @param func defines the function to remove
  79130. * @returns the current mesh
  79131. */
  79132. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79133. /**
  79134. * Registers for this mesh a javascript function called just after the rendering is complete
  79135. * @param func defines the function to call after rendering this mesh
  79136. * @returns the current mesh
  79137. */
  79138. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79139. /**
  79140. * Disposes a previously registered javascript function called after the rendering.
  79141. * @param func defines the function to remove
  79142. * @returns the current mesh
  79143. */
  79144. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79145. /** @hidden */
  79146. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  79147. /** @hidden */
  79148. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  79149. /** @hidden */
  79150. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  79151. /**
  79152. * 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
  79153. * @param subMesh defines the subMesh to render
  79154. * @param enableAlphaMode defines if alpha mode can be changed
  79155. * @returns the current mesh
  79156. */
  79157. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  79158. private _onBeforeDraw;
  79159. /**
  79160. * Renormalize the mesh and patch it up if there are no weights
  79161. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  79162. * However in the case of zero weights then we set just a single influence to 1.
  79163. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  79164. */
  79165. cleanMatrixWeights(): void;
  79166. private normalizeSkinFourWeights;
  79167. private normalizeSkinWeightsAndExtra;
  79168. /**
  79169. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  79170. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  79171. * the user know there was an issue with importing the mesh
  79172. * @returns a validation object with skinned, valid and report string
  79173. */
  79174. validateSkinning(): {
  79175. skinned: boolean;
  79176. valid: boolean;
  79177. report: string;
  79178. };
  79179. /** @hidden */
  79180. _checkDelayState(): Mesh;
  79181. private _queueLoad;
  79182. /**
  79183. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79184. * A mesh is in the frustum if its bounding box intersects the frustum
  79185. * @param frustumPlanes defines the frustum to test
  79186. * @returns true if the mesh is in the frustum planes
  79187. */
  79188. isInFrustum(frustumPlanes: Plane[]): boolean;
  79189. /**
  79190. * Sets the mesh material by the material or multiMaterial `id` property
  79191. * @param id is a string identifying the material or the multiMaterial
  79192. * @returns the current mesh
  79193. */
  79194. setMaterialByID(id: string): Mesh;
  79195. /**
  79196. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  79197. * @returns an array of IAnimatable
  79198. */
  79199. getAnimatables(): IAnimatable[];
  79200. /**
  79201. * Modifies the mesh geometry according to the passed transformation matrix.
  79202. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  79203. * The mesh normals are modified using the same transformation.
  79204. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79205. * @param transform defines the transform matrix to use
  79206. * @see http://doc.babylonjs.com/resources/baking_transformations
  79207. * @returns the current mesh
  79208. */
  79209. bakeTransformIntoVertices(transform: Matrix): Mesh;
  79210. /**
  79211. * Modifies the mesh geometry according to its own current World Matrix.
  79212. * The mesh World Matrix is then reset.
  79213. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  79214. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79215. * @see http://doc.babylonjs.com/resources/baking_transformations
  79216. * @returns the current mesh
  79217. */
  79218. bakeCurrentTransformIntoVertices(): Mesh;
  79219. /** @hidden */
  79220. readonly _positions: Nullable<Vector3[]>;
  79221. /** @hidden */
  79222. _resetPointsArrayCache(): Mesh;
  79223. /** @hidden */
  79224. _generatePointsArray(): boolean;
  79225. /**
  79226. * Returns a new Mesh object generated from the current mesh properties.
  79227. * This method must not get confused with createInstance()
  79228. * @param name is a string, the name given to the new mesh
  79229. * @param newParent can be any Node object (default `null`)
  79230. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  79231. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  79232. * @returns a new mesh
  79233. */
  79234. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  79235. /**
  79236. * Releases resources associated with this mesh.
  79237. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79238. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79239. */
  79240. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79241. /**
  79242. * Modifies the mesh geometry according to a displacement map.
  79243. * 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.
  79244. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79245. * @param url is a string, the URL from the image file is to be downloaded.
  79246. * @param minHeight is the lower limit of the displacement.
  79247. * @param maxHeight is the upper limit of the displacement.
  79248. * @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.
  79249. * @param uvOffset is an optional vector2 used to offset UV.
  79250. * @param uvScale is an optional vector2 used to scale UV.
  79251. * @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.
  79252. * @returns the Mesh.
  79253. */
  79254. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79255. /**
  79256. * Modifies the mesh geometry according to a displacementMap buffer.
  79257. * 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.
  79258. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79259. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  79260. * @param heightMapWidth is the width of the buffer image.
  79261. * @param heightMapHeight is the height of the buffer image.
  79262. * @param minHeight is the lower limit of the displacement.
  79263. * @param maxHeight is the upper limit of the displacement.
  79264. * @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.
  79265. * @param uvOffset is an optional vector2 used to offset UV.
  79266. * @param uvScale is an optional vector2 used to scale UV.
  79267. * @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.
  79268. * @returns the Mesh.
  79269. */
  79270. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79271. /**
  79272. * Modify the mesh to get a flat shading rendering.
  79273. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  79274. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  79275. * @returns current mesh
  79276. */
  79277. convertToFlatShadedMesh(): Mesh;
  79278. /**
  79279. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  79280. * In other words, more vertices, no more indices and a single bigger VBO.
  79281. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  79282. * @returns current mesh
  79283. */
  79284. convertToUnIndexedMesh(): Mesh;
  79285. /**
  79286. * Inverses facet orientations.
  79287. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79288. * @param flipNormals will also inverts the normals
  79289. * @returns current mesh
  79290. */
  79291. flipFaces(flipNormals?: boolean): Mesh;
  79292. /**
  79293. * Increase the number of facets and hence vertices in a mesh
  79294. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79295. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  79296. */
  79297. increaseVertices(numberPerEdge: number): void;
  79298. /**
  79299. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  79300. * This will undo any application of covertToFlatShadedMesh
  79301. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79302. */
  79303. forceSharedVertices(): void;
  79304. /** @hidden */
  79305. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  79306. /** @hidden */
  79307. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  79308. /**
  79309. * Creates a new InstancedMesh object from the mesh model.
  79310. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79311. * @param name defines the name of the new instance
  79312. * @returns a new InstancedMesh
  79313. */
  79314. createInstance(name: string): InstancedMesh;
  79315. /**
  79316. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  79317. * After this call, all the mesh instances have the same submeshes than the current mesh.
  79318. * @returns the current mesh
  79319. */
  79320. synchronizeInstances(): Mesh;
  79321. /**
  79322. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  79323. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  79324. * This should be used together with the simplification to avoid disappearing triangles.
  79325. * @param successCallback an optional success callback to be called after the optimization finished.
  79326. * @returns the current mesh
  79327. */
  79328. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  79329. /**
  79330. * Serialize current mesh
  79331. * @param serializationObject defines the object which will receive the serialization data
  79332. */
  79333. serialize(serializationObject: any): void;
  79334. /** @hidden */
  79335. _syncGeometryWithMorphTargetManager(): void;
  79336. /** @hidden */
  79337. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  79338. /**
  79339. * Returns a new Mesh object parsed from the source provided.
  79340. * @param parsedMesh is the source
  79341. * @param scene defines the hosting scene
  79342. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  79343. * @returns a new Mesh
  79344. */
  79345. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  79346. /**
  79347. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  79348. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79349. * @param name defines the name of the mesh to create
  79350. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  79351. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  79352. * @param closePath creates a seam between the first and the last points of each path of the path array
  79353. * @param offset is taken in account only if the `pathArray` is containing a single path
  79354. * @param scene defines the hosting scene
  79355. * @param updatable defines if the mesh must be flagged as updatable
  79356. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79357. * @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)
  79358. * @returns a new Mesh
  79359. */
  79360. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79361. /**
  79362. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  79363. * @param name defines the name of the mesh to create
  79364. * @param radius sets the radius size (float) of the polygon (default 0.5)
  79365. * @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
  79366. * @param scene defines the hosting scene
  79367. * @param updatable defines if the mesh must be flagged as updatable
  79368. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79369. * @returns a new Mesh
  79370. */
  79371. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79372. /**
  79373. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  79374. * @param name defines the name of the mesh to create
  79375. * @param size sets the size (float) of each box side (default 1)
  79376. * @param scene defines the hosting scene
  79377. * @param updatable defines if the mesh must be flagged as updatable
  79378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79379. * @returns a new Mesh
  79380. */
  79381. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79382. /**
  79383. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  79384. * @param name defines the name of the mesh to create
  79385. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  79386. * @param diameter sets the diameter size (float) of the sphere (default 1)
  79387. * @param scene defines the hosting scene
  79388. * @param updatable defines if the mesh must be flagged as updatable
  79389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79390. * @returns a new Mesh
  79391. */
  79392. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79393. /**
  79394. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  79395. * @param name defines the name of the mesh to create
  79396. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  79397. * @param diameterTop set the top cap diameter (floats, default 1)
  79398. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  79399. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  79400. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  79401. * @param scene defines the hosting scene
  79402. * @param updatable defines if the mesh must be flagged as updatable
  79403. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79404. * @returns a new Mesh
  79405. */
  79406. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  79407. /**
  79408. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  79409. * @param name defines the name of the mesh to create
  79410. * @param diameter sets the diameter size (float) of the torus (default 1)
  79411. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  79412. * @param tessellation sets the number of torus sides (postive integer, default 16)
  79413. * @param scene defines the hosting scene
  79414. * @param updatable defines if the mesh must be flagged as updatable
  79415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79416. * @returns a new Mesh
  79417. */
  79418. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79419. /**
  79420. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  79421. * @param name defines the name of the mesh to create
  79422. * @param radius sets the global radius size (float) of the torus knot (default 2)
  79423. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  79424. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  79425. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  79426. * @param p the number of windings on X axis (positive integers, default 2)
  79427. * @param q the number of windings on Y axis (positive integers, default 3)
  79428. * @param scene defines the hosting scene
  79429. * @param updatable defines if the mesh must be flagged as updatable
  79430. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79431. * @returns a new Mesh
  79432. */
  79433. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79434. /**
  79435. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  79436. * @param name defines the name of the mesh to create
  79437. * @param points is an array successive Vector3
  79438. * @param scene defines the hosting scene
  79439. * @param updatable defines if the mesh must be flagged as updatable
  79440. * @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).
  79441. * @returns a new Mesh
  79442. */
  79443. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  79444. /**
  79445. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  79446. * @param name defines the name of the mesh to create
  79447. * @param points is an array successive Vector3
  79448. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  79449. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79450. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  79451. * @param scene defines the hosting scene
  79452. * @param updatable defines if the mesh must be flagged as updatable
  79453. * @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)
  79454. * @returns a new Mesh
  79455. */
  79456. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  79457. /**
  79458. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  79459. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  79460. * 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.
  79461. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79462. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79463. * Remember you can only change the shape positions, not their number when updating a polygon.
  79464. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  79465. * @param name defines the name of the mesh to create
  79466. * @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
  79467. * @param scene defines the hosting scene
  79468. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79469. * @param updatable defines if the mesh must be flagged as updatable
  79470. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79471. * @param earcutInjection can be used to inject your own earcut reference
  79472. * @returns a new Mesh
  79473. */
  79474. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79475. /**
  79476. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  79477. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  79478. * @param name defines the name of the mesh to create
  79479. * @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
  79480. * @param depth defines the height of extrusion
  79481. * @param scene defines the hosting scene
  79482. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79483. * @param updatable defines if the mesh must be flagged as updatable
  79484. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79485. * @param earcutInjection can be used to inject your own earcut reference
  79486. * @returns a new Mesh
  79487. */
  79488. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79489. /**
  79490. * Creates an extruded shape mesh.
  79491. * 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
  79492. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79493. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79494. * @param name defines the name of the mesh to create
  79495. * @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
  79496. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79497. * @param scale is the value to scale the shape
  79498. * @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
  79499. * @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
  79500. * @param scene defines the hosting scene
  79501. * @param updatable defines if the mesh must be flagged as updatable
  79502. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79503. * @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)
  79504. * @returns a new Mesh
  79505. */
  79506. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79507. /**
  79508. * Creates an custom extruded shape mesh.
  79509. * The custom extrusion is a parametric shape.
  79510. * It has no predefined shape. Its final shape will depend on the input parameters.
  79511. * Please consider using the same method from the MeshBuilder class instead
  79512. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79513. * @param name defines the name of the mesh to create
  79514. * @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
  79515. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79516. * @param scaleFunction is a custom Javascript function called on each path point
  79517. * @param rotationFunction is a custom Javascript function called on each path point
  79518. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79519. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  79520. * @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
  79521. * @param scene defines the hosting scene
  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 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)
  79525. * @returns a new Mesh
  79526. */
  79527. 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;
  79528. /**
  79529. * Creates lathe mesh.
  79530. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  79531. * Please consider using the same method from the MeshBuilder class instead
  79532. * @param name defines the name of the mesh to create
  79533. * @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
  79534. * @param radius is the radius value of the lathe
  79535. * @param tessellation is the side number of the lathe.
  79536. * @param scene defines the hosting scene
  79537. * @param updatable defines if the mesh must be flagged as updatable
  79538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79539. * @returns a new Mesh
  79540. */
  79541. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79542. /**
  79543. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  79544. * @param name defines the name of the mesh to create
  79545. * @param size sets the size (float) of both sides of the plane at once (default 1)
  79546. * @param scene defines the hosting scene
  79547. * @param updatable defines if the mesh must be flagged as updatable
  79548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79549. * @returns a new Mesh
  79550. */
  79551. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79552. /**
  79553. * Creates a ground mesh.
  79554. * Please consider using the same method from the MeshBuilder class instead
  79555. * @param name defines the name of the mesh to create
  79556. * @param width set the width of the ground
  79557. * @param height set the height of the ground
  79558. * @param subdivisions sets the number of subdivisions per side
  79559. * @param scene defines the hosting scene
  79560. * @param updatable defines if the mesh must be flagged as updatable
  79561. * @returns a new Mesh
  79562. */
  79563. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  79564. /**
  79565. * Creates a tiled ground mesh.
  79566. * Please consider using the same method from the MeshBuilder class instead
  79567. * @param name defines the name of the mesh to create
  79568. * @param xmin set the ground minimum X coordinate
  79569. * @param zmin set the ground minimum Y coordinate
  79570. * @param xmax set the ground maximum X coordinate
  79571. * @param zmax set the ground maximum Z coordinate
  79572. * @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
  79573. * @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
  79574. * @param scene defines the hosting scene
  79575. * @param updatable defines if the mesh must be flagged as updatable
  79576. * @returns a new Mesh
  79577. */
  79578. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  79579. w: number;
  79580. h: number;
  79581. }, precision: {
  79582. w: number;
  79583. h: number;
  79584. }, scene: Scene, updatable?: boolean): Mesh;
  79585. /**
  79586. * Creates a ground mesh from a height map.
  79587. * Please consider using the same method from the MeshBuilder class instead
  79588. * @see http://doc.babylonjs.com/babylon101/height_map
  79589. * @param name defines the name of the mesh to create
  79590. * @param url sets the URL of the height map image resource
  79591. * @param width set the ground width size
  79592. * @param height set the ground height size
  79593. * @param subdivisions sets the number of subdivision per side
  79594. * @param minHeight is the minimum altitude on the ground
  79595. * @param maxHeight is the maximum altitude on the ground
  79596. * @param scene defines the hosting scene
  79597. * @param updatable defines if the mesh must be flagged as updatable
  79598. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  79599. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  79600. * @returns a new Mesh
  79601. */
  79602. 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;
  79603. /**
  79604. * Creates a tube mesh.
  79605. * The tube is a parametric shape.
  79606. * It has no predefined shape. Its final shape will depend on the input parameters.
  79607. * Please consider using the same method from the MeshBuilder class instead
  79608. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79609. * @param name defines the name of the mesh to create
  79610. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  79611. * @param radius sets the tube radius size
  79612. * @param tessellation is the number of sides on the tubular surface
  79613. * @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
  79614. * @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
  79615. * @param scene defines the hosting scene
  79616. * @param updatable defines if the mesh must be flagged as updatable
  79617. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79618. * @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)
  79619. * @returns a new Mesh
  79620. */
  79621. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  79622. (i: number, distance: number): number;
  79623. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79624. /**
  79625. * Creates a polyhedron mesh.
  79626. * Please consider using the same method from the MeshBuilder class instead.
  79627. * * 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
  79628. * * The parameter `size` (positive float, default 1) sets the polygon size
  79629. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  79630. * * 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`
  79631. * * 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
  79632. * * 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)`)
  79633. * * 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
  79634. * * 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
  79635. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79636. * * If you create a double-sided mesh, you can choose what parts of 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
  79637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79638. * @param name defines the name of the mesh to create
  79639. * @param options defines the options used to create the mesh
  79640. * @param scene defines the hosting scene
  79641. * @returns a new Mesh
  79642. */
  79643. static CreatePolyhedron(name: string, options: {
  79644. type?: number;
  79645. size?: number;
  79646. sizeX?: number;
  79647. sizeY?: number;
  79648. sizeZ?: number;
  79649. custom?: any;
  79650. faceUV?: Vector4[];
  79651. faceColors?: Color4[];
  79652. updatable?: boolean;
  79653. sideOrientation?: number;
  79654. }, scene: Scene): Mesh;
  79655. /**
  79656. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  79657. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  79658. * * 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`)
  79659. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  79660. * * 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
  79661. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79662. * * If you create a double-sided mesh, you can choose what parts of 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
  79663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79664. * @param name defines the name of the mesh
  79665. * @param options defines the options used to create the mesh
  79666. * @param scene defines the hosting scene
  79667. * @returns a new Mesh
  79668. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  79669. */
  79670. static CreateIcoSphere(name: string, options: {
  79671. radius?: number;
  79672. flat?: boolean;
  79673. subdivisions?: number;
  79674. sideOrientation?: number;
  79675. updatable?: boolean;
  79676. }, scene: Scene): Mesh;
  79677. /**
  79678. * Creates a decal mesh.
  79679. * Please consider using the same method from the MeshBuilder class instead.
  79680. * A decal is a mesh usually applied as a model onto the surface of another mesh
  79681. * @param name defines the name of the mesh
  79682. * @param sourceMesh defines the mesh receiving the decal
  79683. * @param position sets the position of the decal in world coordinates
  79684. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  79685. * @param size sets the decal scaling
  79686. * @param angle sets the angle to rotate the decal
  79687. * @returns a new Mesh
  79688. */
  79689. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  79690. /**
  79691. * Prepare internal position array for software CPU skinning
  79692. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  79693. */
  79694. setPositionsForCPUSkinning(): Float32Array;
  79695. /**
  79696. * Prepare internal normal array for software CPU skinning
  79697. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  79698. */
  79699. setNormalsForCPUSkinning(): Float32Array;
  79700. /**
  79701. * Updates the vertex buffer by applying transformation from the bones
  79702. * @param skeleton defines the skeleton to apply to current mesh
  79703. * @returns the current mesh
  79704. */
  79705. applySkeleton(skeleton: Skeleton): Mesh;
  79706. /**
  79707. * 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
  79708. * @param meshes defines the list of meshes to scan
  79709. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  79710. */
  79711. static MinMax(meshes: AbstractMesh[]): {
  79712. min: Vector3;
  79713. max: Vector3;
  79714. };
  79715. /**
  79716. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  79717. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  79718. * @returns a vector3
  79719. */
  79720. static Center(meshesOrMinMaxVector: {
  79721. min: Vector3;
  79722. max: Vector3;
  79723. } | AbstractMesh[]): Vector3;
  79724. /**
  79725. * Merge the array of meshes into a single mesh for performance reasons.
  79726. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  79727. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  79728. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  79729. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  79730. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  79731. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  79732. * @returns a new mesh
  79733. */
  79734. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  79735. /** @hidden */
  79736. addInstance(instance: InstancedMesh): void;
  79737. /** @hidden */
  79738. removeInstance(instance: InstancedMesh): void;
  79739. }
  79740. }
  79741. declare module BABYLON {
  79742. /**
  79743. * Base class for the main features of a material in Babylon.js
  79744. */
  79745. export class Material implements IAnimatable {
  79746. /**
  79747. * Returns the triangle fill mode
  79748. */
  79749. static readonly TriangleFillMode: number;
  79750. /**
  79751. * Returns the wireframe mode
  79752. */
  79753. static readonly WireFrameFillMode: number;
  79754. /**
  79755. * Returns the point fill mode
  79756. */
  79757. static readonly PointFillMode: number;
  79758. /**
  79759. * Returns the point list draw mode
  79760. */
  79761. static readonly PointListDrawMode: number;
  79762. /**
  79763. * Returns the line list draw mode
  79764. */
  79765. static readonly LineListDrawMode: number;
  79766. /**
  79767. * Returns the line loop draw mode
  79768. */
  79769. static readonly LineLoopDrawMode: number;
  79770. /**
  79771. * Returns the line strip draw mode
  79772. */
  79773. static readonly LineStripDrawMode: number;
  79774. /**
  79775. * Returns the triangle strip draw mode
  79776. */
  79777. static readonly TriangleStripDrawMode: number;
  79778. /**
  79779. * Returns the triangle fan draw mode
  79780. */
  79781. static readonly TriangleFanDrawMode: number;
  79782. /**
  79783. * Stores the clock-wise side orientation
  79784. */
  79785. static readonly ClockWiseSideOrientation: number;
  79786. /**
  79787. * Stores the counter clock-wise side orientation
  79788. */
  79789. static readonly CounterClockWiseSideOrientation: number;
  79790. /**
  79791. * The dirty texture flag value
  79792. */
  79793. static readonly TextureDirtyFlag: number;
  79794. /**
  79795. * The dirty light flag value
  79796. */
  79797. static readonly LightDirtyFlag: number;
  79798. /**
  79799. * The dirty fresnel flag value
  79800. */
  79801. static readonly FresnelDirtyFlag: number;
  79802. /**
  79803. * The dirty attribute flag value
  79804. */
  79805. static readonly AttributesDirtyFlag: number;
  79806. /**
  79807. * The dirty misc flag value
  79808. */
  79809. static readonly MiscDirtyFlag: number;
  79810. /**
  79811. * The all dirty flag value
  79812. */
  79813. static readonly AllDirtyFlag: number;
  79814. /**
  79815. * The ID of the material
  79816. */
  79817. id: string;
  79818. /**
  79819. * Gets or sets the unique id of the material
  79820. */
  79821. uniqueId: number;
  79822. /**
  79823. * The name of the material
  79824. */
  79825. name: string;
  79826. /**
  79827. * Gets or sets user defined metadata
  79828. */
  79829. metadata: any;
  79830. /**
  79831. * For internal use only. Please do not use.
  79832. */
  79833. reservedDataStore: any;
  79834. /**
  79835. * Specifies if the ready state should be checked on each call
  79836. */
  79837. checkReadyOnEveryCall: boolean;
  79838. /**
  79839. * Specifies if the ready state should be checked once
  79840. */
  79841. checkReadyOnlyOnce: boolean;
  79842. /**
  79843. * The state of the material
  79844. */
  79845. state: string;
  79846. /**
  79847. * The alpha value of the material
  79848. */
  79849. protected _alpha: number;
  79850. /**
  79851. * List of inspectable custom properties (used by the Inspector)
  79852. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79853. */
  79854. inspectableCustomProperties: IInspectable[];
  79855. /**
  79856. * Sets the alpha value of the material
  79857. */
  79858. /**
  79859. * Gets the alpha value of the material
  79860. */
  79861. alpha: number;
  79862. /**
  79863. * Specifies if back face culling is enabled
  79864. */
  79865. protected _backFaceCulling: boolean;
  79866. /**
  79867. * Sets the back-face culling state
  79868. */
  79869. /**
  79870. * Gets the back-face culling state
  79871. */
  79872. backFaceCulling: boolean;
  79873. /**
  79874. * Stores the value for side orientation
  79875. */
  79876. sideOrientation: number;
  79877. /**
  79878. * Callback triggered when the material is compiled
  79879. */
  79880. onCompiled: (effect: Effect) => void;
  79881. /**
  79882. * Callback triggered when an error occurs
  79883. */
  79884. onError: (effect: Effect, errors: string) => void;
  79885. /**
  79886. * Callback triggered to get the render target textures
  79887. */
  79888. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  79889. /**
  79890. * Gets a boolean indicating that current material needs to register RTT
  79891. */
  79892. readonly hasRenderTargetTextures: boolean;
  79893. /**
  79894. * Specifies if the material should be serialized
  79895. */
  79896. doNotSerialize: boolean;
  79897. /**
  79898. * @hidden
  79899. */
  79900. _storeEffectOnSubMeshes: boolean;
  79901. /**
  79902. * Stores the animations for the material
  79903. */
  79904. animations: Array<Animation>;
  79905. /**
  79906. * An event triggered when the material is disposed
  79907. */
  79908. onDisposeObservable: Observable<Material>;
  79909. /**
  79910. * An observer which watches for dispose events
  79911. */
  79912. private _onDisposeObserver;
  79913. private _onUnBindObservable;
  79914. /**
  79915. * Called during a dispose event
  79916. */
  79917. onDispose: () => void;
  79918. private _onBindObservable;
  79919. /**
  79920. * An event triggered when the material is bound
  79921. */
  79922. readonly onBindObservable: Observable<AbstractMesh>;
  79923. /**
  79924. * An observer which watches for bind events
  79925. */
  79926. private _onBindObserver;
  79927. /**
  79928. * Called during a bind event
  79929. */
  79930. onBind: (Mesh: AbstractMesh) => void;
  79931. /**
  79932. * An event triggered when the material is unbound
  79933. */
  79934. readonly onUnBindObservable: Observable<Material>;
  79935. /**
  79936. * Stores the value of the alpha mode
  79937. */
  79938. private _alphaMode;
  79939. /**
  79940. * Sets the value of the alpha mode.
  79941. *
  79942. * | Value | Type | Description |
  79943. * | --- | --- | --- |
  79944. * | 0 | ALPHA_DISABLE | |
  79945. * | 1 | ALPHA_ADD | |
  79946. * | 2 | ALPHA_COMBINE | |
  79947. * | 3 | ALPHA_SUBTRACT | |
  79948. * | 4 | ALPHA_MULTIPLY | |
  79949. * | 5 | ALPHA_MAXIMIZED | |
  79950. * | 6 | ALPHA_ONEONE | |
  79951. * | 7 | ALPHA_PREMULTIPLIED | |
  79952. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  79953. * | 9 | ALPHA_INTERPOLATE | |
  79954. * | 10 | ALPHA_SCREENMODE | |
  79955. *
  79956. */
  79957. /**
  79958. * Gets the value of the alpha mode
  79959. */
  79960. alphaMode: number;
  79961. /**
  79962. * Stores the state of the need depth pre-pass value
  79963. */
  79964. private _needDepthPrePass;
  79965. /**
  79966. * Sets the need depth pre-pass value
  79967. */
  79968. /**
  79969. * Gets the depth pre-pass value
  79970. */
  79971. needDepthPrePass: boolean;
  79972. /**
  79973. * Specifies if depth writing should be disabled
  79974. */
  79975. disableDepthWrite: boolean;
  79976. /**
  79977. * Specifies if depth writing should be forced
  79978. */
  79979. forceDepthWrite: boolean;
  79980. /**
  79981. * Specifies if there should be a separate pass for culling
  79982. */
  79983. separateCullingPass: boolean;
  79984. /**
  79985. * Stores the state specifing if fog should be enabled
  79986. */
  79987. private _fogEnabled;
  79988. /**
  79989. * Sets the state for enabling fog
  79990. */
  79991. /**
  79992. * Gets the value of the fog enabled state
  79993. */
  79994. fogEnabled: boolean;
  79995. /**
  79996. * Stores the size of points
  79997. */
  79998. pointSize: number;
  79999. /**
  80000. * Stores the z offset value
  80001. */
  80002. zOffset: number;
  80003. /**
  80004. * Gets a value specifying if wireframe mode is enabled
  80005. */
  80006. /**
  80007. * Sets the state of wireframe mode
  80008. */
  80009. wireframe: boolean;
  80010. /**
  80011. * Gets the value specifying if point clouds are enabled
  80012. */
  80013. /**
  80014. * Sets the state of point cloud mode
  80015. */
  80016. pointsCloud: boolean;
  80017. /**
  80018. * Gets the material fill mode
  80019. */
  80020. /**
  80021. * Sets the material fill mode
  80022. */
  80023. fillMode: number;
  80024. /**
  80025. * @hidden
  80026. * Stores the effects for the material
  80027. */
  80028. _effect: Nullable<Effect>;
  80029. /**
  80030. * @hidden
  80031. * Specifies if the material was previously ready
  80032. */
  80033. _wasPreviouslyReady: boolean;
  80034. /**
  80035. * Specifies if uniform buffers should be used
  80036. */
  80037. private _useUBO;
  80038. /**
  80039. * Stores a reference to the scene
  80040. */
  80041. private _scene;
  80042. /**
  80043. * Stores the fill mode state
  80044. */
  80045. private _fillMode;
  80046. /**
  80047. * Specifies if the depth write state should be cached
  80048. */
  80049. private _cachedDepthWriteState;
  80050. /**
  80051. * Stores the uniform buffer
  80052. */
  80053. protected _uniformBuffer: UniformBuffer;
  80054. /** @hidden */
  80055. _indexInSceneMaterialArray: number;
  80056. /** @hidden */
  80057. meshMap: Nullable<{
  80058. [id: string]: AbstractMesh | undefined;
  80059. }>;
  80060. /**
  80061. * Creates a material instance
  80062. * @param name defines the name of the material
  80063. * @param scene defines the scene to reference
  80064. * @param doNotAdd specifies if the material should be added to the scene
  80065. */
  80066. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80067. /**
  80068. * Returns a string representation of the current material
  80069. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80070. * @returns a string with material information
  80071. */
  80072. toString(fullDetails?: boolean): string;
  80073. /**
  80074. * Gets the class name of the material
  80075. * @returns a string with the class name of the material
  80076. */
  80077. getClassName(): string;
  80078. /**
  80079. * Specifies if updates for the material been locked
  80080. */
  80081. readonly isFrozen: boolean;
  80082. /**
  80083. * Locks updates for the material
  80084. */
  80085. freeze(): void;
  80086. /**
  80087. * Unlocks updates for the material
  80088. */
  80089. unfreeze(): void;
  80090. /**
  80091. * Specifies if the material is ready to be used
  80092. * @param mesh defines the mesh to check
  80093. * @param useInstances specifies if instances should be used
  80094. * @returns a boolean indicating if the material is ready to be used
  80095. */
  80096. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80097. /**
  80098. * Specifies that the submesh is ready to be used
  80099. * @param mesh defines the mesh to check
  80100. * @param subMesh defines which submesh to check
  80101. * @param useInstances specifies that instances should be used
  80102. * @returns a boolean indicating that the submesh is ready or not
  80103. */
  80104. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80105. /**
  80106. * Returns the material effect
  80107. * @returns the effect associated with the material
  80108. */
  80109. getEffect(): Nullable<Effect>;
  80110. /**
  80111. * Returns the current scene
  80112. * @returns a Scene
  80113. */
  80114. getScene(): Scene;
  80115. /**
  80116. * Specifies if the material will require alpha blending
  80117. * @returns a boolean specifying if alpha blending is needed
  80118. */
  80119. needAlphaBlending(): boolean;
  80120. /**
  80121. * Specifies if the mesh will require alpha blending
  80122. * @param mesh defines the mesh to check
  80123. * @returns a boolean specifying if alpha blending is needed for the mesh
  80124. */
  80125. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  80126. /**
  80127. * Specifies if this material should be rendered in alpha test mode
  80128. * @returns a boolean specifying if an alpha test is needed.
  80129. */
  80130. needAlphaTesting(): boolean;
  80131. /**
  80132. * Gets the texture used for the alpha test
  80133. * @returns the texture to use for alpha testing
  80134. */
  80135. getAlphaTestTexture(): Nullable<BaseTexture>;
  80136. /**
  80137. * Marks the material to indicate that it needs to be re-calculated
  80138. */
  80139. markDirty(): void;
  80140. /** @hidden */
  80141. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  80142. /**
  80143. * Binds the material to the mesh
  80144. * @param world defines the world transformation matrix
  80145. * @param mesh defines the mesh to bind the material to
  80146. */
  80147. bind(world: Matrix, mesh?: Mesh): void;
  80148. /**
  80149. * Binds the submesh to the material
  80150. * @param world defines the world transformation matrix
  80151. * @param mesh defines the mesh containing the submesh
  80152. * @param subMesh defines the submesh to bind the material to
  80153. */
  80154. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  80155. /**
  80156. * Binds the world matrix to the material
  80157. * @param world defines the world transformation matrix
  80158. */
  80159. bindOnlyWorldMatrix(world: Matrix): void;
  80160. /**
  80161. * Binds the scene's uniform buffer to the effect.
  80162. * @param effect defines the effect to bind to the scene uniform buffer
  80163. * @param sceneUbo defines the uniform buffer storing scene data
  80164. */
  80165. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  80166. /**
  80167. * Binds the view matrix to the effect
  80168. * @param effect defines the effect to bind the view matrix to
  80169. */
  80170. bindView(effect: Effect): void;
  80171. /**
  80172. * Binds the view projection matrix to the effect
  80173. * @param effect defines the effect to bind the view projection matrix to
  80174. */
  80175. bindViewProjection(effect: Effect): void;
  80176. /**
  80177. * Specifies if material alpha testing should be turned on for the mesh
  80178. * @param mesh defines the mesh to check
  80179. */
  80180. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  80181. /**
  80182. * Processes to execute after binding the material to a mesh
  80183. * @param mesh defines the rendered mesh
  80184. */
  80185. protected _afterBind(mesh?: Mesh): void;
  80186. /**
  80187. * Unbinds the material from the mesh
  80188. */
  80189. unbind(): void;
  80190. /**
  80191. * Gets the active textures from the material
  80192. * @returns an array of textures
  80193. */
  80194. getActiveTextures(): BaseTexture[];
  80195. /**
  80196. * Specifies if the material uses a texture
  80197. * @param texture defines the texture to check against the material
  80198. * @returns a boolean specifying if the material uses the texture
  80199. */
  80200. hasTexture(texture: BaseTexture): boolean;
  80201. /**
  80202. * Makes a duplicate of the material, and gives it a new name
  80203. * @param name defines the new name for the duplicated material
  80204. * @returns the cloned material
  80205. */
  80206. clone(name: string): Nullable<Material>;
  80207. /**
  80208. * Gets the meshes bound to the material
  80209. * @returns an array of meshes bound to the material
  80210. */
  80211. getBindedMeshes(): AbstractMesh[];
  80212. /**
  80213. * Force shader compilation
  80214. * @param mesh defines the mesh associated with this material
  80215. * @param onCompiled defines a function to execute once the material is compiled
  80216. * @param options defines the options to configure the compilation
  80217. */
  80218. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  80219. clipPlane: boolean;
  80220. }>): void;
  80221. /**
  80222. * Force shader compilation
  80223. * @param mesh defines the mesh that will use this material
  80224. * @param options defines additional options for compiling the shaders
  80225. * @returns a promise that resolves when the compilation completes
  80226. */
  80227. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  80228. clipPlane: boolean;
  80229. }>): Promise<void>;
  80230. private static readonly _ImageProcessingDirtyCallBack;
  80231. private static readonly _TextureDirtyCallBack;
  80232. private static readonly _FresnelDirtyCallBack;
  80233. private static readonly _MiscDirtyCallBack;
  80234. private static readonly _LightsDirtyCallBack;
  80235. private static readonly _AttributeDirtyCallBack;
  80236. private static _FresnelAndMiscDirtyCallBack;
  80237. private static _TextureAndMiscDirtyCallBack;
  80238. private static readonly _DirtyCallbackArray;
  80239. private static readonly _RunDirtyCallBacks;
  80240. /**
  80241. * Marks a define in the material to indicate that it needs to be re-computed
  80242. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  80243. */
  80244. markAsDirty(flag: number): void;
  80245. /**
  80246. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  80247. * @param func defines a function which checks material defines against the submeshes
  80248. */
  80249. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  80250. /**
  80251. * Indicates that image processing needs to be re-calculated for all submeshes
  80252. */
  80253. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  80254. /**
  80255. * Indicates that textures need to be re-calculated for all submeshes
  80256. */
  80257. protected _markAllSubMeshesAsTexturesDirty(): void;
  80258. /**
  80259. * Indicates that fresnel needs to be re-calculated for all submeshes
  80260. */
  80261. protected _markAllSubMeshesAsFresnelDirty(): void;
  80262. /**
  80263. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  80264. */
  80265. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  80266. /**
  80267. * Indicates that lights need to be re-calculated for all submeshes
  80268. */
  80269. protected _markAllSubMeshesAsLightsDirty(): void;
  80270. /**
  80271. * Indicates that attributes need to be re-calculated for all submeshes
  80272. */
  80273. protected _markAllSubMeshesAsAttributesDirty(): void;
  80274. /**
  80275. * Indicates that misc needs to be re-calculated for all submeshes
  80276. */
  80277. protected _markAllSubMeshesAsMiscDirty(): void;
  80278. /**
  80279. * Indicates that textures and misc need to be re-calculated for all submeshes
  80280. */
  80281. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  80282. /**
  80283. * Disposes the material
  80284. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80285. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  80286. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  80287. */
  80288. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  80289. /** @hidden */
  80290. private releaseVertexArrayObject;
  80291. /**
  80292. * Serializes this material
  80293. * @returns the serialized material object
  80294. */
  80295. serialize(): any;
  80296. /**
  80297. * Creates a material from parsed material data
  80298. * @param parsedMaterial defines parsed material data
  80299. * @param scene defines the hosting scene
  80300. * @param rootUrl defines the root URL to use to load textures
  80301. * @returns a new material
  80302. */
  80303. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  80304. }
  80305. }
  80306. declare module BABYLON {
  80307. /**
  80308. * Base class for submeshes
  80309. */
  80310. export class BaseSubMesh {
  80311. /** @hidden */
  80312. _materialDefines: Nullable<MaterialDefines>;
  80313. /** @hidden */
  80314. _materialEffect: Nullable<Effect>;
  80315. /**
  80316. * Gets associated effect
  80317. */
  80318. readonly effect: Nullable<Effect>;
  80319. /**
  80320. * Sets associated effect (effect used to render this submesh)
  80321. * @param effect defines the effect to associate with
  80322. * @param defines defines the set of defines used to compile this effect
  80323. */
  80324. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  80325. }
  80326. /**
  80327. * Defines a subdivision inside a mesh
  80328. */
  80329. export class SubMesh extends BaseSubMesh implements ICullable {
  80330. /** the material index to use */
  80331. materialIndex: number;
  80332. /** vertex index start */
  80333. verticesStart: number;
  80334. /** vertices count */
  80335. verticesCount: number;
  80336. /** index start */
  80337. indexStart: number;
  80338. /** indices count */
  80339. indexCount: number;
  80340. /** @hidden */
  80341. _linesIndexCount: number;
  80342. private _mesh;
  80343. private _renderingMesh;
  80344. private _boundingInfo;
  80345. private _linesIndexBuffer;
  80346. /** @hidden */
  80347. _lastColliderWorldVertices: Nullable<Vector3[]>;
  80348. /** @hidden */
  80349. _trianglePlanes: Plane[];
  80350. /** @hidden */
  80351. _lastColliderTransformMatrix: Matrix;
  80352. /** @hidden */
  80353. _renderId: number;
  80354. /** @hidden */
  80355. _alphaIndex: number;
  80356. /** @hidden */
  80357. _distanceToCamera: number;
  80358. /** @hidden */
  80359. _id: number;
  80360. private _currentMaterial;
  80361. /**
  80362. * Add a new submesh to a mesh
  80363. * @param materialIndex defines the material index to use
  80364. * @param verticesStart defines vertex index start
  80365. * @param verticesCount defines vertices count
  80366. * @param indexStart defines index start
  80367. * @param indexCount defines indices count
  80368. * @param mesh defines the parent mesh
  80369. * @param renderingMesh defines an optional rendering mesh
  80370. * @param createBoundingBox defines if bounding box should be created for this submesh
  80371. * @returns the new submesh
  80372. */
  80373. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  80374. /**
  80375. * Creates a new submesh
  80376. * @param materialIndex defines the material index to use
  80377. * @param verticesStart defines vertex index start
  80378. * @param verticesCount defines vertices count
  80379. * @param indexStart defines index start
  80380. * @param indexCount defines indices count
  80381. * @param mesh defines the parent mesh
  80382. * @param renderingMesh defines an optional rendering mesh
  80383. * @param createBoundingBox defines if bounding box should be created for this submesh
  80384. */
  80385. constructor(
  80386. /** the material index to use */
  80387. materialIndex: number,
  80388. /** vertex index start */
  80389. verticesStart: number,
  80390. /** vertices count */
  80391. verticesCount: number,
  80392. /** index start */
  80393. indexStart: number,
  80394. /** indices count */
  80395. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  80396. /**
  80397. * Returns true if this submesh covers the entire parent mesh
  80398. * @ignorenaming
  80399. */
  80400. readonly IsGlobal: boolean;
  80401. /**
  80402. * Returns the submesh BoudingInfo object
  80403. * @returns current bounding info (or mesh's one if the submesh is global)
  80404. */
  80405. getBoundingInfo(): BoundingInfo;
  80406. /**
  80407. * Sets the submesh BoundingInfo
  80408. * @param boundingInfo defines the new bounding info to use
  80409. * @returns the SubMesh
  80410. */
  80411. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  80412. /**
  80413. * Returns the mesh of the current submesh
  80414. * @return the parent mesh
  80415. */
  80416. getMesh(): AbstractMesh;
  80417. /**
  80418. * Returns the rendering mesh of the submesh
  80419. * @returns the rendering mesh (could be different from parent mesh)
  80420. */
  80421. getRenderingMesh(): Mesh;
  80422. /**
  80423. * Returns the submesh material
  80424. * @returns null or the current material
  80425. */
  80426. getMaterial(): Nullable<Material>;
  80427. /**
  80428. * Sets a new updated BoundingInfo object to the submesh
  80429. * @returns the SubMesh
  80430. */
  80431. refreshBoundingInfo(): SubMesh;
  80432. /** @hidden */
  80433. _checkCollision(collider: Collider): boolean;
  80434. /**
  80435. * Updates the submesh BoundingInfo
  80436. * @param world defines the world matrix to use to update the bounding info
  80437. * @returns the submesh
  80438. */
  80439. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  80440. /**
  80441. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  80442. * @param frustumPlanes defines the frustum planes
  80443. * @returns true if the submesh is intersecting with the frustum
  80444. */
  80445. isInFrustum(frustumPlanes: Plane[]): boolean;
  80446. /**
  80447. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  80448. * @param frustumPlanes defines the frustum planes
  80449. * @returns true if the submesh is inside the frustum
  80450. */
  80451. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80452. /**
  80453. * Renders the submesh
  80454. * @param enableAlphaMode defines if alpha needs to be used
  80455. * @returns the submesh
  80456. */
  80457. render(enableAlphaMode: boolean): SubMesh;
  80458. /**
  80459. * @hidden
  80460. */
  80461. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  80462. /**
  80463. * Checks if the submesh intersects with a ray
  80464. * @param ray defines the ray to test
  80465. * @returns true is the passed ray intersects the submesh bounding box
  80466. */
  80467. canIntersects(ray: Ray): boolean;
  80468. /**
  80469. * Intersects current submesh with a ray
  80470. * @param ray defines the ray to test
  80471. * @param positions defines mesh's positions array
  80472. * @param indices defines mesh's indices array
  80473. * @param fastCheck defines if only bounding info should be used
  80474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  80475. * @returns intersection info or null if no intersection
  80476. */
  80477. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  80478. /** @hidden */
  80479. private _intersectLines;
  80480. /** @hidden */
  80481. private _intersectTriangles;
  80482. /** @hidden */
  80483. _rebuild(): void;
  80484. /**
  80485. * Creates a new submesh from the passed mesh
  80486. * @param newMesh defines the new hosting mesh
  80487. * @param newRenderingMesh defines an optional rendering mesh
  80488. * @returns the new submesh
  80489. */
  80490. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  80491. /**
  80492. * Release associated resources
  80493. */
  80494. dispose(): void;
  80495. /**
  80496. * Gets the class name
  80497. * @returns the string "SubMesh".
  80498. */
  80499. getClassName(): string;
  80500. /**
  80501. * Creates a new submesh from indices data
  80502. * @param materialIndex the index of the main mesh material
  80503. * @param startIndex the index where to start the copy in the mesh indices array
  80504. * @param indexCount the number of indices to copy then from the startIndex
  80505. * @param mesh the main mesh to create the submesh from
  80506. * @param renderingMesh the optional rendering mesh
  80507. * @returns a new submesh
  80508. */
  80509. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  80510. }
  80511. }
  80512. declare module BABYLON {
  80513. /**
  80514. * Class used to store geometry data (vertex buffers + index buffer)
  80515. */
  80516. export class Geometry implements IGetSetVerticesData {
  80517. /**
  80518. * Gets or sets the ID of the geometry
  80519. */
  80520. id: string;
  80521. /**
  80522. * Gets or sets the unique ID of the geometry
  80523. */
  80524. uniqueId: number;
  80525. /**
  80526. * Gets the delay loading state of the geometry (none by default which means not delayed)
  80527. */
  80528. delayLoadState: number;
  80529. /**
  80530. * Gets the file containing the data to load when running in delay load state
  80531. */
  80532. delayLoadingFile: Nullable<string>;
  80533. /**
  80534. * Callback called when the geometry is updated
  80535. */
  80536. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  80537. private _scene;
  80538. private _engine;
  80539. private _meshes;
  80540. private _totalVertices;
  80541. /** @hidden */
  80542. _indices: IndicesArray;
  80543. /** @hidden */
  80544. _vertexBuffers: {
  80545. [key: string]: VertexBuffer;
  80546. };
  80547. private _isDisposed;
  80548. private _extend;
  80549. private _boundingBias;
  80550. /** @hidden */
  80551. _delayInfo: Array<string>;
  80552. private _indexBuffer;
  80553. private _indexBufferIsUpdatable;
  80554. /** @hidden */
  80555. _boundingInfo: Nullable<BoundingInfo>;
  80556. /** @hidden */
  80557. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  80558. /** @hidden */
  80559. _softwareSkinningFrameId: number;
  80560. private _vertexArrayObjects;
  80561. private _updatable;
  80562. /** @hidden */
  80563. _positions: Nullable<Vector3[]>;
  80564. /**
  80565. * 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
  80566. */
  80567. /**
  80568. * 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
  80569. */
  80570. boundingBias: Vector2;
  80571. /**
  80572. * Static function used to attach a new empty geometry to a mesh
  80573. * @param mesh defines the mesh to attach the geometry to
  80574. * @returns the new Geometry
  80575. */
  80576. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  80577. /**
  80578. * Creates a new geometry
  80579. * @param id defines the unique ID
  80580. * @param scene defines the hosting scene
  80581. * @param vertexData defines the VertexData used to get geometry data
  80582. * @param updatable defines if geometry must be updatable (false by default)
  80583. * @param mesh defines the mesh that will be associated with the geometry
  80584. */
  80585. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  80586. /**
  80587. * Gets the current extend of the geometry
  80588. */
  80589. readonly extend: {
  80590. minimum: Vector3;
  80591. maximum: Vector3;
  80592. };
  80593. /**
  80594. * Gets the hosting scene
  80595. * @returns the hosting Scene
  80596. */
  80597. getScene(): Scene;
  80598. /**
  80599. * Gets the hosting engine
  80600. * @returns the hosting Engine
  80601. */
  80602. getEngine(): Engine;
  80603. /**
  80604. * Defines if the geometry is ready to use
  80605. * @returns true if the geometry is ready to be used
  80606. */
  80607. isReady(): boolean;
  80608. /**
  80609. * Gets a value indicating that the geometry should not be serialized
  80610. */
  80611. readonly doNotSerialize: boolean;
  80612. /** @hidden */
  80613. _rebuild(): void;
  80614. /**
  80615. * Affects all geometry data in one call
  80616. * @param vertexData defines the geometry data
  80617. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  80618. */
  80619. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  80620. /**
  80621. * Set specific vertex data
  80622. * @param kind defines the data kind (Position, normal, etc...)
  80623. * @param data defines the vertex data to use
  80624. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80625. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80626. */
  80627. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  80628. /**
  80629. * Removes a specific vertex data
  80630. * @param kind defines the data kind (Position, normal, etc...)
  80631. */
  80632. removeVerticesData(kind: string): void;
  80633. /**
  80634. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  80635. * @param buffer defines the vertex buffer to use
  80636. * @param totalVertices defines the total number of vertices for position kind (could be null)
  80637. */
  80638. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  80639. /**
  80640. * Update a specific vertex buffer
  80641. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  80642. * It will do nothing if the buffer is not updatable
  80643. * @param kind defines the data kind (Position, normal, etc...)
  80644. * @param data defines the data to use
  80645. * @param offset defines the offset in the target buffer where to store the data
  80646. * @param useBytes set to true if the offset is in bytes
  80647. */
  80648. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  80649. /**
  80650. * Update a specific vertex buffer
  80651. * This function will create a new buffer if the current one is not updatable
  80652. * @param kind defines the data kind (Position, normal, etc...)
  80653. * @param data defines the data to use
  80654. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  80655. */
  80656. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  80657. private _updateBoundingInfo;
  80658. /** @hidden */
  80659. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  80660. /**
  80661. * Gets total number of vertices
  80662. * @returns the total number of vertices
  80663. */
  80664. getTotalVertices(): number;
  80665. /**
  80666. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80667. * @param kind defines the data kind (Position, normal, etc...)
  80668. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80669. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80670. * @returns a float array containing vertex data
  80671. */
  80672. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80673. /**
  80674. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  80675. * @param kind defines the data kind (Position, normal, etc...)
  80676. * @returns true if the vertex buffer with the specified kind is updatable
  80677. */
  80678. isVertexBufferUpdatable(kind: string): boolean;
  80679. /**
  80680. * Gets a specific vertex buffer
  80681. * @param kind defines the data kind (Position, normal, etc...)
  80682. * @returns a VertexBuffer
  80683. */
  80684. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80685. /**
  80686. * Returns all vertex buffers
  80687. * @return an object holding all vertex buffers indexed by kind
  80688. */
  80689. getVertexBuffers(): Nullable<{
  80690. [key: string]: VertexBuffer;
  80691. }>;
  80692. /**
  80693. * Gets a boolean indicating if specific vertex buffer is present
  80694. * @param kind defines the data kind (Position, normal, etc...)
  80695. * @returns true if data is present
  80696. */
  80697. isVerticesDataPresent(kind: string): boolean;
  80698. /**
  80699. * Gets a list of all attached data kinds (Position, normal, etc...)
  80700. * @returns a list of string containing all kinds
  80701. */
  80702. getVerticesDataKinds(): string[];
  80703. /**
  80704. * Update index buffer
  80705. * @param indices defines the indices to store in the index buffer
  80706. * @param offset defines the offset in the target buffer where to store the data
  80707. * @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)
  80708. */
  80709. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  80710. /**
  80711. * Creates a new index buffer
  80712. * @param indices defines the indices to store in the index buffer
  80713. * @param totalVertices defines the total number of vertices (could be null)
  80714. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80715. */
  80716. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  80717. /**
  80718. * Return the total number of indices
  80719. * @returns the total number of indices
  80720. */
  80721. getTotalIndices(): number;
  80722. /**
  80723. * Gets the index buffer array
  80724. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80725. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80726. * @returns the index buffer array
  80727. */
  80728. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80729. /**
  80730. * Gets the index buffer
  80731. * @return the index buffer
  80732. */
  80733. getIndexBuffer(): Nullable<WebGLBuffer>;
  80734. /** @hidden */
  80735. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  80736. /**
  80737. * Release the associated resources for a specific mesh
  80738. * @param mesh defines the source mesh
  80739. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  80740. */
  80741. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  80742. /**
  80743. * Apply current geometry to a given mesh
  80744. * @param mesh defines the mesh to apply geometry to
  80745. */
  80746. applyToMesh(mesh: Mesh): void;
  80747. private _updateExtend;
  80748. private _applyToMesh;
  80749. private notifyUpdate;
  80750. /**
  80751. * Load the geometry if it was flagged as delay loaded
  80752. * @param scene defines the hosting scene
  80753. * @param onLoaded defines a callback called when the geometry is loaded
  80754. */
  80755. load(scene: Scene, onLoaded?: () => void): void;
  80756. private _queueLoad;
  80757. /**
  80758. * Invert the geometry to move from a right handed system to a left handed one.
  80759. */
  80760. toLeftHanded(): void;
  80761. /** @hidden */
  80762. _resetPointsArrayCache(): void;
  80763. /** @hidden */
  80764. _generatePointsArray(): boolean;
  80765. /**
  80766. * Gets a value indicating if the geometry is disposed
  80767. * @returns true if the geometry was disposed
  80768. */
  80769. isDisposed(): boolean;
  80770. private _disposeVertexArrayObjects;
  80771. /**
  80772. * Free all associated resources
  80773. */
  80774. dispose(): void;
  80775. /**
  80776. * Clone the current geometry into a new geometry
  80777. * @param id defines the unique ID of the new geometry
  80778. * @returns a new geometry object
  80779. */
  80780. copy(id: string): Geometry;
  80781. /**
  80782. * Serialize the current geometry info (and not the vertices data) into a JSON object
  80783. * @return a JSON representation of the current geometry data (without the vertices data)
  80784. */
  80785. serialize(): any;
  80786. private toNumberArray;
  80787. /**
  80788. * Serialize all vertices data into a JSON oject
  80789. * @returns a JSON representation of the current geometry data
  80790. */
  80791. serializeVerticeData(): any;
  80792. /**
  80793. * Extracts a clone of a mesh geometry
  80794. * @param mesh defines the source mesh
  80795. * @param id defines the unique ID of the new geometry object
  80796. * @returns the new geometry object
  80797. */
  80798. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  80799. /**
  80800. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  80801. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  80802. * Be aware Math.random() could cause collisions, but:
  80803. * "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"
  80804. * @returns a string containing a new GUID
  80805. */
  80806. static RandomId(): string;
  80807. /** @hidden */
  80808. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  80809. private static _CleanMatricesWeights;
  80810. /**
  80811. * Create a new geometry from persisted data (Using .babylon file format)
  80812. * @param parsedVertexData defines the persisted data
  80813. * @param scene defines the hosting scene
  80814. * @param rootUrl defines the root url to use to load assets (like delayed data)
  80815. * @returns the new geometry object
  80816. */
  80817. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  80818. }
  80819. }
  80820. declare module BABYLON {
  80821. /**
  80822. * Define an interface for all classes that will get and set the data on vertices
  80823. */
  80824. export interface IGetSetVerticesData {
  80825. /**
  80826. * Gets a boolean indicating if specific vertex data is present
  80827. * @param kind defines the vertex data kind to use
  80828. * @returns true is data kind is present
  80829. */
  80830. isVerticesDataPresent(kind: string): boolean;
  80831. /**
  80832. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80833. * @param kind defines the data kind (Position, normal, etc...)
  80834. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80835. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80836. * @returns a float array containing vertex data
  80837. */
  80838. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80839. /**
  80840. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80841. * @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.
  80842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80843. * @returns the indices array or an empty array if the mesh has no geometry
  80844. */
  80845. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80846. /**
  80847. * Set specific vertex data
  80848. * @param kind defines the data kind (Position, normal, etc...)
  80849. * @param data defines the vertex data to use
  80850. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80851. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80852. */
  80853. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  80854. /**
  80855. * Update a specific associated vertex buffer
  80856. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80857. * - VertexBuffer.PositionKind
  80858. * - VertexBuffer.UVKind
  80859. * - VertexBuffer.UV2Kind
  80860. * - VertexBuffer.UV3Kind
  80861. * - VertexBuffer.UV4Kind
  80862. * - VertexBuffer.UV5Kind
  80863. * - VertexBuffer.UV6Kind
  80864. * - VertexBuffer.ColorKind
  80865. * - VertexBuffer.MatricesIndicesKind
  80866. * - VertexBuffer.MatricesIndicesExtraKind
  80867. * - VertexBuffer.MatricesWeightsKind
  80868. * - VertexBuffer.MatricesWeightsExtraKind
  80869. * @param data defines the data source
  80870. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80871. * @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)
  80872. */
  80873. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  80874. /**
  80875. * Creates a new index buffer
  80876. * @param indices defines the indices to store in the index buffer
  80877. * @param totalVertices defines the total number of vertices (could be null)
  80878. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80879. */
  80880. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  80881. }
  80882. /**
  80883. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  80884. */
  80885. export class VertexData {
  80886. /**
  80887. * Mesh side orientation : usually the external or front surface
  80888. */
  80889. static readonly FRONTSIDE: number;
  80890. /**
  80891. * Mesh side orientation : usually the internal or back surface
  80892. */
  80893. static readonly BACKSIDE: number;
  80894. /**
  80895. * Mesh side orientation : both internal and external or front and back surfaces
  80896. */
  80897. static readonly DOUBLESIDE: number;
  80898. /**
  80899. * Mesh side orientation : by default, `FRONTSIDE`
  80900. */
  80901. static readonly DEFAULTSIDE: number;
  80902. /**
  80903. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  80904. */
  80905. positions: Nullable<FloatArray>;
  80906. /**
  80907. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  80908. */
  80909. normals: Nullable<FloatArray>;
  80910. /**
  80911. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  80912. */
  80913. tangents: Nullable<FloatArray>;
  80914. /**
  80915. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80916. */
  80917. uvs: Nullable<FloatArray>;
  80918. /**
  80919. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80920. */
  80921. uvs2: Nullable<FloatArray>;
  80922. /**
  80923. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80924. */
  80925. uvs3: Nullable<FloatArray>;
  80926. /**
  80927. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80928. */
  80929. uvs4: Nullable<FloatArray>;
  80930. /**
  80931. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80932. */
  80933. uvs5: Nullable<FloatArray>;
  80934. /**
  80935. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80936. */
  80937. uvs6: Nullable<FloatArray>;
  80938. /**
  80939. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  80940. */
  80941. colors: Nullable<FloatArray>;
  80942. /**
  80943. * 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).
  80944. */
  80945. matricesIndices: Nullable<FloatArray>;
  80946. /**
  80947. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  80948. */
  80949. matricesWeights: Nullable<FloatArray>;
  80950. /**
  80951. * An array extending the number of possible indices
  80952. */
  80953. matricesIndicesExtra: Nullable<FloatArray>;
  80954. /**
  80955. * An array extending the number of possible weights when the number of indices is extended
  80956. */
  80957. matricesWeightsExtra: Nullable<FloatArray>;
  80958. /**
  80959. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  80960. */
  80961. indices: Nullable<IndicesArray>;
  80962. /**
  80963. * Uses the passed data array to set the set the values for the specified kind of data
  80964. * @param data a linear array of floating numbers
  80965. * @param kind the type of data that is being set, eg positions, colors etc
  80966. */
  80967. set(data: FloatArray, kind: string): void;
  80968. /**
  80969. * Associates the vertexData to the passed Mesh.
  80970. * Sets it as updatable or not (default `false`)
  80971. * @param mesh the mesh the vertexData is applied to
  80972. * @param updatable when used and having the value true allows new data to update the vertexData
  80973. * @returns the VertexData
  80974. */
  80975. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  80976. /**
  80977. * Associates the vertexData to the passed Geometry.
  80978. * Sets it as updatable or not (default `false`)
  80979. * @param geometry the geometry the vertexData is applied to
  80980. * @param updatable when used and having the value true allows new data to update the vertexData
  80981. * @returns VertexData
  80982. */
  80983. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  80984. /**
  80985. * Updates the associated mesh
  80986. * @param mesh the mesh to be updated
  80987. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80988. * @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
  80989. * @returns VertexData
  80990. */
  80991. updateMesh(mesh: Mesh): VertexData;
  80992. /**
  80993. * Updates the associated geometry
  80994. * @param geometry the geometry to be updated
  80995. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80996. * @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
  80997. * @returns VertexData.
  80998. */
  80999. updateGeometry(geometry: Geometry): VertexData;
  81000. private _applyTo;
  81001. private _update;
  81002. /**
  81003. * Transforms each position and each normal of the vertexData according to the passed Matrix
  81004. * @param matrix the transforming matrix
  81005. * @returns the VertexData
  81006. */
  81007. transform(matrix: Matrix): VertexData;
  81008. /**
  81009. * Merges the passed VertexData into the current one
  81010. * @param other the VertexData to be merged into the current one
  81011. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  81012. * @returns the modified VertexData
  81013. */
  81014. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  81015. private _mergeElement;
  81016. private _validate;
  81017. /**
  81018. * Serializes the VertexData
  81019. * @returns a serialized object
  81020. */
  81021. serialize(): any;
  81022. /**
  81023. * Extracts the vertexData from a mesh
  81024. * @param mesh the mesh from which to extract the VertexData
  81025. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  81026. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81027. * @returns the object VertexData associated to the passed mesh
  81028. */
  81029. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81030. /**
  81031. * Extracts the vertexData from the geometry
  81032. * @param geometry the geometry from which to extract the VertexData
  81033. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  81034. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81035. * @returns the object VertexData associated to the passed mesh
  81036. */
  81037. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81038. private static _ExtractFrom;
  81039. /**
  81040. * Creates the VertexData for a Ribbon
  81041. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  81042. * * pathArray array of paths, each of which an array of successive Vector3
  81043. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  81044. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  81045. * * 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
  81046. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81047. * * 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)
  81048. * * 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)
  81049. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  81050. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  81051. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  81052. * @returns the VertexData of the ribbon
  81053. */
  81054. static CreateRibbon(options: {
  81055. pathArray: Vector3[][];
  81056. closeArray?: boolean;
  81057. closePath?: boolean;
  81058. offset?: number;
  81059. sideOrientation?: number;
  81060. frontUVs?: Vector4;
  81061. backUVs?: Vector4;
  81062. invertUV?: boolean;
  81063. uvs?: Vector2[];
  81064. colors?: Color4[];
  81065. }): VertexData;
  81066. /**
  81067. * Creates the VertexData for a box
  81068. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81069. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81070. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81071. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81072. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81073. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81074. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81076. * * 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)
  81077. * * 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)
  81078. * @returns the VertexData of the box
  81079. */
  81080. static CreateBox(options: {
  81081. size?: number;
  81082. width?: number;
  81083. height?: number;
  81084. depth?: number;
  81085. faceUV?: Vector4[];
  81086. faceColors?: Color4[];
  81087. sideOrientation?: number;
  81088. frontUVs?: Vector4;
  81089. backUVs?: Vector4;
  81090. }): VertexData;
  81091. /**
  81092. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81094. * * segments sets the number of horizontal strips optional, default 32
  81095. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81096. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81097. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81098. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81099. * * 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
  81100. * * 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
  81101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81102. * * 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)
  81103. * * 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)
  81104. * @returns the VertexData of the ellipsoid
  81105. */
  81106. static CreateSphere(options: {
  81107. segments?: number;
  81108. diameter?: number;
  81109. diameterX?: number;
  81110. diameterY?: number;
  81111. diameterZ?: number;
  81112. arc?: number;
  81113. slice?: number;
  81114. sideOrientation?: number;
  81115. frontUVs?: Vector4;
  81116. backUVs?: Vector4;
  81117. }): VertexData;
  81118. /**
  81119. * Creates the VertexData for a cylinder, cone or prism
  81120. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81121. * * height sets the height (y direction) of the cylinder, optional, default 2
  81122. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  81123. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  81124. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  81125. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81126. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  81127. * * 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
  81128. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81129. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81130. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  81131. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  81132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81133. * * 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)
  81134. * * 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)
  81135. * @returns the VertexData of the cylinder, cone or prism
  81136. */
  81137. static CreateCylinder(options: {
  81138. height?: number;
  81139. diameterTop?: number;
  81140. diameterBottom?: number;
  81141. diameter?: number;
  81142. tessellation?: number;
  81143. subdivisions?: number;
  81144. arc?: number;
  81145. faceColors?: Color4[];
  81146. faceUV?: Vector4[];
  81147. hasRings?: boolean;
  81148. enclose?: boolean;
  81149. sideOrientation?: number;
  81150. frontUVs?: Vector4;
  81151. backUVs?: Vector4;
  81152. }): VertexData;
  81153. /**
  81154. * Creates the VertexData for a torus
  81155. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81156. * * diameter the diameter of the torus, optional default 1
  81157. * * thickness the diameter of the tube forming the torus, optional default 0.5
  81158. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81160. * * 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)
  81161. * * 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)
  81162. * @returns the VertexData of the torus
  81163. */
  81164. static CreateTorus(options: {
  81165. diameter?: number;
  81166. thickness?: number;
  81167. tessellation?: number;
  81168. sideOrientation?: number;
  81169. frontUVs?: Vector4;
  81170. backUVs?: Vector4;
  81171. }): VertexData;
  81172. /**
  81173. * Creates the VertexData of the LineSystem
  81174. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  81175. * - lines an array of lines, each line being an array of successive Vector3
  81176. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  81177. * @returns the VertexData of the LineSystem
  81178. */
  81179. static CreateLineSystem(options: {
  81180. lines: Vector3[][];
  81181. colors?: Nullable<Color4[][]>;
  81182. }): VertexData;
  81183. /**
  81184. * Create the VertexData for a DashedLines
  81185. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  81186. * - points an array successive Vector3
  81187. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  81188. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  81189. * - dashNb the intended total number of dashes, optional, default 200
  81190. * @returns the VertexData for the DashedLines
  81191. */
  81192. static CreateDashedLines(options: {
  81193. points: Vector3[];
  81194. dashSize?: number;
  81195. gapSize?: number;
  81196. dashNb?: number;
  81197. }): VertexData;
  81198. /**
  81199. * Creates the VertexData for a Ground
  81200. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81201. * - width the width (x direction) of the ground, optional, default 1
  81202. * - height the height (z direction) of the ground, optional, default 1
  81203. * - subdivisions the number of subdivisions per side, optional, default 1
  81204. * @returns the VertexData of the Ground
  81205. */
  81206. static CreateGround(options: {
  81207. width?: number;
  81208. height?: number;
  81209. subdivisions?: number;
  81210. subdivisionsX?: number;
  81211. subdivisionsY?: number;
  81212. }): VertexData;
  81213. /**
  81214. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  81215. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81216. * * xmin the ground minimum X coordinate, optional, default -1
  81217. * * zmin the ground minimum Z coordinate, optional, default -1
  81218. * * xmax the ground maximum X coordinate, optional, default 1
  81219. * * zmax the ground maximum Z coordinate, optional, default 1
  81220. * * 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}
  81221. * * 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}
  81222. * @returns the VertexData of the TiledGround
  81223. */
  81224. static CreateTiledGround(options: {
  81225. xmin: number;
  81226. zmin: number;
  81227. xmax: number;
  81228. zmax: number;
  81229. subdivisions?: {
  81230. w: number;
  81231. h: number;
  81232. };
  81233. precision?: {
  81234. w: number;
  81235. h: number;
  81236. };
  81237. }): VertexData;
  81238. /**
  81239. * Creates the VertexData of the Ground designed from a heightmap
  81240. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  81241. * * width the width (x direction) of the ground
  81242. * * height the height (z direction) of the ground
  81243. * * subdivisions the number of subdivisions per side
  81244. * * minHeight the minimum altitude on the ground, optional, default 0
  81245. * * maxHeight the maximum altitude on the ground, optional default 1
  81246. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  81247. * * buffer the array holding the image color data
  81248. * * bufferWidth the width of image
  81249. * * bufferHeight the height of image
  81250. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  81251. * @returns the VertexData of the Ground designed from a heightmap
  81252. */
  81253. static CreateGroundFromHeightMap(options: {
  81254. width: number;
  81255. height: number;
  81256. subdivisions: number;
  81257. minHeight: number;
  81258. maxHeight: number;
  81259. colorFilter: Color3;
  81260. buffer: Uint8Array;
  81261. bufferWidth: number;
  81262. bufferHeight: number;
  81263. alphaFilter: number;
  81264. }): VertexData;
  81265. /**
  81266. * Creates the VertexData for a Plane
  81267. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  81268. * * size sets the width and height of the plane to the value of size, optional default 1
  81269. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  81270. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  81271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81272. * * 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)
  81273. * * 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)
  81274. * @returns the VertexData of the box
  81275. */
  81276. static CreatePlane(options: {
  81277. size?: number;
  81278. width?: number;
  81279. height?: number;
  81280. sideOrientation?: number;
  81281. frontUVs?: Vector4;
  81282. backUVs?: Vector4;
  81283. }): VertexData;
  81284. /**
  81285. * Creates the VertexData of the Disc or regular Polygon
  81286. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  81287. * * radius the radius of the disc, optional default 0.5
  81288. * * tessellation the number of polygon sides, optional, default 64
  81289. * * 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
  81290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81291. * * 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)
  81292. * * 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)
  81293. * @returns the VertexData of the box
  81294. */
  81295. static CreateDisc(options: {
  81296. radius?: number;
  81297. tessellation?: number;
  81298. arc?: number;
  81299. sideOrientation?: number;
  81300. frontUVs?: Vector4;
  81301. backUVs?: Vector4;
  81302. }): VertexData;
  81303. /**
  81304. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  81305. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  81306. * @param polygon a mesh built from polygonTriangulation.build()
  81307. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81308. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81309. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81310. * @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)
  81311. * @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)
  81312. * @returns the VertexData of the Polygon
  81313. */
  81314. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  81315. /**
  81316. * Creates the VertexData of the IcoSphere
  81317. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  81318. * * radius the radius of the IcoSphere, optional default 1
  81319. * * radiusX allows stretching in the x direction, optional, default radius
  81320. * * radiusY allows stretching in the y direction, optional, default radius
  81321. * * radiusZ allows stretching in the z direction, optional, default radius
  81322. * * flat when true creates a flat shaded mesh, optional, default true
  81323. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 IcoSphere
  81328. */
  81329. static CreateIcoSphere(options: {
  81330. radius?: number;
  81331. radiusX?: number;
  81332. radiusY?: number;
  81333. radiusZ?: number;
  81334. flat?: boolean;
  81335. subdivisions?: number;
  81336. sideOrientation?: number;
  81337. frontUVs?: Vector4;
  81338. backUVs?: Vector4;
  81339. }): VertexData;
  81340. /**
  81341. * Creates the VertexData for a Polyhedron
  81342. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  81343. * * type provided types are:
  81344. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  81345. * * 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)
  81346. * * size the size of the IcoSphere, optional default 1
  81347. * * sizeX allows stretching in the x direction, optional, default size
  81348. * * sizeY allows stretching in the y direction, optional, default size
  81349. * * sizeZ allows stretching in the z direction, optional, default size
  81350. * * 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
  81351. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81352. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81353. * * flat when true creates a flat shaded mesh, optional, default true
  81354. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81356. * * 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)
  81357. * * 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)
  81358. * @returns the VertexData of the Polyhedron
  81359. */
  81360. static CreatePolyhedron(options: {
  81361. type?: number;
  81362. size?: number;
  81363. sizeX?: number;
  81364. sizeY?: number;
  81365. sizeZ?: number;
  81366. custom?: any;
  81367. faceUV?: Vector4[];
  81368. faceColors?: Color4[];
  81369. flat?: boolean;
  81370. sideOrientation?: number;
  81371. frontUVs?: Vector4;
  81372. backUVs?: Vector4;
  81373. }): VertexData;
  81374. /**
  81375. * Creates the VertexData for a TorusKnot
  81376. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  81377. * * radius the radius of the torus knot, optional, default 2
  81378. * * tube the thickness of the tube, optional, default 0.5
  81379. * * radialSegments the number of sides on each tube segments, optional, default 32
  81380. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  81381. * * p the number of windings around the z axis, optional, default 2
  81382. * * q the number of windings around the x axis, optional, default 3
  81383. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81384. * * 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)
  81385. * * 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)
  81386. * @returns the VertexData of the Torus Knot
  81387. */
  81388. static CreateTorusKnot(options: {
  81389. radius?: number;
  81390. tube?: number;
  81391. radialSegments?: number;
  81392. tubularSegments?: number;
  81393. p?: number;
  81394. q?: number;
  81395. sideOrientation?: number;
  81396. frontUVs?: Vector4;
  81397. backUVs?: Vector4;
  81398. }): VertexData;
  81399. /**
  81400. * Compute normals for given positions and indices
  81401. * @param positions an array of vertex positions, [...., x, y, z, ......]
  81402. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  81403. * @param normals an array of vertex normals, [...., x, y, z, ......]
  81404. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  81405. * * facetNormals : optional array of facet normals (vector3)
  81406. * * facetPositions : optional array of facet positions (vector3)
  81407. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  81408. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  81409. * * bInfo : optional bounding info, required for facetPartitioning computation
  81410. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  81411. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  81412. * * useRightHandedSystem: optional boolean to for right handed system computation
  81413. * * depthSort : optional boolean to enable the facet depth sort computation
  81414. * * distanceTo : optional Vector3 to compute the facet depth from this location
  81415. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  81416. */
  81417. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  81418. facetNormals?: any;
  81419. facetPositions?: any;
  81420. facetPartitioning?: any;
  81421. ratio?: number;
  81422. bInfo?: any;
  81423. bbSize?: Vector3;
  81424. subDiv?: any;
  81425. useRightHandedSystem?: boolean;
  81426. depthSort?: boolean;
  81427. distanceTo?: Vector3;
  81428. depthSortedFacets?: any;
  81429. }): void;
  81430. /** @hidden */
  81431. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  81432. /**
  81433. * Applies VertexData created from the imported parameters to the geometry
  81434. * @param parsedVertexData the parsed data from an imported file
  81435. * @param geometry the geometry to apply the VertexData to
  81436. */
  81437. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  81438. }
  81439. }
  81440. declare module BABYLON {
  81441. /**
  81442. * Class containing static functions to help procedurally build meshes
  81443. */
  81444. export class DiscBuilder {
  81445. /**
  81446. * Creates a plane polygonal mesh. By default, this is a disc
  81447. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  81448. * * 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
  81449. * * 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
  81450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81453. * @param name defines the name of the mesh
  81454. * @param options defines the options used to create the mesh
  81455. * @param scene defines the hosting scene
  81456. * @returns the plane polygonal mesh
  81457. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  81458. */
  81459. static CreateDisc(name: string, options: {
  81460. radius?: number;
  81461. tessellation?: number;
  81462. arc?: number;
  81463. updatable?: boolean;
  81464. sideOrientation?: number;
  81465. frontUVs?: Vector4;
  81466. backUVs?: Vector4;
  81467. }, scene?: Nullable<Scene>): Mesh;
  81468. }
  81469. }
  81470. declare module BABYLON {
  81471. /**
  81472. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  81473. *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.
  81474. * The SPS is also a particle system. It provides some methods to manage the particles.
  81475. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  81476. *
  81477. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  81478. */
  81479. export class SolidParticleSystem implements IDisposable {
  81480. /**
  81481. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  81482. * Example : var p = SPS.particles[i];
  81483. */
  81484. particles: SolidParticle[];
  81485. /**
  81486. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  81487. */
  81488. nbParticles: number;
  81489. /**
  81490. * If the particles must ever face the camera (default false). Useful for planar particles.
  81491. */
  81492. billboard: boolean;
  81493. /**
  81494. * Recompute normals when adding a shape
  81495. */
  81496. recomputeNormals: boolean;
  81497. /**
  81498. * This a counter ofr your own usage. It's not set by any SPS functions.
  81499. */
  81500. counter: number;
  81501. /**
  81502. * The SPS name. This name is also given to the underlying mesh.
  81503. */
  81504. name: string;
  81505. /**
  81506. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  81507. */
  81508. mesh: Mesh;
  81509. /**
  81510. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  81511. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  81512. */
  81513. vars: any;
  81514. /**
  81515. * This array is populated when the SPS is set as 'pickable'.
  81516. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  81517. * Each element of this array is an object `{idx: int, faceId: int}`.
  81518. * `idx` is the picked particle index in the `SPS.particles` array
  81519. * `faceId` is the picked face index counted within this particle.
  81520. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  81521. */
  81522. pickedParticles: {
  81523. idx: number;
  81524. faceId: number;
  81525. }[];
  81526. /**
  81527. * This array is populated when `enableDepthSort` is set to true.
  81528. * Each element of this array is an instance of the class DepthSortedParticle.
  81529. */
  81530. depthSortedParticles: DepthSortedParticle[];
  81531. /**
  81532. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  81533. * @hidden
  81534. */
  81535. _bSphereOnly: boolean;
  81536. /**
  81537. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  81538. * @hidden
  81539. */
  81540. _bSphereRadiusFactor: number;
  81541. private _scene;
  81542. private _positions;
  81543. private _indices;
  81544. private _normals;
  81545. private _colors;
  81546. private _uvs;
  81547. private _indices32;
  81548. private _positions32;
  81549. private _normals32;
  81550. private _fixedNormal32;
  81551. private _colors32;
  81552. private _uvs32;
  81553. private _index;
  81554. private _updatable;
  81555. private _pickable;
  81556. private _isVisibilityBoxLocked;
  81557. private _alwaysVisible;
  81558. private _depthSort;
  81559. private _shapeCounter;
  81560. private _copy;
  81561. private _color;
  81562. private _computeParticleColor;
  81563. private _computeParticleTexture;
  81564. private _computeParticleRotation;
  81565. private _computeParticleVertex;
  81566. private _computeBoundingBox;
  81567. private _depthSortParticles;
  81568. private _camera;
  81569. private _mustUnrotateFixedNormals;
  81570. private _particlesIntersect;
  81571. private _needs32Bits;
  81572. /**
  81573. * Creates a SPS (Solid Particle System) object.
  81574. * @param name (String) is the SPS name, this will be the underlying mesh name.
  81575. * @param scene (Scene) is the scene in which the SPS is added.
  81576. * @param options defines the options of the sps e.g.
  81577. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  81578. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  81579. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  81580. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  81581. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  81582. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  81583. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  81584. */
  81585. constructor(name: string, scene: Scene, options?: {
  81586. updatable?: boolean;
  81587. isPickable?: boolean;
  81588. enableDepthSort?: boolean;
  81589. particleIntersection?: boolean;
  81590. boundingSphereOnly?: boolean;
  81591. bSphereRadiusFactor?: number;
  81592. });
  81593. /**
  81594. * Builds the SPS underlying mesh. Returns a standard Mesh.
  81595. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  81596. * @returns the created mesh
  81597. */
  81598. buildMesh(): Mesh;
  81599. /**
  81600. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  81601. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  81602. * Thus the particles generated from `digest()` have their property `position` set yet.
  81603. * @param mesh ( Mesh ) is the mesh to be digested
  81604. * @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
  81605. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  81606. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  81607. * @returns the current SPS
  81608. */
  81609. digest(mesh: Mesh, options?: {
  81610. facetNb?: number;
  81611. number?: number;
  81612. delta?: number;
  81613. }): SolidParticleSystem;
  81614. private _unrotateFixedNormals;
  81615. private _resetCopy;
  81616. private _meshBuilder;
  81617. private _posToShape;
  81618. private _uvsToShapeUV;
  81619. private _addParticle;
  81620. /**
  81621. * Adds some particles to the SPS from the model shape. Returns the shape id.
  81622. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  81623. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  81624. * @param nb (positive integer) the number of particles to be created from this model
  81625. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  81626. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  81627. * @returns the number of shapes in the system
  81628. */
  81629. addShape(mesh: Mesh, nb: number, options?: {
  81630. positionFunction?: any;
  81631. vertexFunction?: any;
  81632. }): number;
  81633. private _rebuildParticle;
  81634. /**
  81635. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  81636. * @returns the SPS.
  81637. */
  81638. rebuildMesh(): SolidParticleSystem;
  81639. /**
  81640. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  81641. * This method calls `updateParticle()` for each particle of the SPS.
  81642. * For an animated SPS, it is usually called within the render loop.
  81643. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  81644. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  81645. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  81646. * @returns the SPS.
  81647. */
  81648. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  81649. /**
  81650. * Disposes the SPS.
  81651. */
  81652. dispose(): void;
  81653. /**
  81654. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  81655. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81656. * @returns the SPS.
  81657. */
  81658. refreshVisibleSize(): SolidParticleSystem;
  81659. /**
  81660. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  81661. * @param size the size (float) of the visibility box
  81662. * note : this doesn't lock the SPS mesh bounding box.
  81663. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81664. */
  81665. setVisibilityBox(size: number): void;
  81666. /**
  81667. * Gets whether the SPS as always visible or not
  81668. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81669. */
  81670. /**
  81671. * Sets the SPS as always visible or not
  81672. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81673. */
  81674. isAlwaysVisible: boolean;
  81675. /**
  81676. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81677. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81678. */
  81679. /**
  81680. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81681. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81682. */
  81683. isVisibilityBoxLocked: boolean;
  81684. /**
  81685. * Tells to `setParticles()` to compute the particle rotations or not.
  81686. * Default value : true. The SPS is faster when it's set to false.
  81687. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81688. */
  81689. /**
  81690. * Gets if `setParticles()` computes the particle rotations or not.
  81691. * Default value : true. The SPS is faster when it's set to false.
  81692. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81693. */
  81694. computeParticleRotation: boolean;
  81695. /**
  81696. * Tells to `setParticles()` to compute the particle colors or not.
  81697. * Default value : true. The SPS is faster when it's set to false.
  81698. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81699. */
  81700. /**
  81701. * Gets if `setParticles()` computes the particle colors or not.
  81702. * Default value : true. The SPS is faster when it's set to false.
  81703. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81704. */
  81705. computeParticleColor: boolean;
  81706. /**
  81707. * Gets if `setParticles()` computes the particle textures or not.
  81708. * Default value : true. The SPS is faster when it's set to false.
  81709. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  81710. */
  81711. computeParticleTexture: boolean;
  81712. /**
  81713. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  81714. * Default value : false. The SPS is faster when it's set to false.
  81715. * Note : the particle custom vertex positions aren't stored values.
  81716. */
  81717. /**
  81718. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  81719. * Default value : false. The SPS is faster when it's set to false.
  81720. * Note : the particle custom vertex positions aren't stored values.
  81721. */
  81722. computeParticleVertex: boolean;
  81723. /**
  81724. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  81725. */
  81726. /**
  81727. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  81728. */
  81729. computeBoundingBox: boolean;
  81730. /**
  81731. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  81732. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81733. * Default : `true`
  81734. */
  81735. /**
  81736. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  81737. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81738. * Default : `true`
  81739. */
  81740. depthSortParticles: boolean;
  81741. /**
  81742. * This function does nothing. It may be overwritten to set all the particle first values.
  81743. * The SPS doesn't call this function, you may have to call it by your own.
  81744. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81745. */
  81746. initParticles(): void;
  81747. /**
  81748. * This function does nothing. It may be overwritten to recycle a particle.
  81749. * The SPS doesn't call this function, you may have to call it by your own.
  81750. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81751. * @param particle The particle to recycle
  81752. * @returns the recycled particle
  81753. */
  81754. recycleParticle(particle: SolidParticle): SolidParticle;
  81755. /**
  81756. * Updates a particle : this function should be overwritten by the user.
  81757. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  81758. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81759. * @example : just set a particle position or velocity and recycle conditions
  81760. * @param particle The particle to update
  81761. * @returns the updated particle
  81762. */
  81763. updateParticle(particle: SolidParticle): SolidParticle;
  81764. /**
  81765. * Updates a vertex of a particle : it can be overwritten by the user.
  81766. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  81767. * @param particle the current particle
  81768. * @param vertex the current index of the current particle
  81769. * @param pt the index of the current vertex in the particle shape
  81770. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  81771. * @example : just set a vertex particle position
  81772. * @returns the updated vertex
  81773. */
  81774. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  81775. /**
  81776. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  81777. * This does nothing and may be overwritten by the user.
  81778. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81779. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81780. * @param update the boolean update value actually passed to setParticles()
  81781. */
  81782. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81783. /**
  81784. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  81785. * This will be passed three parameters.
  81786. * This does nothing and may be overwritten by the user.
  81787. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81788. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81789. * @param update the boolean update value actually passed to setParticles()
  81790. */
  81791. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81792. }
  81793. }
  81794. declare module BABYLON {
  81795. /**
  81796. * Represents one particle of a solid particle system.
  81797. */
  81798. export class SolidParticle {
  81799. /**
  81800. * particle global index
  81801. */
  81802. idx: number;
  81803. /**
  81804. * The color of the particle
  81805. */
  81806. color: Nullable<Color4>;
  81807. /**
  81808. * The world space position of the particle.
  81809. */
  81810. position: Vector3;
  81811. /**
  81812. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  81813. */
  81814. rotation: Vector3;
  81815. /**
  81816. * The world space rotation quaternion of the particle.
  81817. */
  81818. rotationQuaternion: Nullable<Quaternion>;
  81819. /**
  81820. * The scaling of the particle.
  81821. */
  81822. scaling: Vector3;
  81823. /**
  81824. * The uvs of the particle.
  81825. */
  81826. uvs: Vector4;
  81827. /**
  81828. * The current speed of the particle.
  81829. */
  81830. velocity: Vector3;
  81831. /**
  81832. * The pivot point in the particle local space.
  81833. */
  81834. pivot: Vector3;
  81835. /**
  81836. * Must the particle be translated from its pivot point in its local space ?
  81837. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  81838. * Default : false
  81839. */
  81840. translateFromPivot: boolean;
  81841. /**
  81842. * Is the particle active or not ?
  81843. */
  81844. alive: boolean;
  81845. /**
  81846. * Is the particle visible or not ?
  81847. */
  81848. isVisible: boolean;
  81849. /**
  81850. * Index of this particle in the global "positions" array (Internal use)
  81851. * @hidden
  81852. */
  81853. _pos: number;
  81854. /**
  81855. * @hidden Index of this particle in the global "indices" array (Internal use)
  81856. */
  81857. _ind: number;
  81858. /**
  81859. * @hidden ModelShape of this particle (Internal use)
  81860. */
  81861. _model: ModelShape;
  81862. /**
  81863. * ModelShape id of this particle
  81864. */
  81865. shapeId: number;
  81866. /**
  81867. * Index of the particle in its shape id (Internal use)
  81868. */
  81869. idxInShape: number;
  81870. /**
  81871. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  81872. */
  81873. _modelBoundingInfo: BoundingInfo;
  81874. /**
  81875. * @hidden Particle BoundingInfo object (Internal use)
  81876. */
  81877. _boundingInfo: BoundingInfo;
  81878. /**
  81879. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  81880. */
  81881. _sps: SolidParticleSystem;
  81882. /**
  81883. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  81884. */
  81885. _stillInvisible: boolean;
  81886. /**
  81887. * @hidden Last computed particle rotation matrix
  81888. */
  81889. _rotationMatrix: number[];
  81890. /**
  81891. * Parent particle Id, if any.
  81892. * Default null.
  81893. */
  81894. parentId: Nullable<number>;
  81895. /**
  81896. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  81897. * The possible values are :
  81898. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81899. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81900. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81901. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81902. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81903. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  81904. * */
  81905. cullingStrategy: number;
  81906. /**
  81907. * @hidden Internal global position in the SPS.
  81908. */
  81909. _globalPosition: Vector3;
  81910. /**
  81911. * Creates a Solid Particle object.
  81912. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  81913. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  81914. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  81915. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  81916. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  81917. * @param shapeId (integer) is the model shape identifier in the SPS.
  81918. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  81919. * @param sps defines the sps it is associated to
  81920. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  81921. */
  81922. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  81923. /**
  81924. * Legacy support, changed scale to scaling
  81925. */
  81926. /**
  81927. * Legacy support, changed scale to scaling
  81928. */
  81929. scale: Vector3;
  81930. /**
  81931. * Legacy support, changed quaternion to rotationQuaternion
  81932. */
  81933. /**
  81934. * Legacy support, changed quaternion to rotationQuaternion
  81935. */
  81936. quaternion: Nullable<Quaternion>;
  81937. /**
  81938. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  81939. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  81940. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  81941. * @returns true if it intersects
  81942. */
  81943. intersectsMesh(target: Mesh | SolidParticle): boolean;
  81944. /**
  81945. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  81946. * A particle is in the frustum if its bounding box intersects the frustum
  81947. * @param frustumPlanes defines the frustum to test
  81948. * @returns true if the particle is in the frustum planes
  81949. */
  81950. isInFrustum(frustumPlanes: Plane[]): boolean;
  81951. /**
  81952. * get the rotation matrix of the particle
  81953. * @hidden
  81954. */
  81955. getRotationMatrix(m: Matrix): void;
  81956. }
  81957. /**
  81958. * Represents the shape of the model used by one particle of a solid particle system.
  81959. * SPS internal tool, don't use it manually.
  81960. */
  81961. export class ModelShape {
  81962. /**
  81963. * The shape id
  81964. * @hidden
  81965. */
  81966. shapeID: number;
  81967. /**
  81968. * flat array of model positions (internal use)
  81969. * @hidden
  81970. */
  81971. _shape: Vector3[];
  81972. /**
  81973. * flat array of model UVs (internal use)
  81974. * @hidden
  81975. */
  81976. _shapeUV: number[];
  81977. /**
  81978. * length of the shape in the model indices array (internal use)
  81979. * @hidden
  81980. */
  81981. _indicesLength: number;
  81982. /**
  81983. * Custom position function (internal use)
  81984. * @hidden
  81985. */
  81986. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  81987. /**
  81988. * Custom vertex function (internal use)
  81989. * @hidden
  81990. */
  81991. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  81992. /**
  81993. * 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.
  81994. * SPS internal tool, don't use it manually.
  81995. * @hidden
  81996. */
  81997. 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>);
  81998. }
  81999. /**
  82000. * Represents a Depth Sorted Particle in the solid particle system.
  82001. */
  82002. export class DepthSortedParticle {
  82003. /**
  82004. * Index of the particle in the "indices" array
  82005. */
  82006. ind: number;
  82007. /**
  82008. * Length of the particle shape in the "indices" array
  82009. */
  82010. indicesLength: number;
  82011. /**
  82012. * Squared distance from the particle to the camera
  82013. */
  82014. sqDistance: number;
  82015. }
  82016. }
  82017. declare module BABYLON {
  82018. /**
  82019. * Class used to store all common mesh properties
  82020. */
  82021. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  82022. /** No occlusion */
  82023. static OCCLUSION_TYPE_NONE: number;
  82024. /** Occlusion set to optimisitic */
  82025. static OCCLUSION_TYPE_OPTIMISTIC: number;
  82026. /** Occlusion set to strict */
  82027. static OCCLUSION_TYPE_STRICT: number;
  82028. /** Use an accurante occlusion algorithm */
  82029. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  82030. /** Use a conservative occlusion algorithm */
  82031. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  82032. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82033. * Test order :
  82034. * Is the bounding sphere outside the frustum ?
  82035. * If not, are the bounding box vertices outside the frustum ?
  82036. * It not, then the cullable object is in the frustum.
  82037. */
  82038. static readonly CULLINGSTRATEGY_STANDARD: number;
  82039. /** Culling strategy : Bounding Sphere Only.
  82040. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82041. * It's also less accurate than the standard because some not visible objects can still be selected.
  82042. * Test : is the bounding sphere outside the frustum ?
  82043. * If not, then the cullable object is in the frustum.
  82044. */
  82045. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82046. /** Culling strategy : Optimistic Inclusion.
  82047. * This in an inclusion test first, then the standard exclusion test.
  82048. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82049. * 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.
  82050. * Anyway, it's as accurate as the standard strategy.
  82051. * Test :
  82052. * Is the cullable object bounding sphere center in the frustum ?
  82053. * If not, apply the default culling strategy.
  82054. */
  82055. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82056. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82057. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82058. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82059. * 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.
  82060. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82061. * Test :
  82062. * Is the cullable object bounding sphere center in the frustum ?
  82063. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82064. */
  82065. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82066. /**
  82067. * No billboard
  82068. */
  82069. static readonly BILLBOARDMODE_NONE: number;
  82070. /** Billboard on X axis */
  82071. static readonly BILLBOARDMODE_X: number;
  82072. /** Billboard on Y axis */
  82073. static readonly BILLBOARDMODE_Y: number;
  82074. /** Billboard on Z axis */
  82075. static readonly BILLBOARDMODE_Z: number;
  82076. /** Billboard on all axes */
  82077. static readonly BILLBOARDMODE_ALL: number;
  82078. private _facetData;
  82079. /**
  82080. * The culling strategy to use to check whether the mesh must be rendered or not.
  82081. * This value can be changed at any time and will be used on the next render mesh selection.
  82082. * The possible values are :
  82083. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82084. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82085. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82086. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82087. * Please read each static variable documentation to get details about the culling process.
  82088. * */
  82089. cullingStrategy: number;
  82090. /**
  82091. * Gets the number of facets in the mesh
  82092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82093. */
  82094. readonly facetNb: number;
  82095. /**
  82096. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82097. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82098. */
  82099. partitioningSubdivisions: number;
  82100. /**
  82101. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82102. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82104. */
  82105. partitioningBBoxRatio: number;
  82106. /**
  82107. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82108. * Works only for updatable meshes.
  82109. * Doesn't work with multi-materials
  82110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82111. */
  82112. mustDepthSortFacets: boolean;
  82113. /**
  82114. * The location (Vector3) where the facet depth sort must be computed from.
  82115. * By default, the active camera position.
  82116. * Used only when facet depth sort is enabled
  82117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82118. */
  82119. facetDepthSortFrom: Vector3;
  82120. /**
  82121. * gets a boolean indicating if facetData is enabled
  82122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82123. */
  82124. readonly isFacetDataEnabled: boolean;
  82125. /** @hidden */
  82126. _updateNonUniformScalingState(value: boolean): boolean;
  82127. /**
  82128. * An event triggered when this mesh collides with another one
  82129. */
  82130. onCollideObservable: Observable<AbstractMesh>;
  82131. private _onCollideObserver;
  82132. /** Set a function to call when this mesh collides with another one */
  82133. onCollide: () => void;
  82134. /**
  82135. * An event triggered when the collision's position changes
  82136. */
  82137. onCollisionPositionChangeObservable: Observable<Vector3>;
  82138. private _onCollisionPositionChangeObserver;
  82139. /** Set a function to call when the collision's position changes */
  82140. onCollisionPositionChange: () => void;
  82141. /**
  82142. * An event triggered when material is changed
  82143. */
  82144. onMaterialChangedObservable: Observable<AbstractMesh>;
  82145. /**
  82146. * Gets or sets the orientation for POV movement & rotation
  82147. */
  82148. definedFacingForward: boolean;
  82149. /** @hidden */
  82150. _occlusionQuery: Nullable<WebGLQuery>;
  82151. private _visibility;
  82152. /**
  82153. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82154. */
  82155. /**
  82156. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82157. */
  82158. visibility: number;
  82159. /** Gets or sets the alpha index used to sort transparent meshes
  82160. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  82161. */
  82162. alphaIndex: number;
  82163. /**
  82164. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  82165. */
  82166. isVisible: boolean;
  82167. /**
  82168. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82169. */
  82170. isPickable: boolean;
  82171. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  82172. showSubMeshesBoundingBox: boolean;
  82173. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  82174. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  82175. */
  82176. isBlocker: boolean;
  82177. /**
  82178. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  82179. */
  82180. enablePointerMoveEvents: boolean;
  82181. /**
  82182. * Specifies the rendering group id for this mesh (0 by default)
  82183. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82184. */
  82185. renderingGroupId: number;
  82186. private _material;
  82187. /** Gets or sets current material */
  82188. material: Nullable<Material>;
  82189. private _receiveShadows;
  82190. /**
  82191. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82192. * @see http://doc.babylonjs.com/babylon101/shadows
  82193. */
  82194. receiveShadows: boolean;
  82195. /** Defines color to use when rendering outline */
  82196. outlineColor: Color3;
  82197. /** Define width to use when rendering outline */
  82198. outlineWidth: number;
  82199. /** Defines color to use when rendering overlay */
  82200. overlayColor: Color3;
  82201. /** Defines alpha to use when rendering overlay */
  82202. overlayAlpha: number;
  82203. private _hasVertexAlpha;
  82204. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82205. hasVertexAlpha: boolean;
  82206. private _useVertexColors;
  82207. /** 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) */
  82208. useVertexColors: boolean;
  82209. private _computeBonesUsingShaders;
  82210. /**
  82211. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82212. */
  82213. computeBonesUsingShaders: boolean;
  82214. private _numBoneInfluencers;
  82215. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82216. numBoneInfluencers: number;
  82217. private _applyFog;
  82218. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82219. applyFog: boolean;
  82220. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  82221. useOctreeForRenderingSelection: boolean;
  82222. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  82223. useOctreeForPicking: boolean;
  82224. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  82225. useOctreeForCollisions: boolean;
  82226. private _layerMask;
  82227. /**
  82228. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82229. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82230. */
  82231. layerMask: number;
  82232. /**
  82233. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  82234. */
  82235. alwaysSelectAsActiveMesh: boolean;
  82236. /**
  82237. * Gets or sets the current action manager
  82238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82239. */
  82240. actionManager: Nullable<AbstractActionManager>;
  82241. private _checkCollisions;
  82242. private _collisionMask;
  82243. private _collisionGroup;
  82244. /**
  82245. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  82246. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82247. */
  82248. ellipsoid: Vector3;
  82249. /**
  82250. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  82251. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82252. */
  82253. ellipsoidOffset: Vector3;
  82254. private _collider;
  82255. private _oldPositionForCollisions;
  82256. private _diffPositionForCollisions;
  82257. /**
  82258. * Gets or sets a collision mask used to mask collisions (default is -1).
  82259. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82260. */
  82261. collisionMask: number;
  82262. /**
  82263. * Gets or sets the current collision group mask (-1 by default).
  82264. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82265. */
  82266. collisionGroup: number;
  82267. /**
  82268. * Defines edge width used when edgesRenderer is enabled
  82269. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82270. */
  82271. edgesWidth: number;
  82272. /**
  82273. * Defines edge color used when edgesRenderer is enabled
  82274. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82275. */
  82276. edgesColor: Color4;
  82277. /** @hidden */
  82278. _edgesRenderer: Nullable<IEdgesRenderer>;
  82279. /** @hidden */
  82280. _masterMesh: Nullable<AbstractMesh>;
  82281. /** @hidden */
  82282. _boundingInfo: Nullable<BoundingInfo>;
  82283. /** @hidden */
  82284. _renderId: number;
  82285. /**
  82286. * Gets or sets the list of subMeshes
  82287. * @see http://doc.babylonjs.com/how_to/multi_materials
  82288. */
  82289. subMeshes: SubMesh[];
  82290. /** @hidden */
  82291. _intersectionsInProgress: AbstractMesh[];
  82292. /** @hidden */
  82293. _unIndexed: boolean;
  82294. /** @hidden */
  82295. _lightSources: Light[];
  82296. /** @hidden */
  82297. readonly _positions: Nullable<Vector3[]>;
  82298. /** @hidden */
  82299. _waitingActions: any;
  82300. /** @hidden */
  82301. _waitingFreezeWorldMatrix: Nullable<boolean>;
  82302. private _skeleton;
  82303. /** @hidden */
  82304. _bonesTransformMatrices: Nullable<Float32Array>;
  82305. /**
  82306. * Gets or sets a skeleton to apply skining transformations
  82307. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82308. */
  82309. skeleton: Nullable<Skeleton>;
  82310. /**
  82311. * An event triggered when the mesh is rebuilt.
  82312. */
  82313. onRebuildObservable: Observable<AbstractMesh>;
  82314. /**
  82315. * Creates a new AbstractMesh
  82316. * @param name defines the name of the mesh
  82317. * @param scene defines the hosting scene
  82318. */
  82319. constructor(name: string, scene?: Nullable<Scene>);
  82320. /**
  82321. * Returns the string "AbstractMesh"
  82322. * @returns "AbstractMesh"
  82323. */
  82324. getClassName(): string;
  82325. /**
  82326. * Gets a string representation of the current mesh
  82327. * @param fullDetails defines a boolean indicating if full details must be included
  82328. * @returns a string representation of the current mesh
  82329. */
  82330. toString(fullDetails?: boolean): string;
  82331. /** @hidden */
  82332. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82333. /** @hidden */
  82334. _rebuild(): void;
  82335. /** @hidden */
  82336. _resyncLightSources(): void;
  82337. /** @hidden */
  82338. _resyncLighSource(light: Light): void;
  82339. /** @hidden */
  82340. _unBindEffect(): void;
  82341. /** @hidden */
  82342. _removeLightSource(light: Light): void;
  82343. private _markSubMeshesAsDirty;
  82344. /** @hidden */
  82345. _markSubMeshesAsLightDirty(): void;
  82346. /** @hidden */
  82347. _markSubMeshesAsAttributesDirty(): void;
  82348. /** @hidden */
  82349. _markSubMeshesAsMiscDirty(): void;
  82350. /**
  82351. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82352. */
  82353. scaling: Vector3;
  82354. /**
  82355. * Returns true if the mesh is blocked. Implemented by child classes
  82356. */
  82357. readonly isBlocked: boolean;
  82358. /**
  82359. * Returns the mesh itself by default. Implemented by child classes
  82360. * @param camera defines the camera to use to pick the right LOD level
  82361. * @returns the currentAbstractMesh
  82362. */
  82363. getLOD(camera: Camera): Nullable<AbstractMesh>;
  82364. /**
  82365. * Returns 0 by default. Implemented by child classes
  82366. * @returns an integer
  82367. */
  82368. getTotalVertices(): number;
  82369. /**
  82370. * Returns a positive integer : the total number of indices in this mesh geometry.
  82371. * @returns the numner of indices or zero if the mesh has no geometry.
  82372. */
  82373. getTotalIndices(): number;
  82374. /**
  82375. * Returns null by default. Implemented by child classes
  82376. * @returns null
  82377. */
  82378. getIndices(): Nullable<IndicesArray>;
  82379. /**
  82380. * Returns the array of the requested vertex data kind. Implemented by child classes
  82381. * @param kind defines the vertex data kind to use
  82382. * @returns null
  82383. */
  82384. getVerticesData(kind: string): Nullable<FloatArray>;
  82385. /**
  82386. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82387. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82388. * Note that a new underlying VertexBuffer object is created each call.
  82389. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82390. * @param kind defines vertex data kind:
  82391. * * VertexBuffer.PositionKind
  82392. * * VertexBuffer.UVKind
  82393. * * VertexBuffer.UV2Kind
  82394. * * VertexBuffer.UV3Kind
  82395. * * VertexBuffer.UV4Kind
  82396. * * VertexBuffer.UV5Kind
  82397. * * VertexBuffer.UV6Kind
  82398. * * VertexBuffer.ColorKind
  82399. * * VertexBuffer.MatricesIndicesKind
  82400. * * VertexBuffer.MatricesIndicesExtraKind
  82401. * * VertexBuffer.MatricesWeightsKind
  82402. * * VertexBuffer.MatricesWeightsExtraKind
  82403. * @param data defines the data source
  82404. * @param updatable defines if the data must be flagged as updatable (or static)
  82405. * @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
  82406. * @returns the current mesh
  82407. */
  82408. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  82409. /**
  82410. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82411. * If the mesh has no geometry, it is simply returned as it is.
  82412. * @param kind defines vertex data kind:
  82413. * * VertexBuffer.PositionKind
  82414. * * VertexBuffer.UVKind
  82415. * * VertexBuffer.UV2Kind
  82416. * * VertexBuffer.UV3Kind
  82417. * * VertexBuffer.UV4Kind
  82418. * * VertexBuffer.UV5Kind
  82419. * * VertexBuffer.UV6Kind
  82420. * * VertexBuffer.ColorKind
  82421. * * VertexBuffer.MatricesIndicesKind
  82422. * * VertexBuffer.MatricesIndicesExtraKind
  82423. * * VertexBuffer.MatricesWeightsKind
  82424. * * VertexBuffer.MatricesWeightsExtraKind
  82425. * @param data defines the data source
  82426. * @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
  82427. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  82428. * @returns the current mesh
  82429. */
  82430. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  82431. /**
  82432. * Sets the mesh indices,
  82433. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82434. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  82435. * @param totalVertices Defines the total number of vertices
  82436. * @returns the current mesh
  82437. */
  82438. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  82439. /**
  82440. * Gets a boolean indicating if specific vertex data is present
  82441. * @param kind defines the vertex data kind to use
  82442. * @returns true is data kind is present
  82443. */
  82444. isVerticesDataPresent(kind: string): boolean;
  82445. /**
  82446. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82447. * @returns a BoundingInfo
  82448. */
  82449. getBoundingInfo(): BoundingInfo;
  82450. /**
  82451. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82452. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82453. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82454. * @returns the current mesh
  82455. */
  82456. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  82457. /**
  82458. * Overwrite the current bounding info
  82459. * @param boundingInfo defines the new bounding info
  82460. * @returns the current mesh
  82461. */
  82462. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  82463. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82464. readonly useBones: boolean;
  82465. /** @hidden */
  82466. _preActivate(): void;
  82467. /** @hidden */
  82468. _preActivateForIntermediateRendering(renderId: number): void;
  82469. /** @hidden */
  82470. _activate(renderId: number): void;
  82471. /**
  82472. * Gets the current world matrix
  82473. * @returns a Matrix
  82474. */
  82475. getWorldMatrix(): Matrix;
  82476. /** @hidden */
  82477. _getWorldMatrixDeterminant(): number;
  82478. /**
  82479. * Perform relative position change from the point of view of behind the front of the mesh.
  82480. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82481. * Supports definition of mesh facing forward or backward
  82482. * @param amountRight defines the distance on the right axis
  82483. * @param amountUp defines the distance on the up axis
  82484. * @param amountForward defines the distance on the forward axis
  82485. * @returns the current mesh
  82486. */
  82487. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  82488. /**
  82489. * Calculate relative position change from the point of view of behind the front of the mesh.
  82490. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82491. * Supports definition of mesh facing forward or backward
  82492. * @param amountRight defines the distance on the right axis
  82493. * @param amountUp defines the distance on the up axis
  82494. * @param amountForward defines the distance on the forward axis
  82495. * @returns the new displacement vector
  82496. */
  82497. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  82498. /**
  82499. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82500. * Supports definition of mesh facing forward or backward
  82501. * @param flipBack defines the flip
  82502. * @param twirlClockwise defines the twirl
  82503. * @param tiltRight defines the tilt
  82504. * @returns the current mesh
  82505. */
  82506. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  82507. /**
  82508. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82509. * Supports definition of mesh facing forward or backward.
  82510. * @param flipBack defines the flip
  82511. * @param twirlClockwise defines the twirl
  82512. * @param tiltRight defines the tilt
  82513. * @returns the new rotation vector
  82514. */
  82515. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  82516. /**
  82517. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82518. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82519. * @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
  82520. * @returns the new bounding vectors
  82521. */
  82522. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  82523. min: Vector3;
  82524. max: Vector3;
  82525. };
  82526. /**
  82527. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82528. * This means the mesh underlying bounding box and sphere are recomputed.
  82529. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82530. * @returns the current mesh
  82531. */
  82532. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  82533. /** @hidden */
  82534. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  82535. /** @hidden */
  82536. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  82537. /** @hidden */
  82538. _updateBoundingInfo(): AbstractMesh;
  82539. /** @hidden */
  82540. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  82541. /** @hidden */
  82542. protected _afterComputeWorldMatrix(): void;
  82543. /**
  82544. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  82545. * A mesh is in the frustum if its bounding box intersects the frustum
  82546. * @param frustumPlanes defines the frustum to test
  82547. * @returns true if the mesh is in the frustum planes
  82548. */
  82549. isInFrustum(frustumPlanes: Plane[]): boolean;
  82550. /**
  82551. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  82552. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  82553. * @param frustumPlanes defines the frustum to test
  82554. * @returns true if the mesh is completely in the frustum planes
  82555. */
  82556. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82557. /**
  82558. * True if the mesh intersects another mesh or a SolidParticle object
  82559. * @param mesh defines a target mesh or SolidParticle to test
  82560. * @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)
  82561. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  82562. * @returns true if there is an intersection
  82563. */
  82564. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  82565. /**
  82566. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  82567. * @param point defines the point to test
  82568. * @returns true if there is an intersection
  82569. */
  82570. intersectsPoint(point: Vector3): boolean;
  82571. /**
  82572. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  82573. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82574. */
  82575. checkCollisions: boolean;
  82576. /**
  82577. * Gets Collider object used to compute collisions (not physics)
  82578. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82579. */
  82580. readonly collider: Collider;
  82581. /**
  82582. * Move the mesh using collision engine
  82583. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82584. * @param displacement defines the requested displacement vector
  82585. * @returns the current mesh
  82586. */
  82587. moveWithCollisions(displacement: Vector3): AbstractMesh;
  82588. private _onCollisionPositionChange;
  82589. /** @hidden */
  82590. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  82591. /** @hidden */
  82592. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  82593. /** @hidden */
  82594. _checkCollision(collider: Collider): AbstractMesh;
  82595. /** @hidden */
  82596. _generatePointsArray(): boolean;
  82597. /**
  82598. * Checks if the passed Ray intersects with the mesh
  82599. * @param ray defines the ray to use
  82600. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  82601. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82602. * @returns the picking info
  82603. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82604. */
  82605. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  82606. /**
  82607. * Clones the current mesh
  82608. * @param name defines the mesh name
  82609. * @param newParent defines the new mesh parent
  82610. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  82611. * @returns the new mesh
  82612. */
  82613. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  82614. /**
  82615. * Disposes all the submeshes of the current meshnp
  82616. * @returns the current mesh
  82617. */
  82618. releaseSubMeshes(): AbstractMesh;
  82619. /**
  82620. * Releases resources associated with this abstract mesh.
  82621. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82622. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82623. */
  82624. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82625. /**
  82626. * Adds the passed mesh as a child to the current mesh
  82627. * @param mesh defines the child mesh
  82628. * @returns the current mesh
  82629. */
  82630. addChild(mesh: AbstractMesh): AbstractMesh;
  82631. /**
  82632. * Removes the passed mesh from the current mesh children list
  82633. * @param mesh defines the child mesh
  82634. * @returns the current mesh
  82635. */
  82636. removeChild(mesh: AbstractMesh): AbstractMesh;
  82637. /** @hidden */
  82638. private _initFacetData;
  82639. /**
  82640. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  82641. * This method can be called within the render loop.
  82642. * 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
  82643. * @returns the current mesh
  82644. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82645. */
  82646. updateFacetData(): AbstractMesh;
  82647. /**
  82648. * Returns the facetLocalNormals array.
  82649. * The normals are expressed in the mesh local spac
  82650. * @returns an array of Vector3
  82651. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82652. */
  82653. getFacetLocalNormals(): Vector3[];
  82654. /**
  82655. * Returns the facetLocalPositions array.
  82656. * The facet positions are expressed in the mesh local space
  82657. * @returns an array of Vector3
  82658. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82659. */
  82660. getFacetLocalPositions(): Vector3[];
  82661. /**
  82662. * Returns the facetLocalPartioning array
  82663. * @returns an array of array of numbers
  82664. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82665. */
  82666. getFacetLocalPartitioning(): number[][];
  82667. /**
  82668. * Returns the i-th facet position in the world system.
  82669. * This method allocates a new Vector3 per call
  82670. * @param i defines the facet index
  82671. * @returns a new Vector3
  82672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82673. */
  82674. getFacetPosition(i: number): Vector3;
  82675. /**
  82676. * Sets the reference Vector3 with the i-th facet position in the world system
  82677. * @param i defines the facet index
  82678. * @param ref defines the target vector
  82679. * @returns the current mesh
  82680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82681. */
  82682. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  82683. /**
  82684. * Returns the i-th facet normal in the world system.
  82685. * This method allocates a new Vector3 per call
  82686. * @param i defines the facet index
  82687. * @returns a new Vector3
  82688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82689. */
  82690. getFacetNormal(i: number): Vector3;
  82691. /**
  82692. * Sets the reference Vector3 with the i-th facet normal in the world system
  82693. * @param i defines the facet index
  82694. * @param ref defines the target vector
  82695. * @returns the current mesh
  82696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82697. */
  82698. getFacetNormalToRef(i: number, ref: Vector3): this;
  82699. /**
  82700. * 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)
  82701. * @param x defines x coordinate
  82702. * @param y defines y coordinate
  82703. * @param z defines z coordinate
  82704. * @returns the array of facet indexes
  82705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82706. */
  82707. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  82708. /**
  82709. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  82710. * @param projected sets as the (x,y,z) world projection on the facet
  82711. * @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
  82712. * @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
  82713. * @param x defines x coordinate
  82714. * @param y defines y coordinate
  82715. * @param z defines z coordinate
  82716. * @returns the face index if found (or null instead)
  82717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82718. */
  82719. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82720. /**
  82721. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  82722. * @param projected sets as the (x,y,z) local projection on the facet
  82723. * @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
  82724. * @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
  82725. * @param x defines x coordinate
  82726. * @param y defines y coordinate
  82727. * @param z defines z coordinate
  82728. * @returns the face index if found (or null instead)
  82729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82730. */
  82731. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82732. /**
  82733. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  82734. * @returns the parameters
  82735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82736. */
  82737. getFacetDataParameters(): any;
  82738. /**
  82739. * Disables the feature FacetData and frees the related memory
  82740. * @returns the current mesh
  82741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82742. */
  82743. disableFacetData(): AbstractMesh;
  82744. /**
  82745. * Updates the AbstractMesh indices array
  82746. * @param indices defines the data source
  82747. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  82748. * @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)
  82749. * @returns the current mesh
  82750. */
  82751. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  82752. /**
  82753. * Creates new normals data for the mesh
  82754. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  82755. * @returns the current mesh
  82756. */
  82757. createNormals(updatable: boolean): AbstractMesh;
  82758. /**
  82759. * Align the mesh with a normal
  82760. * @param normal defines the normal to use
  82761. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  82762. * @returns the current mesh
  82763. */
  82764. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  82765. /** @hidden */
  82766. _checkOcclusionQuery(): boolean;
  82767. }
  82768. }
  82769. declare module BABYLON {
  82770. /**
  82771. * Interface used to define ActionEvent
  82772. */
  82773. export interface IActionEvent {
  82774. /** The mesh or sprite that triggered the action */
  82775. source: any;
  82776. /** The X mouse cursor position at the time of the event */
  82777. pointerX: number;
  82778. /** The Y mouse cursor position at the time of the event */
  82779. pointerY: number;
  82780. /** The mesh that is currently pointed at (can be null) */
  82781. meshUnderPointer: Nullable<AbstractMesh>;
  82782. /** the original (browser) event that triggered the ActionEvent */
  82783. sourceEvent?: any;
  82784. /** additional data for the event */
  82785. additionalData?: any;
  82786. }
  82787. /**
  82788. * ActionEvent is the event being sent when an action is triggered.
  82789. */
  82790. export class ActionEvent implements IActionEvent {
  82791. /** The mesh or sprite that triggered the action */
  82792. source: any;
  82793. /** The X mouse cursor position at the time of the event */
  82794. pointerX: number;
  82795. /** The Y mouse cursor position at the time of the event */
  82796. pointerY: number;
  82797. /** The mesh that is currently pointed at (can be null) */
  82798. meshUnderPointer: Nullable<AbstractMesh>;
  82799. /** the original (browser) event that triggered the ActionEvent */
  82800. sourceEvent?: any;
  82801. /** additional data for the event */
  82802. additionalData?: any;
  82803. /**
  82804. * Creates a new ActionEvent
  82805. * @param source The mesh or sprite that triggered the action
  82806. * @param pointerX The X mouse cursor position at the time of the event
  82807. * @param pointerY The Y mouse cursor position at the time of the event
  82808. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  82809. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  82810. * @param additionalData additional data for the event
  82811. */
  82812. constructor(
  82813. /** The mesh or sprite that triggered the action */
  82814. source: any,
  82815. /** The X mouse cursor position at the time of the event */
  82816. pointerX: number,
  82817. /** The Y mouse cursor position at the time of the event */
  82818. pointerY: number,
  82819. /** The mesh that is currently pointed at (can be null) */
  82820. meshUnderPointer: Nullable<AbstractMesh>,
  82821. /** the original (browser) event that triggered the ActionEvent */
  82822. sourceEvent?: any,
  82823. /** additional data for the event */
  82824. additionalData?: any);
  82825. /**
  82826. * Helper function to auto-create an ActionEvent from a source mesh.
  82827. * @param source The source mesh that triggered the event
  82828. * @param evt The original (browser) event
  82829. * @param additionalData additional data for the event
  82830. * @returns the new ActionEvent
  82831. */
  82832. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  82833. /**
  82834. * Helper function to auto-create an ActionEvent from a source sprite
  82835. * @param source The source sprite that triggered the event
  82836. * @param scene Scene associated with the sprite
  82837. * @param evt The original (browser) event
  82838. * @param additionalData additional data for the event
  82839. * @returns the new ActionEvent
  82840. */
  82841. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  82842. /**
  82843. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  82844. * @param scene the scene where the event occurred
  82845. * @param evt The original (browser) event
  82846. * @returns the new ActionEvent
  82847. */
  82848. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  82849. /**
  82850. * Helper function to auto-create an ActionEvent from a primitive
  82851. * @param prim defines the target primitive
  82852. * @param pointerPos defines the pointer position
  82853. * @param evt The original (browser) event
  82854. * @param additionalData additional data for the event
  82855. * @returns the new ActionEvent
  82856. */
  82857. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  82858. }
  82859. }
  82860. declare module BABYLON {
  82861. /**
  82862. * Abstract class used to decouple action Manager from scene and meshes.
  82863. * Do not instantiate.
  82864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82865. */
  82866. export abstract class AbstractActionManager implements IDisposable {
  82867. /** Gets the list of active triggers */
  82868. static Triggers: {
  82869. [key: string]: number;
  82870. };
  82871. /** Gets the cursor to use when hovering items */
  82872. hoverCursor: string;
  82873. /** Gets the list of actions */
  82874. actions: IAction[];
  82875. /**
  82876. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  82877. */
  82878. isRecursive: boolean;
  82879. /**
  82880. * Releases all associated resources
  82881. */
  82882. abstract dispose(): void;
  82883. /**
  82884. * Does this action manager has pointer triggers
  82885. */
  82886. abstract readonly hasPointerTriggers: boolean;
  82887. /**
  82888. * Does this action manager has pick triggers
  82889. */
  82890. abstract readonly hasPickTriggers: boolean;
  82891. /**
  82892. * Process a specific trigger
  82893. * @param trigger defines the trigger to process
  82894. * @param evt defines the event details to be processed
  82895. */
  82896. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  82897. /**
  82898. * Does this action manager handles actions of any of the given triggers
  82899. * @param triggers defines the triggers to be tested
  82900. * @return a boolean indicating whether one (or more) of the triggers is handled
  82901. */
  82902. abstract hasSpecificTriggers(triggers: number[]): boolean;
  82903. /**
  82904. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  82905. * speed.
  82906. * @param triggerA defines the trigger to be tested
  82907. * @param triggerB defines the trigger to be tested
  82908. * @return a boolean indicating whether one (or more) of the triggers is handled
  82909. */
  82910. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  82911. /**
  82912. * Does this action manager handles actions of a given trigger
  82913. * @param trigger defines the trigger to be tested
  82914. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  82915. * @return whether the trigger is handled
  82916. */
  82917. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  82918. /**
  82919. * Serialize this manager to a JSON object
  82920. * @param name defines the property name to store this manager
  82921. * @returns a JSON representation of this manager
  82922. */
  82923. abstract serialize(name: string): any;
  82924. /**
  82925. * Registers an action to this action manager
  82926. * @param action defines the action to be registered
  82927. * @return the action amended (prepared) after registration
  82928. */
  82929. abstract registerAction(action: IAction): Nullable<IAction>;
  82930. /**
  82931. * Unregisters an action to this action manager
  82932. * @param action defines the action to be unregistered
  82933. * @return a boolean indicating whether the action has been unregistered
  82934. */
  82935. abstract unregisterAction(action: IAction): Boolean;
  82936. /**
  82937. * Does exist one action manager with at least one trigger
  82938. **/
  82939. static readonly HasTriggers: boolean;
  82940. /**
  82941. * Does exist one action manager with at least one pick trigger
  82942. **/
  82943. static readonly HasPickTriggers: boolean;
  82944. /**
  82945. * Does exist one action manager that handles actions of a given trigger
  82946. * @param trigger defines the trigger to be tested
  82947. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  82948. **/
  82949. static HasSpecificTrigger(trigger: number): boolean;
  82950. }
  82951. }
  82952. declare module BABYLON {
  82953. /**
  82954. * Defines how a node can be built from a string name.
  82955. */
  82956. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  82957. /**
  82958. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  82959. */
  82960. export class Node implements IBehaviorAware<Node> {
  82961. /** @hidden */
  82962. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  82963. private static _NodeConstructors;
  82964. /**
  82965. * Add a new node constructor
  82966. * @param type defines the type name of the node to construct
  82967. * @param constructorFunc defines the constructor function
  82968. */
  82969. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  82970. /**
  82971. * Returns a node constructor based on type name
  82972. * @param type defines the type name
  82973. * @param name defines the new node name
  82974. * @param scene defines the hosting scene
  82975. * @param options defines optional options to transmit to constructors
  82976. * @returns the new constructor or null
  82977. */
  82978. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  82979. /**
  82980. * Gets or sets the name of the node
  82981. */
  82982. name: string;
  82983. /**
  82984. * Gets or sets the id of the node
  82985. */
  82986. id: string;
  82987. /**
  82988. * Gets or sets the unique id of the node
  82989. */
  82990. uniqueId: number;
  82991. /**
  82992. * Gets or sets a string used to store user defined state for the node
  82993. */
  82994. state: string;
  82995. /**
  82996. * Gets or sets an object used to store user defined information for the node
  82997. */
  82998. metadata: any;
  82999. /**
  83000. * For internal use only. Please do not use.
  83001. */
  83002. reservedDataStore: any;
  83003. /**
  83004. * List of inspectable custom properties (used by the Inspector)
  83005. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83006. */
  83007. inspectableCustomProperties: IInspectable[];
  83008. /**
  83009. * Gets or sets a boolean used to define if the node must be serialized
  83010. */
  83011. doNotSerialize: boolean;
  83012. /** @hidden */
  83013. _isDisposed: boolean;
  83014. /**
  83015. * Gets a list of Animations associated with the node
  83016. */
  83017. animations: Animation[];
  83018. protected _ranges: {
  83019. [name: string]: Nullable<AnimationRange>;
  83020. };
  83021. /**
  83022. * Callback raised when the node is ready to be used
  83023. */
  83024. onReady: (node: Node) => void;
  83025. private _isEnabled;
  83026. private _isParentEnabled;
  83027. private _isReady;
  83028. /** @hidden */
  83029. _currentRenderId: number;
  83030. private _parentRenderId;
  83031. protected _childRenderId: number;
  83032. /** @hidden */
  83033. _waitingParentId: Nullable<string>;
  83034. /** @hidden */
  83035. _scene: Scene;
  83036. /** @hidden */
  83037. _cache: any;
  83038. private _parentNode;
  83039. private _children;
  83040. /** @hidden */
  83041. _worldMatrix: Matrix;
  83042. /** @hidden */
  83043. _worldMatrixDeterminant: number;
  83044. /** @hidden */
  83045. private _sceneRootNodesIndex;
  83046. /**
  83047. * Gets a boolean indicating if the node has been disposed
  83048. * @returns true if the node was disposed
  83049. */
  83050. isDisposed(): boolean;
  83051. /**
  83052. * Gets or sets the parent of the node (without keeping the current position in the scene)
  83053. * @see https://doc.babylonjs.com/how_to/parenting
  83054. */
  83055. parent: Nullable<Node>;
  83056. private addToSceneRootNodes;
  83057. private removeFromSceneRootNodes;
  83058. private _animationPropertiesOverride;
  83059. /**
  83060. * Gets or sets the animation properties override
  83061. */
  83062. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83063. /**
  83064. * Gets a string idenfifying the name of the class
  83065. * @returns "Node" string
  83066. */
  83067. getClassName(): string;
  83068. /** @hidden */
  83069. readonly _isNode: boolean;
  83070. /**
  83071. * An event triggered when the mesh is disposed
  83072. */
  83073. onDisposeObservable: Observable<Node>;
  83074. private _onDisposeObserver;
  83075. /**
  83076. * Sets a callback that will be raised when the node will be disposed
  83077. */
  83078. onDispose: () => void;
  83079. /**
  83080. * Creates a new Node
  83081. * @param name the name and id to be given to this node
  83082. * @param scene the scene this node will be added to
  83083. * @param addToRootNodes the node will be added to scene.rootNodes
  83084. */
  83085. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83086. /**
  83087. * Gets the scene of the node
  83088. * @returns a scene
  83089. */
  83090. getScene(): Scene;
  83091. /**
  83092. * Gets the engine of the node
  83093. * @returns a Engine
  83094. */
  83095. getEngine(): Engine;
  83096. private _behaviors;
  83097. /**
  83098. * Attach a behavior to the node
  83099. * @see http://doc.babylonjs.com/features/behaviour
  83100. * @param behavior defines the behavior to attach
  83101. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83102. * @returns the current Node
  83103. */
  83104. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  83105. /**
  83106. * Remove an attached behavior
  83107. * @see http://doc.babylonjs.com/features/behaviour
  83108. * @param behavior defines the behavior to attach
  83109. * @returns the current Node
  83110. */
  83111. removeBehavior(behavior: Behavior<Node>): Node;
  83112. /**
  83113. * Gets the list of attached behaviors
  83114. * @see http://doc.babylonjs.com/features/behaviour
  83115. */
  83116. readonly behaviors: Behavior<Node>[];
  83117. /**
  83118. * Gets an attached behavior by name
  83119. * @param name defines the name of the behavior to look for
  83120. * @see http://doc.babylonjs.com/features/behaviour
  83121. * @returns null if behavior was not found else the requested behavior
  83122. */
  83123. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  83124. /**
  83125. * Returns the latest update of the World matrix
  83126. * @returns a Matrix
  83127. */
  83128. getWorldMatrix(): Matrix;
  83129. /** @hidden */
  83130. _getWorldMatrixDeterminant(): number;
  83131. /**
  83132. * Returns directly the latest state of the mesh World matrix.
  83133. * A Matrix is returned.
  83134. */
  83135. readonly worldMatrixFromCache: Matrix;
  83136. /** @hidden */
  83137. _initCache(): void;
  83138. /** @hidden */
  83139. updateCache(force?: boolean): void;
  83140. /** @hidden */
  83141. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83142. /** @hidden */
  83143. _updateCache(ignoreParentClass?: boolean): void;
  83144. /** @hidden */
  83145. _isSynchronized(): boolean;
  83146. /** @hidden */
  83147. _markSyncedWithParent(): void;
  83148. /** @hidden */
  83149. isSynchronizedWithParent(): boolean;
  83150. /** @hidden */
  83151. isSynchronized(): boolean;
  83152. /**
  83153. * Is this node ready to be used/rendered
  83154. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83155. * @return true if the node is ready
  83156. */
  83157. isReady(completeCheck?: boolean): boolean;
  83158. /**
  83159. * Is this node enabled?
  83160. * 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
  83161. * @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
  83162. * @return whether this node (and its parent) is enabled
  83163. */
  83164. isEnabled(checkAncestors?: boolean): boolean;
  83165. /** @hidden */
  83166. protected _syncParentEnabledState(): void;
  83167. /**
  83168. * Set the enabled state of this node
  83169. * @param value defines the new enabled state
  83170. */
  83171. setEnabled(value: boolean): void;
  83172. /**
  83173. * Is this node a descendant of the given node?
  83174. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  83175. * @param ancestor defines the parent node to inspect
  83176. * @returns a boolean indicating if this node is a descendant of the given node
  83177. */
  83178. isDescendantOf(ancestor: Node): boolean;
  83179. /** @hidden */
  83180. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  83181. /**
  83182. * Will return all nodes that have this node as ascendant
  83183. * @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
  83184. * @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
  83185. * @return all children nodes of all types
  83186. */
  83187. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  83188. /**
  83189. * Get all child-meshes of this node
  83190. * @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)
  83191. * @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
  83192. * @returns an array of AbstractMesh
  83193. */
  83194. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  83195. /**
  83196. * Get all direct children of this node
  83197. * @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
  83198. * @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)
  83199. * @returns an array of Node
  83200. */
  83201. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  83202. /** @hidden */
  83203. _setReady(state: boolean): void;
  83204. /**
  83205. * Get an animation by name
  83206. * @param name defines the name of the animation to look for
  83207. * @returns null if not found else the requested animation
  83208. */
  83209. getAnimationByName(name: string): Nullable<Animation>;
  83210. /**
  83211. * Creates an animation range for this node
  83212. * @param name defines the name of the range
  83213. * @param from defines the starting key
  83214. * @param to defines the end key
  83215. */
  83216. createAnimationRange(name: string, from: number, to: number): void;
  83217. /**
  83218. * Delete a specific animation range
  83219. * @param name defines the name of the range to delete
  83220. * @param deleteFrames defines if animation frames from the range must be deleted as well
  83221. */
  83222. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  83223. /**
  83224. * Get an animation range by name
  83225. * @param name defines the name of the animation range to look for
  83226. * @returns null if not found else the requested animation range
  83227. */
  83228. getAnimationRange(name: string): Nullable<AnimationRange>;
  83229. /**
  83230. * Gets the list of all animation ranges defined on this node
  83231. * @returns an array
  83232. */
  83233. getAnimationRanges(): Nullable<AnimationRange>[];
  83234. /**
  83235. * Will start the animation sequence
  83236. * @param name defines the range frames for animation sequence
  83237. * @param loop defines if the animation should loop (false by default)
  83238. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  83239. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  83240. * @returns the object created for this animation. If range does not exist, it will return null
  83241. */
  83242. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  83243. /**
  83244. * Serialize animation ranges into a JSON compatible object
  83245. * @returns serialization object
  83246. */
  83247. serializeAnimationRanges(): any;
  83248. /**
  83249. * Computes the world matrix of the node
  83250. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83251. * @returns the world matrix
  83252. */
  83253. computeWorldMatrix(force?: boolean): Matrix;
  83254. /**
  83255. * Releases resources associated with this node.
  83256. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83257. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83258. */
  83259. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83260. /**
  83261. * Parse animation range data from a serialization object and store them into a given node
  83262. * @param node defines where to store the animation ranges
  83263. * @param parsedNode defines the serialization object to read data from
  83264. * @param scene defines the hosting scene
  83265. */
  83266. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  83267. }
  83268. }
  83269. declare module BABYLON {
  83270. /**
  83271. * Class used to store any kind of animation
  83272. */
  83273. export class Animation {
  83274. /**Name of the animation */
  83275. name: string;
  83276. /**Property to animate */
  83277. targetProperty: string;
  83278. /**The frames per second of the animation */
  83279. framePerSecond: number;
  83280. /**The data type of the animation */
  83281. dataType: number;
  83282. /**The loop mode of the animation */
  83283. loopMode?: number | undefined;
  83284. /**Specifies if blending should be enabled */
  83285. enableBlending?: boolean | undefined;
  83286. /**
  83287. * Use matrix interpolation instead of using direct key value when animating matrices
  83288. */
  83289. static AllowMatricesInterpolation: boolean;
  83290. /**
  83291. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  83292. */
  83293. static AllowMatrixDecomposeForInterpolation: boolean;
  83294. /**
  83295. * Stores the key frames of the animation
  83296. */
  83297. private _keys;
  83298. /**
  83299. * Stores the easing function of the animation
  83300. */
  83301. private _easingFunction;
  83302. /**
  83303. * @hidden Internal use only
  83304. */
  83305. _runtimeAnimations: RuntimeAnimation[];
  83306. /**
  83307. * The set of event that will be linked to this animation
  83308. */
  83309. private _events;
  83310. /**
  83311. * Stores an array of target property paths
  83312. */
  83313. targetPropertyPath: string[];
  83314. /**
  83315. * Stores the blending speed of the animation
  83316. */
  83317. blendingSpeed: number;
  83318. /**
  83319. * Stores the animation ranges for the animation
  83320. */
  83321. private _ranges;
  83322. /**
  83323. * @hidden Internal use
  83324. */
  83325. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  83326. /**
  83327. * Sets up an animation
  83328. * @param property The property to animate
  83329. * @param animationType The animation type to apply
  83330. * @param framePerSecond The frames per second of the animation
  83331. * @param easingFunction The easing function used in the animation
  83332. * @returns The created animation
  83333. */
  83334. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  83335. /**
  83336. * Create and start an animation on a node
  83337. * @param name defines the name of the global animation that will be run on all nodes
  83338. * @param node defines the root node where the animation will take place
  83339. * @param targetProperty defines property to animate
  83340. * @param framePerSecond defines the number of frame per second yo use
  83341. * @param totalFrame defines the number of frames in total
  83342. * @param from defines the initial value
  83343. * @param to defines the final value
  83344. * @param loopMode defines which loop mode you want to use (off by default)
  83345. * @param easingFunction defines the easing function to use (linear by default)
  83346. * @param onAnimationEnd defines the callback to call when animation end
  83347. * @returns the animatable created for this animation
  83348. */
  83349. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83350. /**
  83351. * Create and start an animation on a node and its descendants
  83352. * @param name defines the name of the global animation that will be run on all nodes
  83353. * @param node defines the root node where the animation will take place
  83354. * @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
  83355. * @param targetProperty defines property to animate
  83356. * @param framePerSecond defines the number of frame per second to use
  83357. * @param totalFrame defines the number of frames in total
  83358. * @param from defines the initial value
  83359. * @param to defines the final value
  83360. * @param loopMode defines which loop mode you want to use (off by default)
  83361. * @param easingFunction defines the easing function to use (linear by default)
  83362. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83363. * @returns the list of animatables created for all nodes
  83364. * @example https://www.babylonjs-playground.com/#MH0VLI
  83365. */
  83366. 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[]>;
  83367. /**
  83368. * Creates a new animation, merges it with the existing animations and starts it
  83369. * @param name Name of the animation
  83370. * @param node Node which contains the scene that begins the animations
  83371. * @param targetProperty Specifies which property to animate
  83372. * @param framePerSecond The frames per second of the animation
  83373. * @param totalFrame The total number of frames
  83374. * @param from The frame at the beginning of the animation
  83375. * @param to The frame at the end of the animation
  83376. * @param loopMode Specifies the loop mode of the animation
  83377. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  83378. * @param onAnimationEnd Callback to run once the animation is complete
  83379. * @returns Nullable animation
  83380. */
  83381. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83382. /**
  83383. * Transition property of an host to the target Value
  83384. * @param property The property to transition
  83385. * @param targetValue The target Value of the property
  83386. * @param host The object where the property to animate belongs
  83387. * @param scene Scene used to run the animation
  83388. * @param frameRate Framerate (in frame/s) to use
  83389. * @param transition The transition type we want to use
  83390. * @param duration The duration of the animation, in milliseconds
  83391. * @param onAnimationEnd Callback trigger at the end of the animation
  83392. * @returns Nullable animation
  83393. */
  83394. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  83395. /**
  83396. * Return the array of runtime animations currently using this animation
  83397. */
  83398. readonly runtimeAnimations: RuntimeAnimation[];
  83399. /**
  83400. * Specifies if any of the runtime animations are currently running
  83401. */
  83402. readonly hasRunningRuntimeAnimations: boolean;
  83403. /**
  83404. * Initializes the animation
  83405. * @param name Name of the animation
  83406. * @param targetProperty Property to animate
  83407. * @param framePerSecond The frames per second of the animation
  83408. * @param dataType The data type of the animation
  83409. * @param loopMode The loop mode of the animation
  83410. * @param enableBlending Specifies if blending should be enabled
  83411. */
  83412. constructor(
  83413. /**Name of the animation */
  83414. name: string,
  83415. /**Property to animate */
  83416. targetProperty: string,
  83417. /**The frames per second of the animation */
  83418. framePerSecond: number,
  83419. /**The data type of the animation */
  83420. dataType: number,
  83421. /**The loop mode of the animation */
  83422. loopMode?: number | undefined,
  83423. /**Specifies if blending should be enabled */
  83424. enableBlending?: boolean | undefined);
  83425. /**
  83426. * Converts the animation to a string
  83427. * @param fullDetails support for multiple levels of logging within scene loading
  83428. * @returns String form of the animation
  83429. */
  83430. toString(fullDetails?: boolean): string;
  83431. /**
  83432. * Add an event to this animation
  83433. * @param event Event to add
  83434. */
  83435. addEvent(event: AnimationEvent): void;
  83436. /**
  83437. * Remove all events found at the given frame
  83438. * @param frame The frame to remove events from
  83439. */
  83440. removeEvents(frame: number): void;
  83441. /**
  83442. * Retrieves all the events from the animation
  83443. * @returns Events from the animation
  83444. */
  83445. getEvents(): AnimationEvent[];
  83446. /**
  83447. * Creates an animation range
  83448. * @param name Name of the animation range
  83449. * @param from Starting frame of the animation range
  83450. * @param to Ending frame of the animation
  83451. */
  83452. createRange(name: string, from: number, to: number): void;
  83453. /**
  83454. * Deletes an animation range by name
  83455. * @param name Name of the animation range to delete
  83456. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  83457. */
  83458. deleteRange(name: string, deleteFrames?: boolean): void;
  83459. /**
  83460. * Gets the animation range by name, or null if not defined
  83461. * @param name Name of the animation range
  83462. * @returns Nullable animation range
  83463. */
  83464. getRange(name: string): Nullable<AnimationRange>;
  83465. /**
  83466. * Gets the key frames from the animation
  83467. * @returns The key frames of the animation
  83468. */
  83469. getKeys(): Array<IAnimationKey>;
  83470. /**
  83471. * Gets the highest frame rate of the animation
  83472. * @returns Highest frame rate of the animation
  83473. */
  83474. getHighestFrame(): number;
  83475. /**
  83476. * Gets the easing function of the animation
  83477. * @returns Easing function of the animation
  83478. */
  83479. getEasingFunction(): IEasingFunction;
  83480. /**
  83481. * Sets the easing function of the animation
  83482. * @param easingFunction A custom mathematical formula for animation
  83483. */
  83484. setEasingFunction(easingFunction: EasingFunction): void;
  83485. /**
  83486. * Interpolates a scalar linearly
  83487. * @param startValue Start value of the animation curve
  83488. * @param endValue End value of the animation curve
  83489. * @param gradient Scalar amount to interpolate
  83490. * @returns Interpolated scalar value
  83491. */
  83492. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  83493. /**
  83494. * Interpolates a scalar cubically
  83495. * @param startValue Start value of the animation curve
  83496. * @param outTangent End tangent of the animation
  83497. * @param endValue End value of the animation curve
  83498. * @param inTangent Start tangent of the animation curve
  83499. * @param gradient Scalar amount to interpolate
  83500. * @returns Interpolated scalar value
  83501. */
  83502. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  83503. /**
  83504. * Interpolates a quaternion using a spherical linear interpolation
  83505. * @param startValue Start value of the animation curve
  83506. * @param endValue End value of the animation curve
  83507. * @param gradient Scalar amount to interpolate
  83508. * @returns Interpolated quaternion value
  83509. */
  83510. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  83511. /**
  83512. * Interpolates a quaternion cubically
  83513. * @param startValue Start value of the animation curve
  83514. * @param outTangent End tangent of the animation curve
  83515. * @param endValue End value of the animation curve
  83516. * @param inTangent Start tangent of the animation curve
  83517. * @param gradient Scalar amount to interpolate
  83518. * @returns Interpolated quaternion value
  83519. */
  83520. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  83521. /**
  83522. * Interpolates a Vector3 linearl
  83523. * @param startValue Start value of the animation curve
  83524. * @param endValue End value of the animation curve
  83525. * @param gradient Scalar amount to interpolate
  83526. * @returns Interpolated scalar value
  83527. */
  83528. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  83529. /**
  83530. * Interpolates a Vector3 cubically
  83531. * @param startValue Start value of the animation curve
  83532. * @param outTangent End tangent of the animation
  83533. * @param endValue End value of the animation curve
  83534. * @param inTangent Start tangent of the animation curve
  83535. * @param gradient Scalar amount to interpolate
  83536. * @returns InterpolatedVector3 value
  83537. */
  83538. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  83539. /**
  83540. * Interpolates a Vector2 linearly
  83541. * @param startValue Start value of the animation curve
  83542. * @param endValue End value of the animation curve
  83543. * @param gradient Scalar amount to interpolate
  83544. * @returns Interpolated Vector2 value
  83545. */
  83546. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  83547. /**
  83548. * Interpolates a Vector2 cubically
  83549. * @param startValue Start value of the animation curve
  83550. * @param outTangent End tangent of the animation
  83551. * @param endValue End value of the animation curve
  83552. * @param inTangent Start tangent of the animation curve
  83553. * @param gradient Scalar amount to interpolate
  83554. * @returns Interpolated Vector2 value
  83555. */
  83556. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  83557. /**
  83558. * Interpolates a size linearly
  83559. * @param startValue Start value of the animation curve
  83560. * @param endValue End value of the animation curve
  83561. * @param gradient Scalar amount to interpolate
  83562. * @returns Interpolated Size value
  83563. */
  83564. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  83565. /**
  83566. * Interpolates a Color3 linearly
  83567. * @param startValue Start value of the animation curve
  83568. * @param endValue End value of the animation curve
  83569. * @param gradient Scalar amount to interpolate
  83570. * @returns Interpolated Color3 value
  83571. */
  83572. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  83573. /**
  83574. * @hidden Internal use only
  83575. */
  83576. _getKeyValue(value: any): any;
  83577. /**
  83578. * @hidden Internal use only
  83579. */
  83580. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  83581. /**
  83582. * Defines the function to use to interpolate matrices
  83583. * @param startValue defines the start matrix
  83584. * @param endValue defines the end matrix
  83585. * @param gradient defines the gradient between both matrices
  83586. * @param result defines an optional target matrix where to store the interpolation
  83587. * @returns the interpolated matrix
  83588. */
  83589. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  83590. /**
  83591. * Makes a copy of the animation
  83592. * @returns Cloned animation
  83593. */
  83594. clone(): Animation;
  83595. /**
  83596. * Sets the key frames of the animation
  83597. * @param values The animation key frames to set
  83598. */
  83599. setKeys(values: Array<IAnimationKey>): void;
  83600. /**
  83601. * Serializes the animation to an object
  83602. * @returns Serialized object
  83603. */
  83604. serialize(): any;
  83605. /**
  83606. * Float animation type
  83607. */
  83608. private static _ANIMATIONTYPE_FLOAT;
  83609. /**
  83610. * Vector3 animation type
  83611. */
  83612. private static _ANIMATIONTYPE_VECTOR3;
  83613. /**
  83614. * Quaternion animation type
  83615. */
  83616. private static _ANIMATIONTYPE_QUATERNION;
  83617. /**
  83618. * Matrix animation type
  83619. */
  83620. private static _ANIMATIONTYPE_MATRIX;
  83621. /**
  83622. * Color3 animation type
  83623. */
  83624. private static _ANIMATIONTYPE_COLOR3;
  83625. /**
  83626. * Vector2 animation type
  83627. */
  83628. private static _ANIMATIONTYPE_VECTOR2;
  83629. /**
  83630. * Size animation type
  83631. */
  83632. private static _ANIMATIONTYPE_SIZE;
  83633. /**
  83634. * Relative Loop Mode
  83635. */
  83636. private static _ANIMATIONLOOPMODE_RELATIVE;
  83637. /**
  83638. * Cycle Loop Mode
  83639. */
  83640. private static _ANIMATIONLOOPMODE_CYCLE;
  83641. /**
  83642. * Constant Loop Mode
  83643. */
  83644. private static _ANIMATIONLOOPMODE_CONSTANT;
  83645. /**
  83646. * Get the float animation type
  83647. */
  83648. static readonly ANIMATIONTYPE_FLOAT: number;
  83649. /**
  83650. * Get the Vector3 animation type
  83651. */
  83652. static readonly ANIMATIONTYPE_VECTOR3: number;
  83653. /**
  83654. * Get the Vector2 animation type
  83655. */
  83656. static readonly ANIMATIONTYPE_VECTOR2: number;
  83657. /**
  83658. * Get the Size animation type
  83659. */
  83660. static readonly ANIMATIONTYPE_SIZE: number;
  83661. /**
  83662. * Get the Quaternion animation type
  83663. */
  83664. static readonly ANIMATIONTYPE_QUATERNION: number;
  83665. /**
  83666. * Get the Matrix animation type
  83667. */
  83668. static readonly ANIMATIONTYPE_MATRIX: number;
  83669. /**
  83670. * Get the Color3 animation type
  83671. */
  83672. static readonly ANIMATIONTYPE_COLOR3: number;
  83673. /**
  83674. * Get the Relative Loop Mode
  83675. */
  83676. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  83677. /**
  83678. * Get the Cycle Loop Mode
  83679. */
  83680. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  83681. /**
  83682. * Get the Constant Loop Mode
  83683. */
  83684. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  83685. /** @hidden */
  83686. static _UniversalLerp(left: any, right: any, amount: number): any;
  83687. /**
  83688. * Parses an animation object and creates an animation
  83689. * @param parsedAnimation Parsed animation object
  83690. * @returns Animation object
  83691. */
  83692. static Parse(parsedAnimation: any): Animation;
  83693. /**
  83694. * Appends the serialized animations from the source animations
  83695. * @param source Source containing the animations
  83696. * @param destination Target to store the animations
  83697. */
  83698. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  83699. }
  83700. }
  83701. declare module BABYLON {
  83702. /**
  83703. * Base class of all the textures in babylon.
  83704. * It groups all the common properties the materials, post process, lights... might need
  83705. * in order to make a correct use of the texture.
  83706. */
  83707. export class BaseTexture implements IAnimatable {
  83708. /**
  83709. * Default anisotropic filtering level for the application.
  83710. * It is set to 4 as a good tradeoff between perf and quality.
  83711. */
  83712. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  83713. /**
  83714. * Gets or sets the unique id of the texture
  83715. */
  83716. uniqueId: number;
  83717. /**
  83718. * Define the name of the texture.
  83719. */
  83720. name: string;
  83721. /**
  83722. * Gets or sets an object used to store user defined information.
  83723. */
  83724. metadata: any;
  83725. /**
  83726. * For internal use only. Please do not use.
  83727. */
  83728. reservedDataStore: any;
  83729. private _hasAlpha;
  83730. /**
  83731. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  83732. */
  83733. hasAlpha: boolean;
  83734. /**
  83735. * Defines if the alpha value should be determined via the rgb values.
  83736. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  83737. */
  83738. getAlphaFromRGB: boolean;
  83739. /**
  83740. * Intensity or strength of the texture.
  83741. * It is commonly used by materials to fine tune the intensity of the texture
  83742. */
  83743. level: number;
  83744. /**
  83745. * Define the UV chanel to use starting from 0 and defaulting to 0.
  83746. * This is part of the texture as textures usually maps to one uv set.
  83747. */
  83748. coordinatesIndex: number;
  83749. private _coordinatesMode;
  83750. /**
  83751. * How a texture is mapped.
  83752. *
  83753. * | Value | Type | Description |
  83754. * | ----- | ----------------------------------- | ----------- |
  83755. * | 0 | EXPLICIT_MODE | |
  83756. * | 1 | SPHERICAL_MODE | |
  83757. * | 2 | PLANAR_MODE | |
  83758. * | 3 | CUBIC_MODE | |
  83759. * | 4 | PROJECTION_MODE | |
  83760. * | 5 | SKYBOX_MODE | |
  83761. * | 6 | INVCUBIC_MODE | |
  83762. * | 7 | EQUIRECTANGULAR_MODE | |
  83763. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  83764. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  83765. */
  83766. coordinatesMode: number;
  83767. /**
  83768. * | Value | Type | Description |
  83769. * | ----- | ------------------ | ----------- |
  83770. * | 0 | CLAMP_ADDRESSMODE | |
  83771. * | 1 | WRAP_ADDRESSMODE | |
  83772. * | 2 | MIRROR_ADDRESSMODE | |
  83773. */
  83774. wrapU: number;
  83775. /**
  83776. * | Value | Type | Description |
  83777. * | ----- | ------------------ | ----------- |
  83778. * | 0 | CLAMP_ADDRESSMODE | |
  83779. * | 1 | WRAP_ADDRESSMODE | |
  83780. * | 2 | MIRROR_ADDRESSMODE | |
  83781. */
  83782. wrapV: number;
  83783. /**
  83784. * | Value | Type | Description |
  83785. * | ----- | ------------------ | ----------- |
  83786. * | 0 | CLAMP_ADDRESSMODE | |
  83787. * | 1 | WRAP_ADDRESSMODE | |
  83788. * | 2 | MIRROR_ADDRESSMODE | |
  83789. */
  83790. wrapR: number;
  83791. /**
  83792. * With compliant hardware and browser (supporting anisotropic filtering)
  83793. * this defines the level of anisotropic filtering in the texture.
  83794. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83795. */
  83796. anisotropicFilteringLevel: number;
  83797. /**
  83798. * Define if the texture is a cube texture or if false a 2d texture.
  83799. */
  83800. isCube: boolean;
  83801. /**
  83802. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83803. */
  83804. is3D: boolean;
  83805. /**
  83806. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  83807. * HDR texture are usually stored in linear space.
  83808. * This only impacts the PBR and Background materials
  83809. */
  83810. gammaSpace: boolean;
  83811. /**
  83812. * Gets whether or not the texture contains RGBD data.
  83813. */
  83814. readonly isRGBD: boolean;
  83815. /**
  83816. * Is Z inverted in the texture (useful in a cube texture).
  83817. */
  83818. invertZ: boolean;
  83819. /**
  83820. * Are mip maps generated for this texture or not.
  83821. */
  83822. readonly noMipmap: boolean;
  83823. /**
  83824. * @hidden
  83825. */
  83826. lodLevelInAlpha: boolean;
  83827. /**
  83828. * With prefiltered texture, defined the offset used during the prefiltering steps.
  83829. */
  83830. lodGenerationOffset: number;
  83831. /**
  83832. * With prefiltered texture, defined the scale used during the prefiltering steps.
  83833. */
  83834. lodGenerationScale: number;
  83835. /**
  83836. * Define if the texture is a render target.
  83837. */
  83838. isRenderTarget: boolean;
  83839. /**
  83840. * Define the unique id of the texture in the scene.
  83841. */
  83842. readonly uid: string;
  83843. /**
  83844. * Return a string representation of the texture.
  83845. * @returns the texture as a string
  83846. */
  83847. toString(): string;
  83848. /**
  83849. * Get the class name of the texture.
  83850. * @returns "BaseTexture"
  83851. */
  83852. getClassName(): string;
  83853. /**
  83854. * Define the list of animation attached to the texture.
  83855. */
  83856. animations: Animation[];
  83857. /**
  83858. * An event triggered when the texture is disposed.
  83859. */
  83860. onDisposeObservable: Observable<BaseTexture>;
  83861. private _onDisposeObserver;
  83862. /**
  83863. * Callback triggered when the texture has been disposed.
  83864. * Kept for back compatibility, you can use the onDisposeObservable instead.
  83865. */
  83866. onDispose: () => void;
  83867. /**
  83868. * Define the current state of the loading sequence when in delayed load mode.
  83869. */
  83870. delayLoadState: number;
  83871. private _scene;
  83872. /** @hidden */
  83873. _texture: Nullable<InternalTexture>;
  83874. private _uid;
  83875. /**
  83876. * Define if the texture is preventinga material to render or not.
  83877. * If not and the texture is not ready, the engine will use a default black texture instead.
  83878. */
  83879. readonly isBlocking: boolean;
  83880. /**
  83881. * Instantiates a new BaseTexture.
  83882. * Base class of all the textures in babylon.
  83883. * It groups all the common properties the materials, post process, lights... might need
  83884. * in order to make a correct use of the texture.
  83885. * @param scene Define the scene the texture blongs to
  83886. */
  83887. constructor(scene: Nullable<Scene>);
  83888. /**
  83889. * Get the scene the texture belongs to.
  83890. * @returns the scene or null if undefined
  83891. */
  83892. getScene(): Nullable<Scene>;
  83893. /**
  83894. * Get the texture transform matrix used to offset tile the texture for istance.
  83895. * @returns the transformation matrix
  83896. */
  83897. getTextureMatrix(): Matrix;
  83898. /**
  83899. * Get the texture reflection matrix used to rotate/transform the reflection.
  83900. * @returns the reflection matrix
  83901. */
  83902. getReflectionTextureMatrix(): Matrix;
  83903. /**
  83904. * Get the underlying lower level texture from Babylon.
  83905. * @returns the insternal texture
  83906. */
  83907. getInternalTexture(): Nullable<InternalTexture>;
  83908. /**
  83909. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  83910. * @returns true if ready or not blocking
  83911. */
  83912. isReadyOrNotBlocking(): boolean;
  83913. /**
  83914. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83915. * @returns true if fully ready
  83916. */
  83917. isReady(): boolean;
  83918. private _cachedSize;
  83919. /**
  83920. * Get the size of the texture.
  83921. * @returns the texture size.
  83922. */
  83923. getSize(): ISize;
  83924. /**
  83925. * Get the base size of the texture.
  83926. * It can be different from the size if the texture has been resized for POT for instance
  83927. * @returns the base size
  83928. */
  83929. getBaseSize(): ISize;
  83930. /**
  83931. * Update the sampling mode of the texture.
  83932. * Default is Trilinear mode.
  83933. *
  83934. * | Value | Type | Description |
  83935. * | ----- | ------------------ | ----------- |
  83936. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83937. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83938. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83939. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83940. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83941. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83942. * | 7 | NEAREST_LINEAR | |
  83943. * | 8 | NEAREST_NEAREST | |
  83944. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83945. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83946. * | 11 | LINEAR_LINEAR | |
  83947. * | 12 | LINEAR_NEAREST | |
  83948. *
  83949. * > _mag_: magnification filter (close to the viewer)
  83950. * > _min_: minification filter (far from the viewer)
  83951. * > _mip_: filter used between mip map levels
  83952. *@param samplingMode Define the new sampling mode of the texture
  83953. */
  83954. updateSamplingMode(samplingMode: number): void;
  83955. /**
  83956. * Scales the texture if is `canRescale()`
  83957. * @param ratio the resize factor we want to use to rescale
  83958. */
  83959. scale(ratio: number): void;
  83960. /**
  83961. * Get if the texture can rescale.
  83962. */
  83963. readonly canRescale: boolean;
  83964. /** @hidden */
  83965. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  83966. /** @hidden */
  83967. _rebuild(): void;
  83968. /**
  83969. * Triggers the load sequence in delayed load mode.
  83970. */
  83971. delayLoad(): void;
  83972. /**
  83973. * Clones the texture.
  83974. * @returns the cloned texture
  83975. */
  83976. clone(): Nullable<BaseTexture>;
  83977. /**
  83978. * Get the texture underlying type (INT, FLOAT...)
  83979. */
  83980. readonly textureType: number;
  83981. /**
  83982. * Get the texture underlying format (RGB, RGBA...)
  83983. */
  83984. readonly textureFormat: number;
  83985. /**
  83986. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  83987. * This will returns an RGBA array buffer containing either in values (0-255) or
  83988. * float values (0-1) depending of the underlying buffer type.
  83989. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  83990. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  83991. * @param buffer defines a user defined buffer to fill with data (can be null)
  83992. * @returns The Array buffer containing the pixels data.
  83993. */
  83994. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  83995. /**
  83996. * Release and destroy the underlying lower level texture aka internalTexture.
  83997. */
  83998. releaseInternalTexture(): void;
  83999. /**
  84000. * Get the polynomial representation of the texture data.
  84001. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  84002. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  84003. */
  84004. sphericalPolynomial: Nullable<SphericalPolynomial>;
  84005. /** @hidden */
  84006. readonly _lodTextureHigh: Nullable<BaseTexture>;
  84007. /** @hidden */
  84008. readonly _lodTextureMid: Nullable<BaseTexture>;
  84009. /** @hidden */
  84010. readonly _lodTextureLow: Nullable<BaseTexture>;
  84011. /**
  84012. * Dispose the texture and release its associated resources.
  84013. */
  84014. dispose(): void;
  84015. /**
  84016. * Serialize the texture into a JSON representation that can be parsed later on.
  84017. * @returns the JSON representation of the texture
  84018. */
  84019. serialize(): any;
  84020. /**
  84021. * Helper function to be called back once a list of texture contains only ready textures.
  84022. * @param textures Define the list of textures to wait for
  84023. * @param callback Define the callback triggered once the entire list will be ready
  84024. */
  84025. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  84026. }
  84027. }
  84028. declare module BABYLON {
  84029. /**
  84030. * Uniform buffer objects.
  84031. *
  84032. * Handles blocks of uniform on the GPU.
  84033. *
  84034. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84035. *
  84036. * For more information, please refer to :
  84037. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84038. */
  84039. export class UniformBuffer {
  84040. private _engine;
  84041. private _buffer;
  84042. private _data;
  84043. private _bufferData;
  84044. private _dynamic?;
  84045. private _uniformLocations;
  84046. private _uniformSizes;
  84047. private _uniformLocationPointer;
  84048. private _needSync;
  84049. private _noUBO;
  84050. private _currentEffect;
  84051. private static _MAX_UNIFORM_SIZE;
  84052. private static _tempBuffer;
  84053. /**
  84054. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84055. * This is dynamic to allow compat with webgl 1 and 2.
  84056. * You will need to pass the name of the uniform as well as the value.
  84057. */
  84058. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84059. /**
  84060. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84061. * This is dynamic to allow compat with webgl 1 and 2.
  84062. * You will need to pass the name of the uniform as well as the value.
  84063. */
  84064. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84065. /**
  84066. * Lambda to Update a single float in a uniform buffer.
  84067. * This is dynamic to allow compat with webgl 1 and 2.
  84068. * You will need to pass the name of the uniform as well as the value.
  84069. */
  84070. updateFloat: (name: string, x: number) => void;
  84071. /**
  84072. * Lambda to Update a vec2 of float in a uniform buffer.
  84073. * This is dynamic to allow compat with webgl 1 and 2.
  84074. * You will need to pass the name of the uniform as well as the value.
  84075. */
  84076. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84077. /**
  84078. * Lambda to Update a vec3 of float in a uniform buffer.
  84079. * This is dynamic to allow compat with webgl 1 and 2.
  84080. * You will need to pass the name of the uniform as well as the value.
  84081. */
  84082. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84083. /**
  84084. * Lambda to Update a vec4 of float in a uniform buffer.
  84085. * This is dynamic to allow compat with webgl 1 and 2.
  84086. * You will need to pass the name of the uniform as well as the value.
  84087. */
  84088. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84089. /**
  84090. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84091. * This is dynamic to allow compat with webgl 1 and 2.
  84092. * You will need to pass the name of the uniform as well as the value.
  84093. */
  84094. updateMatrix: (name: string, mat: Matrix) => void;
  84095. /**
  84096. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84097. * This is dynamic to allow compat with webgl 1 and 2.
  84098. * You will need to pass the name of the uniform as well as the value.
  84099. */
  84100. updateVector3: (name: string, vector: Vector3) => void;
  84101. /**
  84102. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84103. * This is dynamic to allow compat with webgl 1 and 2.
  84104. * You will need to pass the name of the uniform as well as the value.
  84105. */
  84106. updateVector4: (name: string, vector: Vector4) => void;
  84107. /**
  84108. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84109. * This is dynamic to allow compat with webgl 1 and 2.
  84110. * You will need to pass the name of the uniform as well as the value.
  84111. */
  84112. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84113. /**
  84114. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84115. * This is dynamic to allow compat with webgl 1 and 2.
  84116. * You will need to pass the name of the uniform as well as the value.
  84117. */
  84118. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84119. /**
  84120. * Instantiates a new Uniform buffer objects.
  84121. *
  84122. * Handles blocks of uniform on the GPU.
  84123. *
  84124. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84125. *
  84126. * For more information, please refer to :
  84127. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84128. * @param engine Define the engine the buffer is associated with
  84129. * @param data Define the data contained in the buffer
  84130. * @param dynamic Define if the buffer is updatable
  84131. */
  84132. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84133. /**
  84134. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84135. * or just falling back on setUniformXXX calls.
  84136. */
  84137. readonly useUbo: boolean;
  84138. /**
  84139. * Indicates if the WebGL underlying uniform buffer is in sync
  84140. * with the javascript cache data.
  84141. */
  84142. readonly isSync: boolean;
  84143. /**
  84144. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84145. * Also, a dynamic UniformBuffer will disable cache verification and always
  84146. * update the underlying WebGL uniform buffer to the GPU.
  84147. * @returns if Dynamic, otherwise false
  84148. */
  84149. isDynamic(): boolean;
  84150. /**
  84151. * The data cache on JS side.
  84152. * @returns the underlying data as a float array
  84153. */
  84154. getData(): Float32Array;
  84155. /**
  84156. * The underlying WebGL Uniform buffer.
  84157. * @returns the webgl buffer
  84158. */
  84159. getBuffer(): Nullable<WebGLBuffer>;
  84160. /**
  84161. * std140 layout specifies how to align data within an UBO structure.
  84162. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84163. * for specs.
  84164. */
  84165. private _fillAlignment;
  84166. /**
  84167. * Adds an uniform in the buffer.
  84168. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84169. * for the layout to be correct !
  84170. * @param name Name of the uniform, as used in the uniform block in the shader.
  84171. * @param size Data size, or data directly.
  84172. */
  84173. addUniform(name: string, size: number | number[]): void;
  84174. /**
  84175. * Adds a Matrix 4x4 to the uniform buffer.
  84176. * @param name Name of the uniform, as used in the uniform block in the shader.
  84177. * @param mat A 4x4 matrix.
  84178. */
  84179. addMatrix(name: string, mat: Matrix): void;
  84180. /**
  84181. * Adds a vec2 to the uniform buffer.
  84182. * @param name Name of the uniform, as used in the uniform block in the shader.
  84183. * @param x Define the x component value of the vec2
  84184. * @param y Define the y component value of the vec2
  84185. */
  84186. addFloat2(name: string, x: number, y: number): void;
  84187. /**
  84188. * Adds a vec3 to the uniform buffer.
  84189. * @param name Name of the uniform, as used in the uniform block in the shader.
  84190. * @param x Define the x component value of the vec3
  84191. * @param y Define the y component value of the vec3
  84192. * @param z Define the z component value of the vec3
  84193. */
  84194. addFloat3(name: string, x: number, y: number, z: number): void;
  84195. /**
  84196. * Adds a vec3 to the uniform buffer.
  84197. * @param name Name of the uniform, as used in the uniform block in the shader.
  84198. * @param color Define the vec3 from a Color
  84199. */
  84200. addColor3(name: string, color: Color3): void;
  84201. /**
  84202. * Adds a vec4 to the uniform buffer.
  84203. * @param name Name of the uniform, as used in the uniform block in the shader.
  84204. * @param color Define the rgb components from a Color
  84205. * @param alpha Define the a component of the vec4
  84206. */
  84207. addColor4(name: string, color: Color3, alpha: number): void;
  84208. /**
  84209. * Adds a vec3 to the uniform buffer.
  84210. * @param name Name of the uniform, as used in the uniform block in the shader.
  84211. * @param vector Define the vec3 components from a Vector
  84212. */
  84213. addVector3(name: string, vector: Vector3): void;
  84214. /**
  84215. * Adds a Matrix 3x3 to the uniform buffer.
  84216. * @param name Name of the uniform, as used in the uniform block in the shader.
  84217. */
  84218. addMatrix3x3(name: string): void;
  84219. /**
  84220. * Adds a Matrix 2x2 to the uniform buffer.
  84221. * @param name Name of the uniform, as used in the uniform block in the shader.
  84222. */
  84223. addMatrix2x2(name: string): void;
  84224. /**
  84225. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84226. */
  84227. create(): void;
  84228. /** @hidden */
  84229. _rebuild(): void;
  84230. /**
  84231. * Updates the WebGL Uniform Buffer on the GPU.
  84232. * If the `dynamic` flag is set to true, no cache comparison is done.
  84233. * Otherwise, the buffer will be updated only if the cache differs.
  84234. */
  84235. update(): void;
  84236. /**
  84237. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84238. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84239. * @param data Define the flattened data
  84240. * @param size Define the size of the data.
  84241. */
  84242. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84243. private _updateMatrix3x3ForUniform;
  84244. private _updateMatrix3x3ForEffect;
  84245. private _updateMatrix2x2ForEffect;
  84246. private _updateMatrix2x2ForUniform;
  84247. private _updateFloatForEffect;
  84248. private _updateFloatForUniform;
  84249. private _updateFloat2ForEffect;
  84250. private _updateFloat2ForUniform;
  84251. private _updateFloat3ForEffect;
  84252. private _updateFloat3ForUniform;
  84253. private _updateFloat4ForEffect;
  84254. private _updateFloat4ForUniform;
  84255. private _updateMatrixForEffect;
  84256. private _updateMatrixForUniform;
  84257. private _updateVector3ForEffect;
  84258. private _updateVector3ForUniform;
  84259. private _updateVector4ForEffect;
  84260. private _updateVector4ForUniform;
  84261. private _updateColor3ForEffect;
  84262. private _updateColor3ForUniform;
  84263. private _updateColor4ForEffect;
  84264. private _updateColor4ForUniform;
  84265. /**
  84266. * Sets a sampler uniform on the effect.
  84267. * @param name Define the name of the sampler.
  84268. * @param texture Define the texture to set in the sampler
  84269. */
  84270. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84271. /**
  84272. * Directly updates the value of the uniform in the cache AND on the GPU.
  84273. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84274. * @param data Define the flattened data
  84275. */
  84276. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84277. /**
  84278. * Binds this uniform buffer to an effect.
  84279. * @param effect Define the effect to bind the buffer to
  84280. * @param name Name of the uniform block in the shader.
  84281. */
  84282. bindToEffect(effect: Effect, name: string): void;
  84283. /**
  84284. * Disposes the uniform buffer.
  84285. */
  84286. dispose(): void;
  84287. }
  84288. }
  84289. declare module BABYLON {
  84290. /**
  84291. * This represents the required contract to create a new type of texture loader.
  84292. */
  84293. export interface IInternalTextureLoader {
  84294. /**
  84295. * Defines wether the loader supports cascade loading the different faces.
  84296. */
  84297. supportCascades: boolean;
  84298. /**
  84299. * This returns if the loader support the current file information.
  84300. * @param extension defines the file extension of the file being loaded
  84301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84302. * @param fallback defines the fallback internal texture if any
  84303. * @param isBase64 defines whether the texture is encoded as a base64
  84304. * @param isBuffer defines whether the texture data are stored as a buffer
  84305. * @returns true if the loader can load the specified file
  84306. */
  84307. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  84308. /**
  84309. * Transform the url before loading if required.
  84310. * @param rootUrl the url of the texture
  84311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84312. * @returns the transformed texture
  84313. */
  84314. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  84315. /**
  84316. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  84317. * @param rootUrl the url of the texture
  84318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84319. * @returns the fallback texture
  84320. */
  84321. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  84322. /**
  84323. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  84324. * @param data contains the texture data
  84325. * @param texture defines the BabylonJS internal texture
  84326. * @param createPolynomials will be true if polynomials have been requested
  84327. * @param onLoad defines the callback to trigger once the texture is ready
  84328. * @param onError defines the callback to trigger in case of error
  84329. */
  84330. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  84331. /**
  84332. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  84333. * @param data contains the texture data
  84334. * @param texture defines the BabylonJS internal texture
  84335. * @param callback defines the method to call once ready to upload
  84336. */
  84337. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  84338. }
  84339. }
  84340. declare module BABYLON {
  84341. /**
  84342. * Creation options of the multi render target texture.
  84343. */
  84344. export interface IMultiRenderTargetOptions {
  84345. /**
  84346. * Define if the texture needs to create mip maps after render.
  84347. */
  84348. generateMipMaps?: boolean;
  84349. /**
  84350. * Define the types of all the draw buffers we want to create
  84351. */
  84352. types?: number[];
  84353. /**
  84354. * Define the sampling modes of all the draw buffers we want to create
  84355. */
  84356. samplingModes?: number[];
  84357. /**
  84358. * Define if a depth buffer is required
  84359. */
  84360. generateDepthBuffer?: boolean;
  84361. /**
  84362. * Define if a stencil buffer is required
  84363. */
  84364. generateStencilBuffer?: boolean;
  84365. /**
  84366. * Define if a depth texture is required instead of a depth buffer
  84367. */
  84368. generateDepthTexture?: boolean;
  84369. /**
  84370. * Define the number of desired draw buffers
  84371. */
  84372. textureCount?: number;
  84373. /**
  84374. * Define if aspect ratio should be adapted to the texture or stay the scene one
  84375. */
  84376. doNotChangeAspectRatio?: boolean;
  84377. /**
  84378. * Define the default type of the buffers we are creating
  84379. */
  84380. defaultType?: number;
  84381. }
  84382. /**
  84383. * A multi render target, like a render target provides the ability to render to a texture.
  84384. * Unlike the render target, it can render to several draw buffers in one draw.
  84385. * This is specially interesting in deferred rendering or for any effects requiring more than
  84386. * just one color from a single pass.
  84387. */
  84388. export class MultiRenderTarget extends RenderTargetTexture {
  84389. private _internalTextures;
  84390. private _textures;
  84391. private _multiRenderTargetOptions;
  84392. /**
  84393. * Get if draw buffers are currently supported by the used hardware and browser.
  84394. */
  84395. readonly isSupported: boolean;
  84396. /**
  84397. * Get the list of textures generated by the multi render target.
  84398. */
  84399. readonly textures: Texture[];
  84400. /**
  84401. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  84402. */
  84403. readonly depthTexture: Texture;
  84404. /**
  84405. * Set the wrapping mode on U of all the textures we are rendering to.
  84406. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84407. */
  84408. wrapU: number;
  84409. /**
  84410. * Set the wrapping mode on V of all the textures we are rendering to.
  84411. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84412. */
  84413. wrapV: number;
  84414. /**
  84415. * Instantiate a new multi render target texture.
  84416. * A multi render target, like a render target provides the ability to render to a texture.
  84417. * Unlike the render target, it can render to several draw buffers in one draw.
  84418. * This is specially interesting in deferred rendering or for any effects requiring more than
  84419. * just one color from a single pass.
  84420. * @param name Define the name of the texture
  84421. * @param size Define the size of the buffers to render to
  84422. * @param count Define the number of target we are rendering into
  84423. * @param scene Define the scene the texture belongs to
  84424. * @param options Define the options used to create the multi render target
  84425. */
  84426. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  84427. /** @hidden */
  84428. _rebuild(): void;
  84429. private _createInternalTextures;
  84430. private _createTextures;
  84431. /**
  84432. * Define the number of samples used if MSAA is enabled.
  84433. */
  84434. samples: number;
  84435. /**
  84436. * Resize all the textures in the multi render target.
  84437. * Be carrefull as it will recreate all the data in the new texture.
  84438. * @param size Define the new size
  84439. */
  84440. resize(size: any): void;
  84441. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84442. /**
  84443. * Dispose the render targets and their associated resources
  84444. */
  84445. dispose(): void;
  84446. /**
  84447. * Release all the underlying texture used as draw buffers.
  84448. */
  84449. releaseInternalTextures(): void;
  84450. }
  84451. }
  84452. declare module BABYLON {
  84453. /**
  84454. * Class used to work with sound analyzer using fast fourier transform (FFT)
  84455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84456. */
  84457. export class Analyser {
  84458. /**
  84459. * Gets or sets the smoothing
  84460. * @ignorenaming
  84461. */
  84462. SMOOTHING: number;
  84463. /**
  84464. * Gets or sets the FFT table size
  84465. * @ignorenaming
  84466. */
  84467. FFT_SIZE: number;
  84468. /**
  84469. * Gets or sets the bar graph amplitude
  84470. * @ignorenaming
  84471. */
  84472. BARGRAPHAMPLITUDE: number;
  84473. /**
  84474. * Gets or sets the position of the debug canvas
  84475. * @ignorenaming
  84476. */
  84477. DEBUGCANVASPOS: {
  84478. x: number;
  84479. y: number;
  84480. };
  84481. /**
  84482. * Gets or sets the debug canvas size
  84483. * @ignorenaming
  84484. */
  84485. DEBUGCANVASSIZE: {
  84486. width: number;
  84487. height: number;
  84488. };
  84489. private _byteFreqs;
  84490. private _byteTime;
  84491. private _floatFreqs;
  84492. private _webAudioAnalyser;
  84493. private _debugCanvas;
  84494. private _debugCanvasContext;
  84495. private _scene;
  84496. private _registerFunc;
  84497. private _audioEngine;
  84498. /**
  84499. * Creates a new analyser
  84500. * @param scene defines hosting scene
  84501. */
  84502. constructor(scene: Scene);
  84503. /**
  84504. * Get the number of data values you will have to play with for the visualization
  84505. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  84506. * @returns a number
  84507. */
  84508. getFrequencyBinCount(): number;
  84509. /**
  84510. * Gets the current frequency data as a byte array
  84511. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84512. * @returns a Uint8Array
  84513. */
  84514. getByteFrequencyData(): Uint8Array;
  84515. /**
  84516. * Gets the current waveform as a byte array
  84517. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  84518. * @returns a Uint8Array
  84519. */
  84520. getByteTimeDomainData(): Uint8Array;
  84521. /**
  84522. * Gets the current frequency data as a float array
  84523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84524. * @returns a Float32Array
  84525. */
  84526. getFloatFrequencyData(): Float32Array;
  84527. /**
  84528. * Renders the debug canvas
  84529. */
  84530. drawDebugCanvas(): void;
  84531. /**
  84532. * Stops rendering the debug canvas and removes it
  84533. */
  84534. stopDebugCanvas(): void;
  84535. /**
  84536. * Connects two audio nodes
  84537. * @param inputAudioNode defines first node to connect
  84538. * @param outputAudioNode defines second node to connect
  84539. */
  84540. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  84541. /**
  84542. * Releases all associated resources
  84543. */
  84544. dispose(): void;
  84545. }
  84546. }
  84547. declare module BABYLON {
  84548. /**
  84549. * This represents an audio engine and it is responsible
  84550. * to play, synchronize and analyse sounds throughout the application.
  84551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84552. */
  84553. export interface IAudioEngine extends IDisposable {
  84554. /**
  84555. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84556. */
  84557. readonly canUseWebAudio: boolean;
  84558. /**
  84559. * Gets the current AudioContext if available.
  84560. */
  84561. readonly audioContext: Nullable<AudioContext>;
  84562. /**
  84563. * The master gain node defines the global audio volume of your audio engine.
  84564. */
  84565. readonly masterGain: GainNode;
  84566. /**
  84567. * Gets whether or not mp3 are supported by your browser.
  84568. */
  84569. readonly isMP3supported: boolean;
  84570. /**
  84571. * Gets whether or not ogg are supported by your browser.
  84572. */
  84573. readonly isOGGsupported: boolean;
  84574. /**
  84575. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84576. * @ignoreNaming
  84577. */
  84578. WarnedWebAudioUnsupported: boolean;
  84579. /**
  84580. * Defines if the audio engine relies on a custom unlocked button.
  84581. * In this case, the embedded button will not be displayed.
  84582. */
  84583. useCustomUnlockedButton: boolean;
  84584. /**
  84585. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  84586. */
  84587. readonly unlocked: boolean;
  84588. /**
  84589. * Event raised when audio has been unlocked on the browser.
  84590. */
  84591. onAudioUnlockedObservable: Observable<AudioEngine>;
  84592. /**
  84593. * Event raised when audio has been locked on the browser.
  84594. */
  84595. onAudioLockedObservable: Observable<AudioEngine>;
  84596. /**
  84597. * Flags the audio engine in Locked state.
  84598. * This happens due to new browser policies preventing audio to autoplay.
  84599. */
  84600. lock(): void;
  84601. /**
  84602. * Unlocks the audio engine once a user action has been done on the dom.
  84603. * This is helpful to resume play once browser policies have been satisfied.
  84604. */
  84605. unlock(): void;
  84606. }
  84607. /**
  84608. * This represents the default audio engine used in babylon.
  84609. * It is responsible to play, synchronize and analyse sounds throughout the application.
  84610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84611. */
  84612. export class AudioEngine implements IAudioEngine {
  84613. private _audioContext;
  84614. private _audioContextInitialized;
  84615. private _muteButton;
  84616. private _hostElement;
  84617. /**
  84618. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84619. */
  84620. canUseWebAudio: boolean;
  84621. /**
  84622. * The master gain node defines the global audio volume of your audio engine.
  84623. */
  84624. masterGain: GainNode;
  84625. /**
  84626. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84627. * @ignoreNaming
  84628. */
  84629. WarnedWebAudioUnsupported: boolean;
  84630. /**
  84631. * Gets whether or not mp3 are supported by your browser.
  84632. */
  84633. isMP3supported: boolean;
  84634. /**
  84635. * Gets whether or not ogg are supported by your browser.
  84636. */
  84637. isOGGsupported: boolean;
  84638. /**
  84639. * Gets whether audio has been unlocked on the device.
  84640. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  84641. * a user interaction has happened.
  84642. */
  84643. unlocked: boolean;
  84644. /**
  84645. * Defines if the audio engine relies on a custom unlocked button.
  84646. * In this case, the embedded button will not be displayed.
  84647. */
  84648. useCustomUnlockedButton: boolean;
  84649. /**
  84650. * Event raised when audio has been unlocked on the browser.
  84651. */
  84652. onAudioUnlockedObservable: Observable<AudioEngine>;
  84653. /**
  84654. * Event raised when audio has been locked on the browser.
  84655. */
  84656. onAudioLockedObservable: Observable<AudioEngine>;
  84657. /**
  84658. * Gets the current AudioContext if available.
  84659. */
  84660. readonly audioContext: Nullable<AudioContext>;
  84661. private _connectedAnalyser;
  84662. /**
  84663. * Instantiates a new audio engine.
  84664. *
  84665. * There should be only one per page as some browsers restrict the number
  84666. * of audio contexts you can create.
  84667. * @param hostElement defines the host element where to display the mute icon if necessary
  84668. */
  84669. constructor(hostElement?: Nullable<HTMLElement>);
  84670. /**
  84671. * Flags the audio engine in Locked state.
  84672. * This happens due to new browser policies preventing audio to autoplay.
  84673. */
  84674. lock(): void;
  84675. /**
  84676. * Unlocks the audio engine once a user action has been done on the dom.
  84677. * This is helpful to resume play once browser policies have been satisfied.
  84678. */
  84679. unlock(): void;
  84680. private _resumeAudioContext;
  84681. private _initializeAudioContext;
  84682. private _tryToRun;
  84683. private _triggerRunningState;
  84684. private _triggerSuspendedState;
  84685. private _displayMuteButton;
  84686. private _moveButtonToTopLeft;
  84687. private _onResize;
  84688. private _hideMuteButton;
  84689. /**
  84690. * Destroy and release the resources associated with the audio ccontext.
  84691. */
  84692. dispose(): void;
  84693. /**
  84694. * Gets the global volume sets on the master gain.
  84695. * @returns the global volume if set or -1 otherwise
  84696. */
  84697. getGlobalVolume(): number;
  84698. /**
  84699. * Sets the global volume of your experience (sets on the master gain).
  84700. * @param newVolume Defines the new global volume of the application
  84701. */
  84702. setGlobalVolume(newVolume: number): void;
  84703. /**
  84704. * Connect the audio engine to an audio analyser allowing some amazing
  84705. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  84706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  84707. * @param analyser The analyser to connect to the engine
  84708. */
  84709. connectToAnalyser(analyser: Analyser): void;
  84710. }
  84711. }
  84712. declare module BABYLON {
  84713. /**
  84714. * Interface used to present a loading screen while loading a scene
  84715. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84716. */
  84717. export interface ILoadingScreen {
  84718. /**
  84719. * Function called to display the loading screen
  84720. */
  84721. displayLoadingUI: () => void;
  84722. /**
  84723. * Function called to hide the loading screen
  84724. */
  84725. hideLoadingUI: () => void;
  84726. /**
  84727. * Gets or sets the color to use for the background
  84728. */
  84729. loadingUIBackgroundColor: string;
  84730. /**
  84731. * Gets or sets the text to display while loading
  84732. */
  84733. loadingUIText: string;
  84734. }
  84735. /**
  84736. * Class used for the default loading screen
  84737. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84738. */
  84739. export class DefaultLoadingScreen implements ILoadingScreen {
  84740. private _renderingCanvas;
  84741. private _loadingText;
  84742. private _loadingDivBackgroundColor;
  84743. private _loadingDiv;
  84744. private _loadingTextDiv;
  84745. /**
  84746. * Creates a new default loading screen
  84747. * @param _renderingCanvas defines the canvas used to render the scene
  84748. * @param _loadingText defines the default text to display
  84749. * @param _loadingDivBackgroundColor defines the default background color
  84750. */
  84751. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  84752. /**
  84753. * Function called to display the loading screen
  84754. */
  84755. displayLoadingUI(): void;
  84756. /**
  84757. * Function called to hide the loading screen
  84758. */
  84759. hideLoadingUI(): void;
  84760. /**
  84761. * Gets or sets the text to display while loading
  84762. */
  84763. loadingUIText: string;
  84764. /**
  84765. * Gets or sets the color to use for the background
  84766. */
  84767. loadingUIBackgroundColor: string;
  84768. private _resizeLoadingUI;
  84769. }
  84770. }
  84771. declare module BABYLON {
  84772. /**
  84773. * Settings for finer control over video usage
  84774. */
  84775. export interface VideoTextureSettings {
  84776. /**
  84777. * Applies `autoplay` to video, if specified
  84778. */
  84779. autoPlay?: boolean;
  84780. /**
  84781. * Applies `loop` to video, if specified
  84782. */
  84783. loop?: boolean;
  84784. /**
  84785. * Automatically updates internal texture from video at every frame in the render loop
  84786. */
  84787. autoUpdateTexture: boolean;
  84788. /**
  84789. * Image src displayed during the video loading or until the user interacts with the video.
  84790. */
  84791. poster?: string;
  84792. }
  84793. /**
  84794. * If you want to display a video in your scene, this is the special texture for that.
  84795. * This special texture works similar to other textures, with the exception of a few parameters.
  84796. * @see https://doc.babylonjs.com/how_to/video_texture
  84797. */
  84798. export class VideoTexture extends Texture {
  84799. /**
  84800. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  84801. */
  84802. readonly autoUpdateTexture: boolean;
  84803. /**
  84804. * The video instance used by the texture internally
  84805. */
  84806. readonly video: HTMLVideoElement;
  84807. private _onUserActionRequestedObservable;
  84808. /**
  84809. * Event triggerd when a dom action is required by the user to play the video.
  84810. * This happens due to recent changes in browser policies preventing video to auto start.
  84811. */
  84812. readonly onUserActionRequestedObservable: Observable<Texture>;
  84813. private _generateMipMaps;
  84814. private _engine;
  84815. private _stillImageCaptured;
  84816. private _displayingPosterTexture;
  84817. private _settings;
  84818. private _createInternalTextureOnEvent;
  84819. /**
  84820. * Creates a video texture.
  84821. * If you want to display a video in your scene, this is the special texture for that.
  84822. * This special texture works similar to other textures, with the exception of a few parameters.
  84823. * @see https://doc.babylonjs.com/how_to/video_texture
  84824. * @param name optional name, will detect from video source, if not defined
  84825. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  84826. * @param scene is obviously the current scene.
  84827. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  84828. * @param invertY is false by default but can be used to invert video on Y axis
  84829. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  84830. * @param settings allows finer control over video usage
  84831. */
  84832. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  84833. private _getName;
  84834. private _getVideo;
  84835. private _createInternalTexture;
  84836. private reset;
  84837. /**
  84838. * @hidden Internal method to initiate `update`.
  84839. */
  84840. _rebuild(): void;
  84841. /**
  84842. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  84843. */
  84844. update(): void;
  84845. /**
  84846. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  84847. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  84848. */
  84849. updateTexture(isVisible: boolean): void;
  84850. protected _updateInternalTexture: () => void;
  84851. /**
  84852. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  84853. * @param url New url.
  84854. */
  84855. updateURL(url: string): void;
  84856. /**
  84857. * Dispose the texture and release its associated resources.
  84858. */
  84859. dispose(): void;
  84860. /**
  84861. * Creates a video texture straight from a stream.
  84862. * @param scene Define the scene the texture should be created in
  84863. * @param stream Define the stream the texture should be created from
  84864. * @returns The created video texture as a promise
  84865. */
  84866. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  84867. /**
  84868. * Creates a video texture straight from your WebCam video feed.
  84869. * @param scene Define the scene the texture should be created in
  84870. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84871. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84872. * @returns The created video texture as a promise
  84873. */
  84874. static CreateFromWebCamAsync(scene: Scene, constraints: {
  84875. minWidth: number;
  84876. maxWidth: number;
  84877. minHeight: number;
  84878. maxHeight: number;
  84879. deviceId: string;
  84880. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  84881. /**
  84882. * Creates a video texture straight from your WebCam video feed.
  84883. * @param scene Define the scene the texture should be created in
  84884. * @param onReady Define a callback to triggered once the texture will be ready
  84885. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84886. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84887. */
  84888. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  84889. minWidth: number;
  84890. maxWidth: number;
  84891. minHeight: number;
  84892. maxHeight: number;
  84893. deviceId: string;
  84894. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  84895. }
  84896. }
  84897. declare module BABYLON {
  84898. /**
  84899. * Interface for attribute information associated with buffer instanciation
  84900. */
  84901. export class InstancingAttributeInfo {
  84902. /**
  84903. * Index/offset of the attribute in the vertex shader
  84904. */
  84905. index: number;
  84906. /**
  84907. * size of the attribute, 1, 2, 3 or 4
  84908. */
  84909. attributeSize: number;
  84910. /**
  84911. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  84912. * default is FLOAT
  84913. */
  84914. attribyteType: number;
  84915. /**
  84916. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  84917. */
  84918. normalized: boolean;
  84919. /**
  84920. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  84921. */
  84922. offset: number;
  84923. /**
  84924. * Name of the GLSL attribute, for debugging purpose only
  84925. */
  84926. attributeName: string;
  84927. }
  84928. /**
  84929. * Define options used to create a depth texture
  84930. */
  84931. export class DepthTextureCreationOptions {
  84932. /** Specifies whether or not a stencil should be allocated in the texture */
  84933. generateStencil?: boolean;
  84934. /** Specifies whether or not bilinear filtering is enable on the texture */
  84935. bilinearFiltering?: boolean;
  84936. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84937. comparisonFunction?: number;
  84938. /** Specifies if the created texture is a cube texture */
  84939. isCube?: boolean;
  84940. }
  84941. /**
  84942. * Class used to describe the capabilities of the engine relatively to the current browser
  84943. */
  84944. export class EngineCapabilities {
  84945. /** Maximum textures units per fragment shader */
  84946. maxTexturesImageUnits: number;
  84947. /** Maximum texture units per vertex shader */
  84948. maxVertexTextureImageUnits: number;
  84949. /** Maximum textures units in the entire pipeline */
  84950. maxCombinedTexturesImageUnits: number;
  84951. /** Maximum texture size */
  84952. maxTextureSize: number;
  84953. /** Maximum cube texture size */
  84954. maxCubemapTextureSize: number;
  84955. /** Maximum render texture size */
  84956. maxRenderTextureSize: number;
  84957. /** Maximum number of vertex attributes */
  84958. maxVertexAttribs: number;
  84959. /** Maximum number of varyings */
  84960. maxVaryingVectors: number;
  84961. /** Maximum number of uniforms per vertex shader */
  84962. maxVertexUniformVectors: number;
  84963. /** Maximum number of uniforms per fragment shader */
  84964. maxFragmentUniformVectors: number;
  84965. /** Defines if standard derivates (dx/dy) are supported */
  84966. standardDerivatives: boolean;
  84967. /** Defines if s3tc texture compression is supported */
  84968. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  84969. /** Defines if pvrtc texture compression is supported */
  84970. pvrtc: any;
  84971. /** Defines if etc1 texture compression is supported */
  84972. etc1: any;
  84973. /** Defines if etc2 texture compression is supported */
  84974. etc2: any;
  84975. /** Defines if astc texture compression is supported */
  84976. astc: any;
  84977. /** Defines if float textures are supported */
  84978. textureFloat: boolean;
  84979. /** Defines if vertex array objects are supported */
  84980. vertexArrayObject: boolean;
  84981. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  84982. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  84983. /** Gets the maximum level of anisotropy supported */
  84984. maxAnisotropy: number;
  84985. /** Defines if instancing is supported */
  84986. instancedArrays: boolean;
  84987. /** Defines if 32 bits indices are supported */
  84988. uintIndices: boolean;
  84989. /** Defines if high precision shaders are supported */
  84990. highPrecisionShaderSupported: boolean;
  84991. /** Defines if depth reading in the fragment shader is supported */
  84992. fragmentDepthSupported: boolean;
  84993. /** Defines if float texture linear filtering is supported*/
  84994. textureFloatLinearFiltering: boolean;
  84995. /** Defines if rendering to float textures is supported */
  84996. textureFloatRender: boolean;
  84997. /** Defines if half float textures are supported*/
  84998. textureHalfFloat: boolean;
  84999. /** Defines if half float texture linear filtering is supported*/
  85000. textureHalfFloatLinearFiltering: boolean;
  85001. /** Defines if rendering to half float textures is supported */
  85002. textureHalfFloatRender: boolean;
  85003. /** Defines if textureLOD shader command is supported */
  85004. textureLOD: boolean;
  85005. /** Defines if draw buffers extension is supported */
  85006. drawBuffersExtension: boolean;
  85007. /** Defines if depth textures are supported */
  85008. depthTextureExtension: boolean;
  85009. /** Defines if float color buffer are supported */
  85010. colorBufferFloat: boolean;
  85011. /** Gets disjoint timer query extension (null if not supported) */
  85012. timerQuery: EXT_disjoint_timer_query;
  85013. /** Defines if timestamp can be used with timer query */
  85014. canUseTimestampForTimerQuery: boolean;
  85015. /** Function used to let the system compiles shaders in background */
  85016. parallelShaderCompile: {
  85017. COMPLETION_STATUS_KHR: number;
  85018. };
  85019. }
  85020. /** Interface defining initialization parameters for Engine class */
  85021. export interface EngineOptions extends WebGLContextAttributes {
  85022. /**
  85023. * Defines if the engine should no exceed a specified device ratio
  85024. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  85025. */
  85026. limitDeviceRatio?: number;
  85027. /**
  85028. * Defines if webvr should be enabled automatically
  85029. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85030. */
  85031. autoEnableWebVR?: boolean;
  85032. /**
  85033. * Defines if webgl2 should be turned off even if supported
  85034. * @see http://doc.babylonjs.com/features/webgl2
  85035. */
  85036. disableWebGL2Support?: boolean;
  85037. /**
  85038. * Defines if webaudio should be initialized as well
  85039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85040. */
  85041. audioEngine?: boolean;
  85042. /**
  85043. * Defines if animations should run using a deterministic lock step
  85044. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85045. */
  85046. deterministicLockstep?: boolean;
  85047. /** Defines the maximum steps to use with deterministic lock step mode */
  85048. lockstepMaxSteps?: number;
  85049. /**
  85050. * Defines that engine should ignore context lost events
  85051. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  85052. */
  85053. doNotHandleContextLost?: boolean;
  85054. /**
  85055. * Defines that engine should ignore modifying touch action attribute and style
  85056. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  85057. */
  85058. doNotHandleTouchAction?: boolean;
  85059. /**
  85060. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  85061. */
  85062. useHighPrecisionFloats?: boolean;
  85063. }
  85064. /**
  85065. * Defines the interface used by display changed events
  85066. */
  85067. export interface IDisplayChangedEventArgs {
  85068. /** Gets the vrDisplay object (if any) */
  85069. vrDisplay: Nullable<any>;
  85070. /** Gets a boolean indicating if webVR is supported */
  85071. vrSupported: boolean;
  85072. }
  85073. /**
  85074. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  85075. */
  85076. export class Engine {
  85077. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  85078. static ExceptionList: ({
  85079. key: string;
  85080. capture: string;
  85081. captureConstraint: number;
  85082. targets: string[];
  85083. } | {
  85084. key: string;
  85085. capture: null;
  85086. captureConstraint: null;
  85087. targets: string[];
  85088. })[];
  85089. /** Gets the list of created engines */
  85090. static readonly Instances: Engine[];
  85091. /**
  85092. * Gets the latest created engine
  85093. */
  85094. static readonly LastCreatedEngine: Nullable<Engine>;
  85095. /**
  85096. * Gets the latest created scene
  85097. */
  85098. static readonly LastCreatedScene: Nullable<Scene>;
  85099. /**
  85100. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  85101. * @param flag defines which part of the materials must be marked as dirty
  85102. * @param predicate defines a predicate used to filter which materials should be affected
  85103. */
  85104. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  85105. /**
  85106. * Hidden
  85107. */
  85108. static _TextureLoaders: IInternalTextureLoader[];
  85109. /** Defines that alpha blending is disabled */
  85110. static readonly ALPHA_DISABLE: number;
  85111. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  85112. static readonly ALPHA_ADD: number;
  85113. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85114. static readonly ALPHA_COMBINE: number;
  85115. /** Defines that alpha blending to DEST - SRC * DEST */
  85116. static readonly ALPHA_SUBTRACT: number;
  85117. /** Defines that alpha blending to SRC * DEST */
  85118. static readonly ALPHA_MULTIPLY: number;
  85119. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  85120. static readonly ALPHA_MAXIMIZED: number;
  85121. /** Defines that alpha blending to SRC + DEST */
  85122. static readonly ALPHA_ONEONE: number;
  85123. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  85124. static readonly ALPHA_PREMULTIPLIED: number;
  85125. /**
  85126. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  85127. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85128. */
  85129. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85130. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  85131. static readonly ALPHA_INTERPOLATE: number;
  85132. /**
  85133. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  85134. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85135. */
  85136. static readonly ALPHA_SCREENMODE: number;
  85137. /** Defines that the ressource is not delayed*/
  85138. static readonly DELAYLOADSTATE_NONE: number;
  85139. /** Defines that the ressource was successfully delay loaded */
  85140. static readonly DELAYLOADSTATE_LOADED: number;
  85141. /** Defines that the ressource is currently delay loading */
  85142. static readonly DELAYLOADSTATE_LOADING: number;
  85143. /** Defines that the ressource is delayed and has not started loading */
  85144. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85145. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85146. static readonly NEVER: number;
  85147. /** 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 */
  85148. static readonly ALWAYS: number;
  85149. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85150. static readonly LESS: number;
  85151. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85152. static readonly EQUAL: number;
  85153. /** 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 */
  85154. static readonly LEQUAL: number;
  85155. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85156. static readonly GREATER: number;
  85157. /** 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 */
  85158. static readonly GEQUAL: number;
  85159. /** 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 */
  85160. static readonly NOTEQUAL: number;
  85161. /** Passed to stencilOperation to specify that stencil value must be kept */
  85162. static readonly KEEP: number;
  85163. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85164. static readonly REPLACE: number;
  85165. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85166. static readonly INCR: number;
  85167. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85168. static readonly DECR: number;
  85169. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85170. static readonly INVERT: number;
  85171. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85172. static readonly INCR_WRAP: number;
  85173. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85174. static readonly DECR_WRAP: number;
  85175. /** Texture is not repeating outside of 0..1 UVs */
  85176. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85177. /** Texture is repeating outside of 0..1 UVs */
  85178. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85179. /** Texture is repeating and mirrored */
  85180. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85181. /** ALPHA */
  85182. static readonly TEXTUREFORMAT_ALPHA: number;
  85183. /** LUMINANCE */
  85184. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85185. /** LUMINANCE_ALPHA */
  85186. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85187. /** RGB */
  85188. static readonly TEXTUREFORMAT_RGB: number;
  85189. /** RGBA */
  85190. static readonly TEXTUREFORMAT_RGBA: number;
  85191. /** RED */
  85192. static readonly TEXTUREFORMAT_RED: number;
  85193. /** RED (2nd reference) */
  85194. static readonly TEXTUREFORMAT_R: number;
  85195. /** RG */
  85196. static readonly TEXTUREFORMAT_RG: number;
  85197. /** RED_INTEGER */
  85198. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85199. /** RED_INTEGER (2nd reference) */
  85200. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85201. /** RG_INTEGER */
  85202. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85203. /** RGB_INTEGER */
  85204. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85205. /** RGBA_INTEGER */
  85206. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85207. /** UNSIGNED_BYTE */
  85208. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85209. /** UNSIGNED_BYTE (2nd reference) */
  85210. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85211. /** FLOAT */
  85212. static readonly TEXTURETYPE_FLOAT: number;
  85213. /** HALF_FLOAT */
  85214. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85215. /** BYTE */
  85216. static readonly TEXTURETYPE_BYTE: number;
  85217. /** SHORT */
  85218. static readonly TEXTURETYPE_SHORT: number;
  85219. /** UNSIGNED_SHORT */
  85220. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85221. /** INT */
  85222. static readonly TEXTURETYPE_INT: number;
  85223. /** UNSIGNED_INT */
  85224. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85225. /** UNSIGNED_SHORT_4_4_4_4 */
  85226. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85227. /** UNSIGNED_SHORT_5_5_5_1 */
  85228. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85229. /** UNSIGNED_SHORT_5_6_5 */
  85230. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85231. /** UNSIGNED_INT_2_10_10_10_REV */
  85232. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85233. /** UNSIGNED_INT_24_8 */
  85234. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85235. /** UNSIGNED_INT_10F_11F_11F_REV */
  85236. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85237. /** UNSIGNED_INT_5_9_9_9_REV */
  85238. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85239. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85240. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85241. /** nearest is mag = nearest and min = nearest and mip = linear */
  85242. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85243. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85244. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85245. /** Trilinear is mag = linear and min = linear and mip = linear */
  85246. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85247. /** nearest is mag = nearest and min = nearest and mip = linear */
  85248. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85249. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85250. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85251. /** Trilinear is mag = linear and min = linear and mip = linear */
  85252. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85253. /** mag = nearest and min = nearest and mip = nearest */
  85254. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85255. /** mag = nearest and min = linear and mip = nearest */
  85256. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85257. /** mag = nearest and min = linear and mip = linear */
  85258. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85259. /** mag = nearest and min = linear and mip = none */
  85260. static readonly TEXTURE_NEAREST_LINEAR: number;
  85261. /** mag = nearest and min = nearest and mip = none */
  85262. static readonly TEXTURE_NEAREST_NEAREST: number;
  85263. /** mag = linear and min = nearest and mip = nearest */
  85264. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85265. /** mag = linear and min = nearest and mip = linear */
  85266. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85267. /** mag = linear and min = linear and mip = none */
  85268. static readonly TEXTURE_LINEAR_LINEAR: number;
  85269. /** mag = linear and min = nearest and mip = none */
  85270. static readonly TEXTURE_LINEAR_NEAREST: number;
  85271. /** Explicit coordinates mode */
  85272. static readonly TEXTURE_EXPLICIT_MODE: number;
  85273. /** Spherical coordinates mode */
  85274. static readonly TEXTURE_SPHERICAL_MODE: number;
  85275. /** Planar coordinates mode */
  85276. static readonly TEXTURE_PLANAR_MODE: number;
  85277. /** Cubic coordinates mode */
  85278. static readonly TEXTURE_CUBIC_MODE: number;
  85279. /** Projection coordinates mode */
  85280. static readonly TEXTURE_PROJECTION_MODE: number;
  85281. /** Skybox coordinates mode */
  85282. static readonly TEXTURE_SKYBOX_MODE: number;
  85283. /** Inverse Cubic coordinates mode */
  85284. static readonly TEXTURE_INVCUBIC_MODE: number;
  85285. /** Equirectangular coordinates mode */
  85286. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85287. /** Equirectangular Fixed coordinates mode */
  85288. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85289. /** Equirectangular Fixed Mirrored coordinates mode */
  85290. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85291. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85292. static readonly SCALEMODE_FLOOR: number;
  85293. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85294. static readonly SCALEMODE_NEAREST: number;
  85295. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85296. static readonly SCALEMODE_CEILING: number;
  85297. /**
  85298. * Returns the current npm package of the sdk
  85299. */
  85300. static readonly NpmPackage: string;
  85301. /**
  85302. * Returns the current version of the framework
  85303. */
  85304. static readonly Version: string;
  85305. /**
  85306. * Returns a string describing the current engine
  85307. */
  85308. readonly description: string;
  85309. /**
  85310. * Gets or sets the epsilon value used by collision engine
  85311. */
  85312. static CollisionsEpsilon: number;
  85313. /**
  85314. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85315. */
  85316. static ShadersRepository: string;
  85317. /**
  85318. * Method called to create the default loading screen.
  85319. * This can be overriden in your own app.
  85320. * @param canvas The rendering canvas element
  85321. * @returns The loading screen
  85322. */
  85323. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  85324. /**
  85325. * Method called to create the default rescale post process on each engine.
  85326. */
  85327. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  85328. /**
  85329. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  85330. */
  85331. forcePOTTextures: boolean;
  85332. /**
  85333. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  85334. */
  85335. isFullscreen: boolean;
  85336. /**
  85337. * Gets a boolean indicating if the pointer is currently locked
  85338. */
  85339. isPointerLock: boolean;
  85340. /**
  85341. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  85342. */
  85343. cullBackFaces: boolean;
  85344. /**
  85345. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  85346. */
  85347. renderEvenInBackground: boolean;
  85348. /**
  85349. * Gets or sets a boolean indicating that cache can be kept between frames
  85350. */
  85351. preventCacheWipeBetweenFrames: boolean;
  85352. /**
  85353. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  85354. **/
  85355. enableOfflineSupport: boolean;
  85356. /**
  85357. * 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)
  85358. **/
  85359. disableManifestCheck: boolean;
  85360. /**
  85361. * Gets the list of created scenes
  85362. */
  85363. scenes: Scene[];
  85364. /**
  85365. * Event raised when a new scene is created
  85366. */
  85367. onNewSceneAddedObservable: Observable<Scene>;
  85368. /**
  85369. * Gets the list of created postprocesses
  85370. */
  85371. postProcesses: PostProcess[];
  85372. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  85373. validateShaderPrograms: boolean;
  85374. /**
  85375. * Observable event triggered each time the rendering canvas is resized
  85376. */
  85377. onResizeObservable: Observable<Engine>;
  85378. /**
  85379. * Observable event triggered each time the canvas loses focus
  85380. */
  85381. onCanvasBlurObservable: Observable<Engine>;
  85382. /**
  85383. * Observable event triggered each time the canvas gains focus
  85384. */
  85385. onCanvasFocusObservable: Observable<Engine>;
  85386. /**
  85387. * Observable event triggered each time the canvas receives pointerout event
  85388. */
  85389. onCanvasPointerOutObservable: Observable<PointerEvent>;
  85390. /**
  85391. * Observable event triggered before each texture is initialized
  85392. */
  85393. onBeforeTextureInitObservable: Observable<Texture>;
  85394. private _vrDisplay;
  85395. private _vrSupported;
  85396. private _oldSize;
  85397. private _oldHardwareScaleFactor;
  85398. private _vrExclusivePointerMode;
  85399. private _webVRInitPromise;
  85400. /**
  85401. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85402. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85403. */
  85404. readonly isInVRExclusivePointerMode: boolean;
  85405. /**
  85406. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  85407. */
  85408. disableUniformBuffers: boolean;
  85409. /** @hidden */
  85410. _uniformBuffers: UniformBuffer[];
  85411. /**
  85412. * Gets a boolean indicating that the engine supports uniform buffers
  85413. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85414. */
  85415. readonly supportsUniformBuffers: boolean;
  85416. /**
  85417. * Observable raised when the engine begins a new frame
  85418. */
  85419. onBeginFrameObservable: Observable<Engine>;
  85420. /**
  85421. * If set, will be used to request the next animation frame for the render loop
  85422. */
  85423. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  85424. /**
  85425. * Observable raised when the engine ends the current frame
  85426. */
  85427. onEndFrameObservable: Observable<Engine>;
  85428. /**
  85429. * Observable raised when the engine is about to compile a shader
  85430. */
  85431. onBeforeShaderCompilationObservable: Observable<Engine>;
  85432. /**
  85433. * Observable raised when the engine has jsut compiled a shader
  85434. */
  85435. onAfterShaderCompilationObservable: Observable<Engine>;
  85436. /** @hidden */
  85437. _gl: WebGLRenderingContext;
  85438. private _renderingCanvas;
  85439. private _windowIsBackground;
  85440. private _webGLVersion;
  85441. protected _highPrecisionShadersAllowed: boolean;
  85442. /** @hidden */
  85443. readonly _shouldUseHighPrecisionShader: boolean;
  85444. /**
  85445. * Gets a boolean indicating that only power of 2 textures are supported
  85446. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  85447. */
  85448. readonly needPOTTextures: boolean;
  85449. /** @hidden */
  85450. _badOS: boolean;
  85451. /** @hidden */
  85452. _badDesktopOS: boolean;
  85453. /**
  85454. * Gets or sets a value indicating if we want to disable texture binding optimization.
  85455. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  85456. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  85457. */
  85458. disableTextureBindingOptimization: boolean;
  85459. /**
  85460. * Gets the audio engine
  85461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85462. * @ignorenaming
  85463. */
  85464. static audioEngine: IAudioEngine;
  85465. /**
  85466. * Default AudioEngine factory responsible of creating the Audio Engine.
  85467. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  85468. */
  85469. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  85470. /**
  85471. * Default offline support factory responsible of creating a tool used to store data locally.
  85472. * By default, this will create a Database object if the workload has been embedded.
  85473. */
  85474. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  85475. private _onFocus;
  85476. private _onBlur;
  85477. private _onCanvasPointerOut;
  85478. private _onCanvasBlur;
  85479. private _onCanvasFocus;
  85480. private _onFullscreenChange;
  85481. private _onPointerLockChange;
  85482. private _onVRDisplayPointerRestricted;
  85483. private _onVRDisplayPointerUnrestricted;
  85484. private _onVrDisplayConnect;
  85485. private _onVrDisplayDisconnect;
  85486. private _onVrDisplayPresentChange;
  85487. /**
  85488. * Observable signaled when VR display mode changes
  85489. */
  85490. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85491. /**
  85492. * Observable signaled when VR request present is complete
  85493. */
  85494. onVRRequestPresentComplete: Observable<boolean>;
  85495. /**
  85496. * Observable signaled when VR request present starts
  85497. */
  85498. onVRRequestPresentStart: Observable<Engine>;
  85499. private _hardwareScalingLevel;
  85500. /** @hidden */
  85501. protected _caps: EngineCapabilities;
  85502. private _pointerLockRequested;
  85503. private _isStencilEnable;
  85504. private _colorWrite;
  85505. private _loadingScreen;
  85506. /** @hidden */
  85507. _drawCalls: PerfCounter;
  85508. /** @hidden */
  85509. _textureCollisions: PerfCounter;
  85510. private _glVersion;
  85511. private _glRenderer;
  85512. private _glVendor;
  85513. private _videoTextureSupported;
  85514. private _renderingQueueLaunched;
  85515. private _activeRenderLoops;
  85516. private _deterministicLockstep;
  85517. private _lockstepMaxSteps;
  85518. /**
  85519. * Observable signaled when a context lost event is raised
  85520. */
  85521. onContextLostObservable: Observable<Engine>;
  85522. /**
  85523. * Observable signaled when a context restored event is raised
  85524. */
  85525. onContextRestoredObservable: Observable<Engine>;
  85526. private _onContextLost;
  85527. private _onContextRestored;
  85528. private _contextWasLost;
  85529. private _doNotHandleContextLost;
  85530. /**
  85531. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  85532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  85533. */
  85534. doNotHandleContextLost: boolean;
  85535. private _performanceMonitor;
  85536. private _fps;
  85537. private _deltaTime;
  85538. /**
  85539. * Turn this value on if you want to pause FPS computation when in background
  85540. */
  85541. disablePerformanceMonitorInBackground: boolean;
  85542. /**
  85543. * Gets the performance monitor attached to this engine
  85544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  85545. */
  85546. readonly performanceMonitor: PerformanceMonitor;
  85547. /** @hidden */
  85548. protected _depthCullingState: _DepthCullingState;
  85549. /** @hidden */
  85550. protected _stencilState: _StencilState;
  85551. /** @hidden */
  85552. protected _alphaState: _AlphaState;
  85553. /** @hidden */
  85554. protected _alphaMode: number;
  85555. protected _internalTexturesCache: InternalTexture[];
  85556. /** @hidden */
  85557. protected _activeChannel: number;
  85558. private _currentTextureChannel;
  85559. /** @hidden */
  85560. protected _boundTexturesCache: {
  85561. [key: string]: Nullable<InternalTexture>;
  85562. };
  85563. /** @hidden */
  85564. protected _currentEffect: Nullable<Effect>;
  85565. /** @hidden */
  85566. protected _currentProgram: Nullable<WebGLProgram>;
  85567. private _compiledEffects;
  85568. private _vertexAttribArraysEnabled;
  85569. /** @hidden */
  85570. protected _cachedViewport: Nullable<Viewport>;
  85571. private _cachedVertexArrayObject;
  85572. /** @hidden */
  85573. protected _cachedVertexBuffers: any;
  85574. /** @hidden */
  85575. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  85576. /** @hidden */
  85577. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  85578. /** @hidden */
  85579. protected _currentRenderTarget: Nullable<InternalTexture>;
  85580. private _uintIndicesCurrentlySet;
  85581. private _currentBoundBuffer;
  85582. /** @hidden */
  85583. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  85584. private _currentBufferPointers;
  85585. private _currentInstanceLocations;
  85586. private _currentInstanceBuffers;
  85587. private _textureUnits;
  85588. private _firstBoundInternalTextureTracker;
  85589. private _lastBoundInternalTextureTracker;
  85590. private _workingCanvas;
  85591. private _workingContext;
  85592. private _rescalePostProcess;
  85593. private _dummyFramebuffer;
  85594. private _externalData;
  85595. private _bindedRenderFunction;
  85596. private _vaoRecordInProgress;
  85597. private _mustWipeVertexAttributes;
  85598. private _emptyTexture;
  85599. private _emptyCubeTexture;
  85600. private _emptyTexture3D;
  85601. /** @hidden */
  85602. _frameHandler: number;
  85603. private _nextFreeTextureSlots;
  85604. private _maxSimultaneousTextures;
  85605. private _activeRequests;
  85606. private _texturesSupported;
  85607. private _textureFormatInUse;
  85608. /**
  85609. * Gets the list of texture formats supported
  85610. */
  85611. readonly texturesSupported: Array<string>;
  85612. /**
  85613. * Gets the list of texture formats in use
  85614. */
  85615. readonly textureFormatInUse: Nullable<string>;
  85616. /**
  85617. * Gets the current viewport
  85618. */
  85619. readonly currentViewport: Nullable<Viewport>;
  85620. /**
  85621. * Gets the default empty texture
  85622. */
  85623. readonly emptyTexture: InternalTexture;
  85624. /**
  85625. * Gets the default empty 3D texture
  85626. */
  85627. readonly emptyTexture3D: InternalTexture;
  85628. /**
  85629. * Gets the default empty cube texture
  85630. */
  85631. readonly emptyCubeTexture: InternalTexture;
  85632. /**
  85633. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  85634. */
  85635. readonly premultipliedAlpha: boolean;
  85636. /**
  85637. * Creates a new engine
  85638. * @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
  85639. * @param antialias defines enable antialiasing (default: false)
  85640. * @param options defines further options to be sent to the getContext() function
  85641. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  85642. */
  85643. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  85644. private _disableTouchAction;
  85645. private _rebuildInternalTextures;
  85646. private _rebuildEffects;
  85647. /**
  85648. * Gets a boolean indicating if all created effects are ready
  85649. * @returns true if all effects are ready
  85650. */
  85651. areAllEffectsReady(): boolean;
  85652. private _rebuildBuffers;
  85653. private _initGLContext;
  85654. /**
  85655. * Gets version of the current webGL context
  85656. */
  85657. readonly webGLVersion: number;
  85658. /**
  85659. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  85660. */
  85661. readonly isStencilEnable: boolean;
  85662. private _prepareWorkingCanvas;
  85663. /**
  85664. * Reset the texture cache to empty state
  85665. */
  85666. resetTextureCache(): void;
  85667. /**
  85668. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  85669. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85670. * @returns true if engine is in deterministic lock step mode
  85671. */
  85672. isDeterministicLockStep(): boolean;
  85673. /**
  85674. * Gets the max steps when engine is running in deterministic lock step
  85675. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85676. * @returns the max steps
  85677. */
  85678. getLockstepMaxSteps(): number;
  85679. /**
  85680. * Gets an object containing information about the current webGL context
  85681. * @returns an object containing the vender, the renderer and the version of the current webGL context
  85682. */
  85683. getGlInfo(): {
  85684. vendor: string;
  85685. renderer: string;
  85686. version: string;
  85687. };
  85688. /**
  85689. * Gets current aspect ratio
  85690. * @param camera defines the camera to use to get the aspect ratio
  85691. * @param useScreen defines if screen size must be used (or the current render target if any)
  85692. * @returns a number defining the aspect ratio
  85693. */
  85694. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  85695. /**
  85696. * Gets current screen aspect ratio
  85697. * @returns a number defining the aspect ratio
  85698. */
  85699. getScreenAspectRatio(): number;
  85700. /**
  85701. * Gets the current render width
  85702. * @param useScreen defines if screen size must be used (or the current render target if any)
  85703. * @returns a number defining the current render width
  85704. */
  85705. getRenderWidth(useScreen?: boolean): number;
  85706. /**
  85707. * Gets the current render height
  85708. * @param useScreen defines if screen size must be used (or the current render target if any)
  85709. * @returns a number defining the current render height
  85710. */
  85711. getRenderHeight(useScreen?: boolean): number;
  85712. /**
  85713. * Gets the HTML canvas attached with the current webGL context
  85714. * @returns a HTML canvas
  85715. */
  85716. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  85717. /**
  85718. * Gets the client rect of the HTML canvas attached with the current webGL context
  85719. * @returns a client rectanglee
  85720. */
  85721. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  85722. /**
  85723. * Defines the hardware scaling level.
  85724. * By default the hardware scaling level is computed from the window device ratio.
  85725. * 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.
  85726. * @param level defines the level to use
  85727. */
  85728. setHardwareScalingLevel(level: number): void;
  85729. /**
  85730. * Gets the current hardware scaling level.
  85731. * By default the hardware scaling level is computed from the window device ratio.
  85732. * 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.
  85733. * @returns a number indicating the current hardware scaling level
  85734. */
  85735. getHardwareScalingLevel(): number;
  85736. /**
  85737. * Gets the list of loaded textures
  85738. * @returns an array containing all loaded textures
  85739. */
  85740. getLoadedTexturesCache(): InternalTexture[];
  85741. /**
  85742. * Gets the object containing all engine capabilities
  85743. * @returns the EngineCapabilities object
  85744. */
  85745. getCaps(): EngineCapabilities;
  85746. /**
  85747. * Gets the current depth function
  85748. * @returns a number defining the depth function
  85749. */
  85750. getDepthFunction(): Nullable<number>;
  85751. /**
  85752. * Sets the current depth function
  85753. * @param depthFunc defines the function to use
  85754. */
  85755. setDepthFunction(depthFunc: number): void;
  85756. /**
  85757. * Sets the current depth function to GREATER
  85758. */
  85759. setDepthFunctionToGreater(): void;
  85760. /**
  85761. * Sets the current depth function to GEQUAL
  85762. */
  85763. setDepthFunctionToGreaterOrEqual(): void;
  85764. /**
  85765. * Sets the current depth function to LESS
  85766. */
  85767. setDepthFunctionToLess(): void;
  85768. /**
  85769. * Sets the current depth function to LEQUAL
  85770. */
  85771. setDepthFunctionToLessOrEqual(): void;
  85772. /**
  85773. * Gets a boolean indicating if stencil buffer is enabled
  85774. * @returns the current stencil buffer state
  85775. */
  85776. getStencilBuffer(): boolean;
  85777. /**
  85778. * Enable or disable the stencil buffer
  85779. * @param enable defines if the stencil buffer must be enabled or disabled
  85780. */
  85781. setStencilBuffer(enable: boolean): void;
  85782. /**
  85783. * Gets the current stencil mask
  85784. * @returns a number defining the new stencil mask to use
  85785. */
  85786. getStencilMask(): number;
  85787. /**
  85788. * Sets the current stencil mask
  85789. * @param mask defines the new stencil mask to use
  85790. */
  85791. setStencilMask(mask: number): void;
  85792. /**
  85793. * Gets the current stencil function
  85794. * @returns a number defining the stencil function to use
  85795. */
  85796. getStencilFunction(): number;
  85797. /**
  85798. * Gets the current stencil reference value
  85799. * @returns a number defining the stencil reference value to use
  85800. */
  85801. getStencilFunctionReference(): number;
  85802. /**
  85803. * Gets the current stencil mask
  85804. * @returns a number defining the stencil mask to use
  85805. */
  85806. getStencilFunctionMask(): number;
  85807. /**
  85808. * Sets the current stencil function
  85809. * @param stencilFunc defines the new stencil function to use
  85810. */
  85811. setStencilFunction(stencilFunc: number): void;
  85812. /**
  85813. * Sets the current stencil reference
  85814. * @param reference defines the new stencil reference to use
  85815. */
  85816. setStencilFunctionReference(reference: number): void;
  85817. /**
  85818. * Sets the current stencil mask
  85819. * @param mask defines the new stencil mask to use
  85820. */
  85821. setStencilFunctionMask(mask: number): void;
  85822. /**
  85823. * Gets the current stencil operation when stencil fails
  85824. * @returns a number defining stencil operation to use when stencil fails
  85825. */
  85826. getStencilOperationFail(): number;
  85827. /**
  85828. * Gets the current stencil operation when depth fails
  85829. * @returns a number defining stencil operation to use when depth fails
  85830. */
  85831. getStencilOperationDepthFail(): number;
  85832. /**
  85833. * Gets the current stencil operation when stencil passes
  85834. * @returns a number defining stencil operation to use when stencil passes
  85835. */
  85836. getStencilOperationPass(): number;
  85837. /**
  85838. * Sets the stencil operation to use when stencil fails
  85839. * @param operation defines the stencil operation to use when stencil fails
  85840. */
  85841. setStencilOperationFail(operation: number): void;
  85842. /**
  85843. * Sets the stencil operation to use when depth fails
  85844. * @param operation defines the stencil operation to use when depth fails
  85845. */
  85846. setStencilOperationDepthFail(operation: number): void;
  85847. /**
  85848. * Sets the stencil operation to use when stencil passes
  85849. * @param operation defines the stencil operation to use when stencil passes
  85850. */
  85851. setStencilOperationPass(operation: number): void;
  85852. /**
  85853. * Sets a boolean indicating if the dithering state is enabled or disabled
  85854. * @param value defines the dithering state
  85855. */
  85856. setDitheringState(value: boolean): void;
  85857. /**
  85858. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  85859. * @param value defines the rasterizer state
  85860. */
  85861. setRasterizerState(value: boolean): void;
  85862. /**
  85863. * stop executing a render loop function and remove it from the execution array
  85864. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  85865. */
  85866. stopRenderLoop(renderFunction?: () => void): void;
  85867. /** @hidden */
  85868. _renderLoop(): void;
  85869. /**
  85870. * Register and execute a render loop. The engine can have more than one render function
  85871. * @param renderFunction defines the function to continuously execute
  85872. */
  85873. runRenderLoop(renderFunction: () => void): void;
  85874. /**
  85875. * Toggle full screen mode
  85876. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85877. */
  85878. switchFullscreen(requestPointerLock: boolean): void;
  85879. /**
  85880. * Enters full screen mode
  85881. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85882. */
  85883. enterFullscreen(requestPointerLock: boolean): void;
  85884. /**
  85885. * Exits full screen mode
  85886. */
  85887. exitFullscreen(): void;
  85888. /**
  85889. * Clear the current render buffer or the current render target (if any is set up)
  85890. * @param color defines the color to use
  85891. * @param backBuffer defines if the back buffer must be cleared
  85892. * @param depth defines if the depth buffer must be cleared
  85893. * @param stencil defines if the stencil buffer must be cleared
  85894. */
  85895. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  85896. /**
  85897. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  85898. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85899. * @param y defines the y-coordinate of the corner of the clear rectangle
  85900. * @param width defines the width of the clear rectangle
  85901. * @param height defines the height of the clear rectangle
  85902. * @param clearColor defines the clear color
  85903. */
  85904. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  85905. /**
  85906. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  85907. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85908. * @param y defines the y-coordinate of the corner of the clear rectangle
  85909. * @param width defines the width of the clear rectangle
  85910. * @param height defines the height of the clear rectangle
  85911. */
  85912. enableScissor(x: number, y: number, width: number, height: number): void;
  85913. /**
  85914. * Disable previously set scissor test rectangle
  85915. */
  85916. disableScissor(): void;
  85917. private _viewportCached;
  85918. /** @hidden */
  85919. _viewport(x: number, y: number, width: number, height: number): void;
  85920. /**
  85921. * Set the WebGL's viewport
  85922. * @param viewport defines the viewport element to be used
  85923. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  85924. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  85925. */
  85926. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  85927. /**
  85928. * Directly set the WebGL Viewport
  85929. * @param x defines the x coordinate of the viewport (in screen space)
  85930. * @param y defines the y coordinate of the viewport (in screen space)
  85931. * @param width defines the width of the viewport (in screen space)
  85932. * @param height defines the height of the viewport (in screen space)
  85933. * @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
  85934. */
  85935. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  85936. /**
  85937. * Begin a new frame
  85938. */
  85939. beginFrame(): void;
  85940. /**
  85941. * Enf the current frame
  85942. */
  85943. endFrame(): void;
  85944. /**
  85945. * Resize the view according to the canvas' size
  85946. */
  85947. resize(): void;
  85948. /**
  85949. * Force a specific size of the canvas
  85950. * @param width defines the new canvas' width
  85951. * @param height defines the new canvas' height
  85952. */
  85953. setSize(width: number, height: number): void;
  85954. /**
  85955. * Gets a boolean indicating if a webVR device was detected
  85956. * @returns true if a webVR device was detected
  85957. */
  85958. isVRDevicePresent(): boolean;
  85959. /**
  85960. * Gets the current webVR device
  85961. * @returns the current webVR device (or null)
  85962. */
  85963. getVRDevice(): any;
  85964. /**
  85965. * Initializes a webVR display and starts listening to display change events
  85966. * The onVRDisplayChangedObservable will be notified upon these changes
  85967. * @returns The onVRDisplayChangedObservable
  85968. */
  85969. initWebVR(): Observable<IDisplayChangedEventArgs>;
  85970. /**
  85971. * Initializes a webVR display and starts listening to display change events
  85972. * The onVRDisplayChangedObservable will be notified upon these changes
  85973. * @returns A promise containing a VRDisplay and if vr is supported
  85974. */
  85975. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85976. /**
  85977. * Call this function to switch to webVR mode
  85978. * Will do nothing if webVR is not supported or if there is no webVR device
  85979. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85980. */
  85981. enableVR(): void;
  85982. /**
  85983. * Call this function to leave webVR mode
  85984. * Will do nothing if webVR is not supported or if there is no webVR device
  85985. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85986. */
  85987. disableVR(): void;
  85988. private _onVRFullScreenTriggered;
  85989. private _getVRDisplaysAsync;
  85990. /**
  85991. * Binds the frame buffer to the specified texture.
  85992. * @param texture The texture to render to or null for the default canvas
  85993. * @param faceIndex The face of the texture to render to in case of cube texture
  85994. * @param requiredWidth The width of the target to render to
  85995. * @param requiredHeight The height of the target to render to
  85996. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  85997. * @param depthStencilTexture The depth stencil texture to use to render
  85998. * @param lodLevel defines le lod level to bind to the frame buffer
  85999. */
  86000. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  86001. private bindUnboundFramebuffer;
  86002. /**
  86003. * Unbind the current render target texture from the webGL context
  86004. * @param texture defines the render target texture to unbind
  86005. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86006. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86007. */
  86008. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86009. /**
  86010. * Unbind a list of render target textures from the webGL context
  86011. * This is used only when drawBuffer extension or webGL2 are active
  86012. * @param textures defines the render target textures to unbind
  86013. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86014. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86015. */
  86016. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86017. /**
  86018. * Force the mipmap generation for the given render target texture
  86019. * @param texture defines the render target texture to use
  86020. */
  86021. generateMipMapsForCubemap(texture: InternalTexture): void;
  86022. /**
  86023. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  86024. */
  86025. flushFramebuffer(): void;
  86026. /**
  86027. * Unbind the current render target and bind the default framebuffer
  86028. */
  86029. restoreDefaultFramebuffer(): void;
  86030. /**
  86031. * Create an uniform buffer
  86032. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86033. * @param elements defines the content of the uniform buffer
  86034. * @returns the webGL uniform buffer
  86035. */
  86036. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  86037. /**
  86038. * Create a dynamic uniform buffer
  86039. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86040. * @param elements defines the content of the uniform buffer
  86041. * @returns the webGL uniform buffer
  86042. */
  86043. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  86044. /**
  86045. * Update an existing uniform buffer
  86046. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86047. * @param uniformBuffer defines the target uniform buffer
  86048. * @param elements defines the content to update
  86049. * @param offset defines the offset in the uniform buffer where update should start
  86050. * @param count defines the size of the data to update
  86051. */
  86052. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86053. private _resetVertexBufferBinding;
  86054. /**
  86055. * Creates a vertex buffer
  86056. * @param data the data for the vertex buffer
  86057. * @returns the new WebGL static buffer
  86058. */
  86059. createVertexBuffer(data: DataArray): WebGLBuffer;
  86060. /**
  86061. * Creates a dynamic vertex buffer
  86062. * @param data the data for the dynamic vertex buffer
  86063. * @returns the new WebGL dynamic buffer
  86064. */
  86065. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  86066. /**
  86067. * Update a dynamic index buffer
  86068. * @param indexBuffer defines the target index buffer
  86069. * @param indices defines the data to update
  86070. * @param offset defines the offset in the target index buffer where update should start
  86071. */
  86072. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86073. /**
  86074. * Updates a dynamic vertex buffer.
  86075. * @param vertexBuffer the vertex buffer to update
  86076. * @param data the data used to update the vertex buffer
  86077. * @param byteOffset the byte offset of the data
  86078. * @param byteLength the byte length of the data
  86079. */
  86080. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86081. private _resetIndexBufferBinding;
  86082. /**
  86083. * Creates a new index buffer
  86084. * @param indices defines the content of the index buffer
  86085. * @param updatable defines if the index buffer must be updatable
  86086. * @returns a new webGL buffer
  86087. */
  86088. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  86089. /**
  86090. * Bind a webGL buffer to the webGL context
  86091. * @param buffer defines the buffer to bind
  86092. */
  86093. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  86094. /**
  86095. * Bind an uniform buffer to the current webGL context
  86096. * @param buffer defines the buffer to bind
  86097. */
  86098. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  86099. /**
  86100. * Bind a buffer to the current webGL context at a given location
  86101. * @param buffer defines the buffer to bind
  86102. * @param location defines the index where to bind the buffer
  86103. */
  86104. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  86105. /**
  86106. * Bind a specific block at a given index in a specific shader program
  86107. * @param shaderProgram defines the shader program
  86108. * @param blockName defines the block name
  86109. * @param index defines the index where to bind the block
  86110. */
  86111. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  86112. private bindIndexBuffer;
  86113. private bindBuffer;
  86114. /**
  86115. * update the bound buffer with the given data
  86116. * @param data defines the data to update
  86117. */
  86118. updateArrayBuffer(data: Float32Array): void;
  86119. private _vertexAttribPointer;
  86120. private _bindIndexBufferWithCache;
  86121. private _bindVertexBuffersAttributes;
  86122. /**
  86123. * Records a vertex array object
  86124. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86125. * @param vertexBuffers defines the list of vertex buffers to store
  86126. * @param indexBuffer defines the index buffer to store
  86127. * @param effect defines the effect to store
  86128. * @returns the new vertex array object
  86129. */
  86130. recordVertexArrayObject(vertexBuffers: {
  86131. [key: string]: VertexBuffer;
  86132. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  86133. /**
  86134. * Bind a specific vertex array object
  86135. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86136. * @param vertexArrayObject defines the vertex array object to bind
  86137. * @param indexBuffer defines the index buffer to bind
  86138. */
  86139. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  86140. /**
  86141. * Bind webGl buffers directly to the webGL context
  86142. * @param vertexBuffer defines the vertex buffer to bind
  86143. * @param indexBuffer defines the index buffer to bind
  86144. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  86145. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  86146. * @param effect defines the effect associated with the vertex buffer
  86147. */
  86148. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  86149. private _unbindVertexArrayObject;
  86150. /**
  86151. * Bind a list of vertex buffers to the webGL context
  86152. * @param vertexBuffers defines the list of vertex buffers to bind
  86153. * @param indexBuffer defines the index buffer to bind
  86154. * @param effect defines the effect associated with the vertex buffers
  86155. */
  86156. bindBuffers(vertexBuffers: {
  86157. [key: string]: Nullable<VertexBuffer>;
  86158. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  86159. /**
  86160. * Unbind all instance attributes
  86161. */
  86162. unbindInstanceAttributes(): void;
  86163. /**
  86164. * Release and free the memory of a vertex array object
  86165. * @param vao defines the vertex array object to delete
  86166. */
  86167. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  86168. /** @hidden */
  86169. _releaseBuffer(buffer: WebGLBuffer): boolean;
  86170. /**
  86171. * Creates a webGL buffer to use with instanciation
  86172. * @param capacity defines the size of the buffer
  86173. * @returns the webGL buffer
  86174. */
  86175. createInstancesBuffer(capacity: number): WebGLBuffer;
  86176. /**
  86177. * Delete a webGL buffer used with instanciation
  86178. * @param buffer defines the webGL buffer to delete
  86179. */
  86180. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  86181. /**
  86182. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  86183. * @param instancesBuffer defines the webGL buffer to update and bind
  86184. * @param data defines the data to store in the buffer
  86185. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  86186. */
  86187. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  86188. /**
  86189. * Apply all cached states (depth, culling, stencil and alpha)
  86190. */
  86191. applyStates(): void;
  86192. /**
  86193. * Send a draw order
  86194. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86195. * @param indexStart defines the starting index
  86196. * @param indexCount defines the number of index to draw
  86197. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86198. */
  86199. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  86200. /**
  86201. * Draw a list of points
  86202. * @param verticesStart defines the index of first vertex to draw
  86203. * @param verticesCount defines the count of vertices to draw
  86204. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86205. */
  86206. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86207. /**
  86208. * Draw a list of unindexed primitives
  86209. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86210. * @param verticesStart defines the index of first vertex to draw
  86211. * @param verticesCount defines the count of vertices to draw
  86212. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86213. */
  86214. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86215. /**
  86216. * Draw a list of indexed primitives
  86217. * @param fillMode defines the primitive to use
  86218. * @param indexStart defines the starting index
  86219. * @param indexCount defines the number of index to draw
  86220. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86221. */
  86222. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  86223. /**
  86224. * Draw a list of unindexed primitives
  86225. * @param fillMode defines the primitive to use
  86226. * @param verticesStart defines the index of first vertex to draw
  86227. * @param verticesCount defines the count of vertices to draw
  86228. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86229. */
  86230. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86231. private _drawMode;
  86232. /** @hidden */
  86233. _releaseEffect(effect: Effect): void;
  86234. /** @hidden */
  86235. _deleteProgram(program: WebGLProgram): void;
  86236. /**
  86237. * Create a new effect (used to store vertex/fragment shaders)
  86238. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  86239. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  86240. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  86241. * @param samplers defines an array of string used to represent textures
  86242. * @param defines defines the string containing the defines to use to compile the shaders
  86243. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  86244. * @param onCompiled defines a function to call when the effect creation is successful
  86245. * @param onError defines a function to call when the effect creation has failed
  86246. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  86247. * @returns the new Effect
  86248. */
  86249. 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;
  86250. private _compileShader;
  86251. private _compileRawShader;
  86252. /**
  86253. * Directly creates a webGL program
  86254. * @param vertexCode defines the vertex shader code to use
  86255. * @param fragmentCode defines the fragment shader code to use
  86256. * @param context defines the webGL context to use (if not set, the current one will be used)
  86257. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86258. * @returns the new webGL program
  86259. */
  86260. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86261. /**
  86262. * Creates a webGL program
  86263. * @param vertexCode defines the vertex shader code to use
  86264. * @param fragmentCode defines the fragment shader code to use
  86265. * @param defines defines the string containing the defines to use to compile the shaders
  86266. * @param context defines the webGL context to use (if not set, the current one will be used)
  86267. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86268. * @returns the new webGL program
  86269. */
  86270. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86271. private _createShaderProgram;
  86272. private _finalizeProgram;
  86273. /** @hidden */
  86274. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  86275. /** @hidden */
  86276. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  86277. /**
  86278. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  86279. * @param shaderProgram defines the webGL program to use
  86280. * @param uniformsNames defines the list of uniform names
  86281. * @returns an array of webGL uniform locations
  86282. */
  86283. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  86284. /**
  86285. * Gets the lsit of active attributes for a given webGL program
  86286. * @param shaderProgram defines the webGL program to use
  86287. * @param attributesNames defines the list of attribute names to get
  86288. * @returns an array of indices indicating the offset of each attribute
  86289. */
  86290. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  86291. /**
  86292. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  86293. * @param effect defines the effect to activate
  86294. */
  86295. enableEffect(effect: Nullable<Effect>): void;
  86296. /**
  86297. * Set the value of an uniform to an array of int32
  86298. * @param uniform defines the webGL uniform location where to store the value
  86299. * @param array defines the array of int32 to store
  86300. */
  86301. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86302. /**
  86303. * Set the value of an uniform to an array of int32 (stored as vec2)
  86304. * @param uniform defines the webGL uniform location where to store the value
  86305. * @param array defines the array of int32 to store
  86306. */
  86307. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86308. /**
  86309. * Set the value of an uniform to an array of int32 (stored as vec3)
  86310. * @param uniform defines the webGL uniform location where to store the value
  86311. * @param array defines the array of int32 to store
  86312. */
  86313. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86314. /**
  86315. * Set the value of an uniform to an array of int32 (stored as vec4)
  86316. * @param uniform defines the webGL uniform location where to store the value
  86317. * @param array defines the array of int32 to store
  86318. */
  86319. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86320. /**
  86321. * Set the value of an uniform to an array of float32
  86322. * @param uniform defines the webGL uniform location where to store the value
  86323. * @param array defines the array of float32 to store
  86324. */
  86325. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86326. /**
  86327. * Set the value of an uniform to an array of float32 (stored as vec2)
  86328. * @param uniform defines the webGL uniform location where to store the value
  86329. * @param array defines the array of float32 to store
  86330. */
  86331. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86332. /**
  86333. * Set the value of an uniform to an array of float32 (stored as vec3)
  86334. * @param uniform defines the webGL uniform location where to store the value
  86335. * @param array defines the array of float32 to store
  86336. */
  86337. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86338. /**
  86339. * Set the value of an uniform to an array of float32 (stored as vec4)
  86340. * @param uniform defines the webGL uniform location where to store the value
  86341. * @param array defines the array of float32 to store
  86342. */
  86343. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86344. /**
  86345. * Set the value of an uniform to an array of number
  86346. * @param uniform defines the webGL uniform location where to store the value
  86347. * @param array defines the array of number to store
  86348. */
  86349. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86350. /**
  86351. * Set the value of an uniform to an array of number (stored as vec2)
  86352. * @param uniform defines the webGL uniform location where to store the value
  86353. * @param array defines the array of number to store
  86354. */
  86355. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86356. /**
  86357. * Set the value of an uniform to an array of number (stored as vec3)
  86358. * @param uniform defines the webGL uniform location where to store the value
  86359. * @param array defines the array of number to store
  86360. */
  86361. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86362. /**
  86363. * Set the value of an uniform to an array of number (stored as vec4)
  86364. * @param uniform defines the webGL uniform location where to store the value
  86365. * @param array defines the array of number to store
  86366. */
  86367. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86368. /**
  86369. * Set the value of an uniform to an array of float32 (stored as matrices)
  86370. * @param uniform defines the webGL uniform location where to store the value
  86371. * @param matrices defines the array of float32 to store
  86372. */
  86373. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  86374. /**
  86375. * Set the value of an uniform to a matrix
  86376. * @param uniform defines the webGL uniform location where to store the value
  86377. * @param matrix defines the matrix to store
  86378. */
  86379. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  86380. /**
  86381. * Set the value of an uniform to a matrix (3x3)
  86382. * @param uniform defines the webGL uniform location where to store the value
  86383. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  86384. */
  86385. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86386. /**
  86387. * Set the value of an uniform to a matrix (2x2)
  86388. * @param uniform defines the webGL uniform location where to store the value
  86389. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  86390. */
  86391. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86392. /**
  86393. * Set the value of an uniform to a number (int)
  86394. * @param uniform defines the webGL uniform location where to store the value
  86395. * @param value defines the int number to store
  86396. */
  86397. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86398. /**
  86399. * Set the value of an uniform to a number (float)
  86400. * @param uniform defines the webGL uniform location where to store the value
  86401. * @param value defines the float number to store
  86402. */
  86403. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86404. /**
  86405. * Set the value of an uniform to a vec2
  86406. * @param uniform defines the webGL uniform location where to store the value
  86407. * @param x defines the 1st component of the value
  86408. * @param y defines the 2nd component of the value
  86409. */
  86410. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  86411. /**
  86412. * Set the value of an uniform to a vec3
  86413. * @param uniform defines the webGL uniform location where to store the value
  86414. * @param x defines the 1st component of the value
  86415. * @param y defines the 2nd component of the value
  86416. * @param z defines the 3rd component of the value
  86417. */
  86418. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  86419. /**
  86420. * Set the value of an uniform to a boolean
  86421. * @param uniform defines the webGL uniform location where to store the value
  86422. * @param bool defines the boolean to store
  86423. */
  86424. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  86425. /**
  86426. * Set the value of an uniform to a vec4
  86427. * @param uniform defines the webGL uniform location where to store the value
  86428. * @param x defines the 1st component of the value
  86429. * @param y defines the 2nd component of the value
  86430. * @param z defines the 3rd component of the value
  86431. * @param w defines the 4th component of the value
  86432. */
  86433. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  86434. /**
  86435. * Set the value of an uniform to a Color3
  86436. * @param uniform defines the webGL uniform location where to store the value
  86437. * @param color3 defines the color to store
  86438. */
  86439. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  86440. /**
  86441. * Set the value of an uniform to a Color3 and an alpha value
  86442. * @param uniform defines the webGL uniform location where to store the value
  86443. * @param color3 defines the color to store
  86444. * @param alpha defines the alpha component to store
  86445. */
  86446. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  86447. /**
  86448. * Sets a Color4 on a uniform variable
  86449. * @param uniform defines the uniform location
  86450. * @param color4 defines the value to be set
  86451. */
  86452. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  86453. /**
  86454. * Set various states to the webGL context
  86455. * @param culling defines backface culling state
  86456. * @param zOffset defines the value to apply to zOffset (0 by default)
  86457. * @param force defines if states must be applied even if cache is up to date
  86458. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  86459. */
  86460. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  86461. /**
  86462. * Set the z offset to apply to current rendering
  86463. * @param value defines the offset to apply
  86464. */
  86465. setZOffset(value: number): void;
  86466. /**
  86467. * Gets the current value of the zOffset
  86468. * @returns the current zOffset state
  86469. */
  86470. getZOffset(): number;
  86471. /**
  86472. * Enable or disable depth buffering
  86473. * @param enable defines the state to set
  86474. */
  86475. setDepthBuffer(enable: boolean): void;
  86476. /**
  86477. * Gets a boolean indicating if depth writing is enabled
  86478. * @returns the current depth writing state
  86479. */
  86480. getDepthWrite(): boolean;
  86481. /**
  86482. * Enable or disable depth writing
  86483. * @param enable defines the state to set
  86484. */
  86485. setDepthWrite(enable: boolean): void;
  86486. /**
  86487. * Enable or disable color writing
  86488. * @param enable defines the state to set
  86489. */
  86490. setColorWrite(enable: boolean): void;
  86491. /**
  86492. * Gets a boolean indicating if color writing is enabled
  86493. * @returns the current color writing state
  86494. */
  86495. getColorWrite(): boolean;
  86496. /**
  86497. * Sets alpha constants used by some alpha blending modes
  86498. * @param r defines the red component
  86499. * @param g defines the green component
  86500. * @param b defines the blue component
  86501. * @param a defines the alpha component
  86502. */
  86503. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  86504. /**
  86505. * Sets the current alpha mode
  86506. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  86507. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  86508. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86509. */
  86510. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  86511. /**
  86512. * Gets the current alpha mode
  86513. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86514. * @returns the current alpha mode
  86515. */
  86516. getAlphaMode(): number;
  86517. /**
  86518. * Clears the list of texture accessible through engine.
  86519. * This can help preventing texture load conflict due to name collision.
  86520. */
  86521. clearInternalTexturesCache(): void;
  86522. /**
  86523. * Force the entire cache to be cleared
  86524. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  86525. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  86526. */
  86527. wipeCaches(bruteForce?: boolean): void;
  86528. /**
  86529. * Set the compressed texture format to use, based on the formats you have, and the formats
  86530. * supported by the hardware / browser.
  86531. *
  86532. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  86533. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  86534. * to API arguments needed to compressed textures. This puts the burden on the container
  86535. * generator to house the arcane code for determining these for current & future formats.
  86536. *
  86537. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  86538. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  86539. *
  86540. * Note: The result of this call is not taken into account when a texture is base64.
  86541. *
  86542. * @param formatsAvailable defines the list of those format families you have created
  86543. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  86544. *
  86545. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  86546. * @returns The extension selected.
  86547. */
  86548. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  86549. private _getSamplingParameters;
  86550. private _partialLoadImg;
  86551. private _cascadeLoadImgs;
  86552. /** @hidden */
  86553. _createTexture(): WebGLTexture;
  86554. /**
  86555. * Usually called from Texture.ts.
  86556. * Passed information to create a WebGLTexture
  86557. * @param urlArg defines a value which contains one of the following:
  86558. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  86559. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  86560. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  86561. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  86562. * @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)
  86563. * @param scene needed for loading to the correct scene
  86564. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  86565. * @param onLoad optional callback to be called upon successful completion
  86566. * @param onError optional callback to be called upon failure
  86567. * @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
  86568. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  86569. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  86570. * @param forcedExtension defines the extension to use to pick the right loader
  86571. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  86572. * @returns a InternalTexture for assignment back into BABYLON.Texture
  86573. */
  86574. 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;
  86575. private _rescaleTexture;
  86576. /**
  86577. * Update a raw texture
  86578. * @param texture defines the texture to update
  86579. * @param data defines the data to store in the texture
  86580. * @param format defines the format of the data
  86581. * @param invertY defines if data must be stored with Y axis inverted
  86582. * @param compression defines the compression used (null by default)
  86583. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86584. */
  86585. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  86586. /**
  86587. * Creates a raw texture
  86588. * @param data defines the data to store in the texture
  86589. * @param width defines the width of the texture
  86590. * @param height defines the height of the texture
  86591. * @param format defines the format of the data
  86592. * @param generateMipMaps defines if the engine should generate the mip levels
  86593. * @param invertY defines if data must be stored with Y axis inverted
  86594. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86595. * @param compression defines the compression used (null by default)
  86596. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86597. * @returns the raw texture inside an InternalTexture
  86598. */
  86599. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  86600. private _unpackFlipYCached;
  86601. /**
  86602. * In case you are sharing the context with other applications, it might
  86603. * be interested to not cache the unpack flip y state to ensure a consistent
  86604. * value would be set.
  86605. */
  86606. enableUnpackFlipYCached: boolean;
  86607. /** @hidden */
  86608. _unpackFlipY(value: boolean): void;
  86609. /** @hidden */
  86610. _getUnpackAlignement(): number;
  86611. /**
  86612. * Creates a dynamic texture
  86613. * @param width defines the width of the texture
  86614. * @param height defines the height of the texture
  86615. * @param generateMipMaps defines if the engine should generate the mip levels
  86616. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86617. * @returns the dynamic texture inside an InternalTexture
  86618. */
  86619. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86620. /**
  86621. * Update the sampling mode of a given texture
  86622. * @param samplingMode defines the required sampling mode
  86623. * @param texture defines the texture to update
  86624. */
  86625. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  86626. /**
  86627. * Update the content of a dynamic texture
  86628. * @param texture defines the texture to update
  86629. * @param canvas defines the canvas containing the source
  86630. * @param invertY defines if data must be stored with Y axis inverted
  86631. * @param premulAlpha defines if alpha is stored as premultiplied
  86632. * @param format defines the format of the data
  86633. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86634. */
  86635. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86636. /**
  86637. * Update a video texture
  86638. * @param texture defines the texture to update
  86639. * @param video defines the video element to use
  86640. * @param invertY defines if data must be stored with Y axis inverted
  86641. */
  86642. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  86643. /**
  86644. * Updates a depth texture Comparison Mode and Function.
  86645. * If the comparison Function is equal to 0, the mode will be set to none.
  86646. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  86647. * @param texture The texture to set the comparison function for
  86648. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  86649. */
  86650. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  86651. private _setupDepthStencilTexture;
  86652. /**
  86653. * Creates a depth stencil texture.
  86654. * This is only available in WebGL 2 or with the depth texture extension available.
  86655. * @param size The size of face edge in the texture.
  86656. * @param options The options defining the texture.
  86657. * @returns The texture
  86658. */
  86659. createDepthStencilTexture(size: number | {
  86660. width: number;
  86661. height: number;
  86662. }, options: DepthTextureCreationOptions): InternalTexture;
  86663. /**
  86664. * Creates a depth stencil texture.
  86665. * This is only available in WebGL 2 or with the depth texture extension available.
  86666. * @param size The size of face edge in the texture.
  86667. * @param options The options defining the texture.
  86668. * @returns The texture
  86669. */
  86670. private _createDepthStencilTexture;
  86671. /**
  86672. * Creates a depth stencil cube texture.
  86673. * This is only available in WebGL 2.
  86674. * @param size The size of face edge in the cube texture.
  86675. * @param options The options defining the cube texture.
  86676. * @returns The cube texture
  86677. */
  86678. private _createDepthStencilCubeTexture;
  86679. /**
  86680. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  86681. * @param renderTarget The render target to set the frame buffer for
  86682. */
  86683. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  86684. /**
  86685. * Creates a new render target texture
  86686. * @param size defines the size of the texture
  86687. * @param options defines the options used to create the texture
  86688. * @returns a new render target texture stored in an InternalTexture
  86689. */
  86690. createRenderTargetTexture(size: number | {
  86691. width: number;
  86692. height: number;
  86693. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86694. /**
  86695. * Create a multi render target texture
  86696. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  86697. * @param size defines the size of the texture
  86698. * @param options defines the creation options
  86699. * @returns the cube texture as an InternalTexture
  86700. */
  86701. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  86702. private _setupFramebufferDepthAttachments;
  86703. /**
  86704. * Updates the sample count of a render target texture
  86705. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86706. * @param texture defines the texture to update
  86707. * @param samples defines the sample count to set
  86708. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86709. */
  86710. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  86711. /**
  86712. * Update the sample count for a given multiple render target texture
  86713. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86714. * @param textures defines the textures to update
  86715. * @param samples defines the sample count to set
  86716. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86717. */
  86718. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  86719. /** @hidden */
  86720. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86721. /** @hidden */
  86722. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86723. /** @hidden */
  86724. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86725. /** @hidden */
  86726. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  86727. /**
  86728. * Creates a new render target cube texture
  86729. * @param size defines the size of the texture
  86730. * @param options defines the options used to create the texture
  86731. * @returns a new render target cube texture stored in an InternalTexture
  86732. */
  86733. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86734. /**
  86735. * Creates a cube texture
  86736. * @param rootUrl defines the url where the files to load is located
  86737. * @param scene defines the current scene
  86738. * @param files defines the list of files to load (1 per face)
  86739. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86740. * @param onLoad defines an optional callback raised when the texture is loaded
  86741. * @param onError defines an optional callback raised if there is an issue to load the texture
  86742. * @param format defines the format of the data
  86743. * @param forcedExtension defines the extension to use to pick the right loader
  86744. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86745. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86746. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86747. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86748. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  86749. * @returns the cube texture as an InternalTexture
  86750. */
  86751. 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;
  86752. /**
  86753. * @hidden
  86754. */
  86755. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86756. /**
  86757. * Update a raw cube texture
  86758. * @param texture defines the texture to udpdate
  86759. * @param data defines the data to store
  86760. * @param format defines the data format
  86761. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86762. * @param invertY defines if data must be stored with Y axis inverted
  86763. * @param compression defines the compression used (null by default)
  86764. * @param level defines which level of the texture to update
  86765. */
  86766. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  86767. /**
  86768. * Creates a new raw cube texture
  86769. * @param data defines the array of data to use to create each face
  86770. * @param size defines the size of the textures
  86771. * @param format defines the format of the data
  86772. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86773. * @param generateMipMaps defines if the engine should generate the mip levels
  86774. * @param invertY defines if data must be stored with Y axis inverted
  86775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86776. * @param compression defines the compression used (null by default)
  86777. * @returns the cube texture as an InternalTexture
  86778. */
  86779. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  86780. /**
  86781. * Creates a new raw cube texture from a specified url
  86782. * @param url defines the url where the data is located
  86783. * @param scene defines the current scene
  86784. * @param size defines the size of the textures
  86785. * @param format defines the format of the data
  86786. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86787. * @param noMipmap defines if the engine should avoid generating the mip levels
  86788. * @param callback defines a callback used to extract texture data from loaded data
  86789. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86790. * @param onLoad defines a callback called when texture is loaded
  86791. * @param onError defines a callback called if there is an error
  86792. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86793. * @param invertY defines if data must be stored with Y axis inverted
  86794. * @returns the cube texture as an InternalTexture
  86795. */
  86796. 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;
  86797. /**
  86798. * Update a raw 3D texture
  86799. * @param texture defines the texture to update
  86800. * @param data defines the data to store
  86801. * @param format defines the data format
  86802. * @param invertY defines if data must be stored with Y axis inverted
  86803. * @param compression defines the used compression (can be null)
  86804. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86805. */
  86806. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  86807. /**
  86808. * Creates a new raw 3D texture
  86809. * @param data defines the data used to create the texture
  86810. * @param width defines the width of the texture
  86811. * @param height defines the height of the texture
  86812. * @param depth defines the depth of the texture
  86813. * @param format defines the format of the texture
  86814. * @param generateMipMaps defines if the engine must generate mip levels
  86815. * @param invertY defines if data must be stored with Y axis inverted
  86816. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86817. * @param compression defines the compressed used (can be null)
  86818. * @param textureType defines the compressed used (can be null)
  86819. * @returns a new raw 3D texture (stored in an InternalTexture)
  86820. */
  86821. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  86822. private _prepareWebGLTextureContinuation;
  86823. private _prepareWebGLTexture;
  86824. private _convertRGBtoRGBATextureData;
  86825. /** @hidden */
  86826. _releaseFramebufferObjects(texture: InternalTexture): void;
  86827. /** @hidden */
  86828. _releaseTexture(texture: InternalTexture): void;
  86829. private setProgram;
  86830. private _boundUniforms;
  86831. /**
  86832. * Binds an effect to the webGL context
  86833. * @param effect defines the effect to bind
  86834. */
  86835. bindSamplers(effect: Effect): void;
  86836. private _moveBoundTextureOnTop;
  86837. private _getCorrectTextureChannel;
  86838. private _linkTrackers;
  86839. private _removeDesignatedSlot;
  86840. private _activateCurrentTexture;
  86841. /** @hidden */
  86842. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  86843. /** @hidden */
  86844. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  86845. /**
  86846. * Sets a texture to the webGL context from a postprocess
  86847. * @param channel defines the channel to use
  86848. * @param postProcess defines the source postprocess
  86849. */
  86850. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  86851. /**
  86852. * Binds the output of the passed in post process to the texture channel specified
  86853. * @param channel The channel the texture should be bound to
  86854. * @param postProcess The post process which's output should be bound
  86855. */
  86856. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  86857. /**
  86858. * Unbind all textures from the webGL context
  86859. */
  86860. unbindAllTextures(): void;
  86861. /**
  86862. * Sets a texture to the according uniform.
  86863. * @param channel The texture channel
  86864. * @param uniform The uniform to set
  86865. * @param texture The texture to apply
  86866. */
  86867. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  86868. /**
  86869. * Sets a depth stencil texture from a render target to the according uniform.
  86870. * @param channel The texture channel
  86871. * @param uniform The uniform to set
  86872. * @param texture The render target texture containing the depth stencil texture to apply
  86873. */
  86874. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  86875. private _bindSamplerUniformToChannel;
  86876. private _getTextureWrapMode;
  86877. private _setTexture;
  86878. /**
  86879. * Sets an array of texture to the webGL context
  86880. * @param channel defines the channel where the texture array must be set
  86881. * @param uniform defines the associated uniform location
  86882. * @param textures defines the array of textures to bind
  86883. */
  86884. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  86885. /** @hidden */
  86886. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  86887. private _setTextureParameterFloat;
  86888. private _setTextureParameterInteger;
  86889. /**
  86890. * Reads pixels from the current frame buffer. Please note that this function can be slow
  86891. * @param x defines the x coordinate of the rectangle where pixels must be read
  86892. * @param y defines the y coordinate of the rectangle where pixels must be read
  86893. * @param width defines the width of the rectangle where pixels must be read
  86894. * @param height defines the height of the rectangle where pixels must be read
  86895. * @returns a Uint8Array containing RGBA colors
  86896. */
  86897. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  86898. /**
  86899. * Add an externaly attached data from its key.
  86900. * This method call will fail and return false, if such key already exists.
  86901. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  86902. * @param key the unique key that identifies the data
  86903. * @param data the data object to associate to the key for this Engine instance
  86904. * @return true if no such key were already present and the data was added successfully, false otherwise
  86905. */
  86906. addExternalData<T>(key: string, data: T): boolean;
  86907. /**
  86908. * Get an externaly attached data from its key
  86909. * @param key the unique key that identifies the data
  86910. * @return the associated data, if present (can be null), or undefined if not present
  86911. */
  86912. getExternalData<T>(key: string): T;
  86913. /**
  86914. * Get an externaly attached data from its key, create it using a factory if it's not already present
  86915. * @param key the unique key that identifies the data
  86916. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  86917. * @return the associated data, can be null if the factory returned null.
  86918. */
  86919. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  86920. /**
  86921. * Remove an externaly attached data from the Engine instance
  86922. * @param key the unique key that identifies the data
  86923. * @return true if the data was successfully removed, false if it doesn't exist
  86924. */
  86925. removeExternalData(key: string): boolean;
  86926. /**
  86927. * Unbind all vertex attributes from the webGL context
  86928. */
  86929. unbindAllAttributes(): void;
  86930. /**
  86931. * 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
  86932. */
  86933. releaseEffects(): void;
  86934. /**
  86935. * Dispose and release all associated resources
  86936. */
  86937. dispose(): void;
  86938. /**
  86939. * Display the loading screen
  86940. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86941. */
  86942. displayLoadingUI(): void;
  86943. /**
  86944. * Hide the loading screen
  86945. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86946. */
  86947. hideLoadingUI(): void;
  86948. /**
  86949. * Gets the current loading screen object
  86950. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86951. */
  86952. /**
  86953. * Sets the current loading screen object
  86954. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86955. */
  86956. loadingScreen: ILoadingScreen;
  86957. /**
  86958. * Sets the current loading screen text
  86959. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86960. */
  86961. loadingUIText: string;
  86962. /**
  86963. * Sets the current loading screen background color
  86964. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86965. */
  86966. loadingUIBackgroundColor: string;
  86967. /**
  86968. * Attach a new callback raised when context lost event is fired
  86969. * @param callback defines the callback to call
  86970. */
  86971. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86972. /**
  86973. * Attach a new callback raised when context restored event is fired
  86974. * @param callback defines the callback to call
  86975. */
  86976. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86977. /**
  86978. * Gets the source code of the vertex shader associated with a specific webGL program
  86979. * @param program defines the program to use
  86980. * @returns a string containing the source code of the vertex shader associated with the program
  86981. */
  86982. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  86983. /**
  86984. * Gets the source code of the fragment shader associated with a specific webGL program
  86985. * @param program defines the program to use
  86986. * @returns a string containing the source code of the fragment shader associated with the program
  86987. */
  86988. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  86989. /**
  86990. * Get the current error code of the webGL context
  86991. * @returns the error code
  86992. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  86993. */
  86994. getError(): number;
  86995. /**
  86996. * Gets the current framerate
  86997. * @returns a number representing the framerate
  86998. */
  86999. getFps(): number;
  87000. /**
  87001. * Gets the time spent between current and previous frame
  87002. * @returns a number representing the delta time in ms
  87003. */
  87004. getDeltaTime(): number;
  87005. private _measureFps;
  87006. /** @hidden */
  87007. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  87008. private _canRenderToFloatFramebuffer;
  87009. private _canRenderToHalfFloatFramebuffer;
  87010. private _canRenderToFramebuffer;
  87011. /** @hidden */
  87012. _getWebGLTextureType(type: number): number;
  87013. private _getInternalFormat;
  87014. /** @hidden */
  87015. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  87016. /** @hidden */
  87017. _getRGBAMultiSampleBufferFormat(type: number): number;
  87018. /** @hidden */
  87019. _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;
  87020. /** @hidden */
  87021. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  87022. private _partialLoadFile;
  87023. private _cascadeLoadFiles;
  87024. /**
  87025. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  87026. * @returns true if the engine can be created
  87027. * @ignorenaming
  87028. */
  87029. static isSupported(): boolean;
  87030. }
  87031. }
  87032. declare module BABYLON {
  87033. /**
  87034. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87035. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87036. */
  87037. export class EffectFallbacks {
  87038. private _defines;
  87039. private _currentRank;
  87040. private _maxRank;
  87041. private _mesh;
  87042. /**
  87043. * Removes the fallback from the bound mesh.
  87044. */
  87045. unBindMesh(): void;
  87046. /**
  87047. * Adds a fallback on the specified property.
  87048. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87049. * @param define The name of the define in the shader
  87050. */
  87051. addFallback(rank: number, define: string): void;
  87052. /**
  87053. * Sets the mesh to use CPU skinning when needing to fallback.
  87054. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87055. * @param mesh The mesh to use the fallbacks.
  87056. */
  87057. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87058. /**
  87059. * Checks to see if more fallbacks are still availible.
  87060. */
  87061. readonly isMoreFallbacks: boolean;
  87062. /**
  87063. * Removes the defines that shoould be removed when falling back.
  87064. * @param currentDefines defines the current define statements for the shader.
  87065. * @param effect defines the current effect we try to compile
  87066. * @returns The resulting defines with defines of the current rank removed.
  87067. */
  87068. reduce(currentDefines: string, effect: Effect): string;
  87069. }
  87070. /**
  87071. * Options to be used when creating an effect.
  87072. */
  87073. export class EffectCreationOptions {
  87074. /**
  87075. * Atrributes that will be used in the shader.
  87076. */
  87077. attributes: string[];
  87078. /**
  87079. * Uniform varible names that will be set in the shader.
  87080. */
  87081. uniformsNames: string[];
  87082. /**
  87083. * Uniform buffer varible names that will be set in the shader.
  87084. */
  87085. uniformBuffersNames: string[];
  87086. /**
  87087. * Sampler texture variable names that will be set in the shader.
  87088. */
  87089. samplers: string[];
  87090. /**
  87091. * Define statements that will be set in the shader.
  87092. */
  87093. defines: any;
  87094. /**
  87095. * Possible fallbacks for this effect to improve performance when needed.
  87096. */
  87097. fallbacks: Nullable<EffectFallbacks>;
  87098. /**
  87099. * Callback that will be called when the shader is compiled.
  87100. */
  87101. onCompiled: Nullable<(effect: Effect) => void>;
  87102. /**
  87103. * Callback that will be called if an error occurs during shader compilation.
  87104. */
  87105. onError: Nullable<(effect: Effect, errors: string) => void>;
  87106. /**
  87107. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87108. */
  87109. indexParameters: any;
  87110. /**
  87111. * Max number of lights that can be used in the shader.
  87112. */
  87113. maxSimultaneousLights: number;
  87114. /**
  87115. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  87116. */
  87117. transformFeedbackVaryings: Nullable<string[]>;
  87118. }
  87119. /**
  87120. * Effect containing vertex and fragment shader that can be executed on an object.
  87121. */
  87122. export class Effect {
  87123. /**
  87124. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87125. */
  87126. static ShadersRepository: string;
  87127. /**
  87128. * Name of the effect.
  87129. */
  87130. name: any;
  87131. /**
  87132. * String container all the define statements that should be set on the shader.
  87133. */
  87134. defines: string;
  87135. /**
  87136. * Callback that will be called when the shader is compiled.
  87137. */
  87138. onCompiled: Nullable<(effect: Effect) => void>;
  87139. /**
  87140. * Callback that will be called if an error occurs during shader compilation.
  87141. */
  87142. onError: Nullable<(effect: Effect, errors: string) => void>;
  87143. /**
  87144. * Callback that will be called when effect is bound.
  87145. */
  87146. onBind: Nullable<(effect: Effect) => void>;
  87147. /**
  87148. * Unique ID of the effect.
  87149. */
  87150. uniqueId: number;
  87151. /**
  87152. * Observable that will be called when the shader is compiled.
  87153. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  87154. */
  87155. onCompileObservable: Observable<Effect>;
  87156. /**
  87157. * Observable that will be called if an error occurs during shader compilation.
  87158. */
  87159. onErrorObservable: Observable<Effect>;
  87160. /** @hidden */
  87161. _onBindObservable: Nullable<Observable<Effect>>;
  87162. /**
  87163. * Observable that will be called when effect is bound.
  87164. */
  87165. readonly onBindObservable: Observable<Effect>;
  87166. /** @hidden */
  87167. _bonesComputationForcedToCPU: boolean;
  87168. private static _uniqueIdSeed;
  87169. private _engine;
  87170. private _uniformBuffersNames;
  87171. private _uniformsNames;
  87172. private _samplers;
  87173. private _isReady;
  87174. private _compilationError;
  87175. private _attributesNames;
  87176. private _attributes;
  87177. private _uniforms;
  87178. /**
  87179. * Key for the effect.
  87180. * @hidden
  87181. */
  87182. _key: string;
  87183. private _indexParameters;
  87184. private _fallbacks;
  87185. private _vertexSourceCode;
  87186. private _fragmentSourceCode;
  87187. private _vertexSourceCodeOverride;
  87188. private _fragmentSourceCodeOverride;
  87189. private _transformFeedbackVaryings;
  87190. /**
  87191. * Compiled shader to webGL program.
  87192. * @hidden
  87193. */
  87194. _program: WebGLProgram;
  87195. private _valueCache;
  87196. private static _baseCache;
  87197. /**
  87198. * Instantiates an effect.
  87199. * An effect can be used to create/manage/execute vertex and fragment shaders.
  87200. * @param baseName Name of the effect.
  87201. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  87202. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  87203. * @param samplers List of sampler variables that will be passed to the shader.
  87204. * @param engine Engine to be used to render the effect
  87205. * @param defines Define statements to be added to the shader.
  87206. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  87207. * @param onCompiled Callback that will be called when the shader is compiled.
  87208. * @param onError Callback that will be called if an error occurs during shader compilation.
  87209. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87210. */
  87211. 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);
  87212. /**
  87213. * Unique key for this effect
  87214. */
  87215. readonly key: string;
  87216. /**
  87217. * If the effect has been compiled and prepared.
  87218. * @returns if the effect is compiled and prepared.
  87219. */
  87220. isReady(): boolean;
  87221. /**
  87222. * The engine the effect was initialized with.
  87223. * @returns the engine.
  87224. */
  87225. getEngine(): Engine;
  87226. /**
  87227. * The compiled webGL program for the effect
  87228. * @returns the webGL program.
  87229. */
  87230. getProgram(): WebGLProgram;
  87231. /**
  87232. * The set of names of attribute variables for the shader.
  87233. * @returns An array of attribute names.
  87234. */
  87235. getAttributesNames(): string[];
  87236. /**
  87237. * Returns the attribute at the given index.
  87238. * @param index The index of the attribute.
  87239. * @returns The location of the attribute.
  87240. */
  87241. getAttributeLocation(index: number): number;
  87242. /**
  87243. * Returns the attribute based on the name of the variable.
  87244. * @param name of the attribute to look up.
  87245. * @returns the attribute location.
  87246. */
  87247. getAttributeLocationByName(name: string): number;
  87248. /**
  87249. * The number of attributes.
  87250. * @returns the numnber of attributes.
  87251. */
  87252. getAttributesCount(): number;
  87253. /**
  87254. * Gets the index of a uniform variable.
  87255. * @param uniformName of the uniform to look up.
  87256. * @returns the index.
  87257. */
  87258. getUniformIndex(uniformName: string): number;
  87259. /**
  87260. * Returns the attribute based on the name of the variable.
  87261. * @param uniformName of the uniform to look up.
  87262. * @returns the location of the uniform.
  87263. */
  87264. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  87265. /**
  87266. * Returns an array of sampler variable names
  87267. * @returns The array of sampler variable neames.
  87268. */
  87269. getSamplers(): string[];
  87270. /**
  87271. * The error from the last compilation.
  87272. * @returns the error string.
  87273. */
  87274. getCompilationError(): string;
  87275. /**
  87276. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  87277. * @param func The callback to be used.
  87278. */
  87279. executeWhenCompiled(func: (effect: Effect) => void): void;
  87280. private _checkIsReady;
  87281. /** @hidden */
  87282. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  87283. /** @hidden */
  87284. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  87285. /** @hidden */
  87286. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  87287. private _processShaderConversion;
  87288. private _processIncludes;
  87289. private _processPrecision;
  87290. /**
  87291. * Recompiles the webGL program
  87292. * @param vertexSourceCode The source code for the vertex shader.
  87293. * @param fragmentSourceCode The source code for the fragment shader.
  87294. * @param onCompiled Callback called when completed.
  87295. * @param onError Callback called on error.
  87296. * @hidden
  87297. */
  87298. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  87299. /**
  87300. * Gets the uniform locations of the the specified variable names
  87301. * @param names THe names of the variables to lookup.
  87302. * @returns Array of locations in the same order as variable names.
  87303. */
  87304. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  87305. /**
  87306. * Prepares the effect
  87307. * @hidden
  87308. */
  87309. _prepareEffect(): void;
  87310. /**
  87311. * Checks if the effect is supported. (Must be called after compilation)
  87312. */
  87313. readonly isSupported: boolean;
  87314. /**
  87315. * Binds a texture to the engine to be used as output of the shader.
  87316. * @param channel Name of the output variable.
  87317. * @param texture Texture to bind.
  87318. * @hidden
  87319. */
  87320. _bindTexture(channel: string, texture: InternalTexture): void;
  87321. /**
  87322. * Sets a texture on the engine to be used in the shader.
  87323. * @param channel Name of the sampler variable.
  87324. * @param texture Texture to set.
  87325. */
  87326. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  87327. /**
  87328. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  87329. * @param channel Name of the sampler variable.
  87330. * @param texture Texture to set.
  87331. */
  87332. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  87333. /**
  87334. * Sets an array of textures on the engine to be used in the shader.
  87335. * @param channel Name of the variable.
  87336. * @param textures Textures to set.
  87337. */
  87338. setTextureArray(channel: string, textures: BaseTexture[]): void;
  87339. /**
  87340. * 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)
  87341. * @param channel Name of the sampler variable.
  87342. * @param postProcess Post process to get the input texture from.
  87343. */
  87344. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  87345. /**
  87346. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  87347. * 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)
  87348. * @param channel Name of the sampler variable.
  87349. * @param postProcess Post process to get the output texture from.
  87350. */
  87351. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  87352. /** @hidden */
  87353. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  87354. /** @hidden */
  87355. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  87356. /** @hidden */
  87357. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  87358. /** @hidden */
  87359. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  87360. /**
  87361. * Binds a buffer to a uniform.
  87362. * @param buffer Buffer to bind.
  87363. * @param name Name of the uniform variable to bind to.
  87364. */
  87365. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  87366. /**
  87367. * Binds block to a uniform.
  87368. * @param blockName Name of the block to bind.
  87369. * @param index Index to bind.
  87370. */
  87371. bindUniformBlock(blockName: string, index: number): void;
  87372. /**
  87373. * Sets an interger value on a uniform variable.
  87374. * @param uniformName Name of the variable.
  87375. * @param value Value to be set.
  87376. * @returns this effect.
  87377. */
  87378. setInt(uniformName: string, value: number): Effect;
  87379. /**
  87380. * Sets an int array on a uniform variable.
  87381. * @param uniformName Name of the variable.
  87382. * @param array array to be set.
  87383. * @returns this effect.
  87384. */
  87385. setIntArray(uniformName: string, array: Int32Array): Effect;
  87386. /**
  87387. * 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)
  87388. * @param uniformName Name of the variable.
  87389. * @param array array to be set.
  87390. * @returns this effect.
  87391. */
  87392. setIntArray2(uniformName: string, array: Int32Array): Effect;
  87393. /**
  87394. * 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)
  87395. * @param uniformName Name of the variable.
  87396. * @param array array to be set.
  87397. * @returns this effect.
  87398. */
  87399. setIntArray3(uniformName: string, array: Int32Array): Effect;
  87400. /**
  87401. * 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)
  87402. * @param uniformName Name of the variable.
  87403. * @param array array to be set.
  87404. * @returns this effect.
  87405. */
  87406. setIntArray4(uniformName: string, array: Int32Array): Effect;
  87407. /**
  87408. * Sets an float array on a uniform variable.
  87409. * @param uniformName Name of the variable.
  87410. * @param array array to be set.
  87411. * @returns this effect.
  87412. */
  87413. setFloatArray(uniformName: string, array: Float32Array): Effect;
  87414. /**
  87415. * 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)
  87416. * @param uniformName Name of the variable.
  87417. * @param array array to be set.
  87418. * @returns this effect.
  87419. */
  87420. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  87421. /**
  87422. * 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)
  87423. * @param uniformName Name of the variable.
  87424. * @param array array to be set.
  87425. * @returns this effect.
  87426. */
  87427. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  87428. /**
  87429. * 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)
  87430. * @param uniformName Name of the variable.
  87431. * @param array array to be set.
  87432. * @returns this effect.
  87433. */
  87434. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  87435. /**
  87436. * Sets an array on a uniform variable.
  87437. * @param uniformName Name of the variable.
  87438. * @param array array to be set.
  87439. * @returns this effect.
  87440. */
  87441. setArray(uniformName: string, array: number[]): Effect;
  87442. /**
  87443. * 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)
  87444. * @param uniformName Name of the variable.
  87445. * @param array array to be set.
  87446. * @returns this effect.
  87447. */
  87448. setArray2(uniformName: string, array: number[]): Effect;
  87449. /**
  87450. * 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)
  87451. * @param uniformName Name of the variable.
  87452. * @param array array to be set.
  87453. * @returns this effect.
  87454. */
  87455. setArray3(uniformName: string, array: number[]): Effect;
  87456. /**
  87457. * 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)
  87458. * @param uniformName Name of the variable.
  87459. * @param array array to be set.
  87460. * @returns this effect.
  87461. */
  87462. setArray4(uniformName: string, array: number[]): Effect;
  87463. /**
  87464. * Sets matrices on a uniform variable.
  87465. * @param uniformName Name of the variable.
  87466. * @param matrices matrices to be set.
  87467. * @returns this effect.
  87468. */
  87469. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  87470. /**
  87471. * Sets matrix on a uniform variable.
  87472. * @param uniformName Name of the variable.
  87473. * @param matrix matrix to be set.
  87474. * @returns this effect.
  87475. */
  87476. setMatrix(uniformName: string, matrix: Matrix): Effect;
  87477. /**
  87478. * 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)
  87479. * @param uniformName Name of the variable.
  87480. * @param matrix matrix to be set.
  87481. * @returns this effect.
  87482. */
  87483. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  87484. /**
  87485. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  87486. * @param uniformName Name of the variable.
  87487. * @param matrix matrix to be set.
  87488. * @returns this effect.
  87489. */
  87490. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  87491. /**
  87492. * Sets a float on a uniform variable.
  87493. * @param uniformName Name of the variable.
  87494. * @param value value to be set.
  87495. * @returns this effect.
  87496. */
  87497. setFloat(uniformName: string, value: number): Effect;
  87498. /**
  87499. * Sets a boolean on a uniform variable.
  87500. * @param uniformName Name of the variable.
  87501. * @param bool value to be set.
  87502. * @returns this effect.
  87503. */
  87504. setBool(uniformName: string, bool: boolean): Effect;
  87505. /**
  87506. * Sets a Vector2 on a uniform variable.
  87507. * @param uniformName Name of the variable.
  87508. * @param vector2 vector2 to be set.
  87509. * @returns this effect.
  87510. */
  87511. setVector2(uniformName: string, vector2: Vector2): Effect;
  87512. /**
  87513. * Sets a float2 on a uniform variable.
  87514. * @param uniformName Name of the variable.
  87515. * @param x First float in float2.
  87516. * @param y Second float in float2.
  87517. * @returns this effect.
  87518. */
  87519. setFloat2(uniformName: string, x: number, y: number): Effect;
  87520. /**
  87521. * Sets a Vector3 on a uniform variable.
  87522. * @param uniformName Name of the variable.
  87523. * @param vector3 Value to be set.
  87524. * @returns this effect.
  87525. */
  87526. setVector3(uniformName: string, vector3: Vector3): Effect;
  87527. /**
  87528. * Sets a float3 on a uniform variable.
  87529. * @param uniformName Name of the variable.
  87530. * @param x First float in float3.
  87531. * @param y Second float in float3.
  87532. * @param z Third float in float3.
  87533. * @returns this effect.
  87534. */
  87535. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  87536. /**
  87537. * Sets a Vector4 on a uniform variable.
  87538. * @param uniformName Name of the variable.
  87539. * @param vector4 Value to be set.
  87540. * @returns this effect.
  87541. */
  87542. setVector4(uniformName: string, vector4: Vector4): Effect;
  87543. /**
  87544. * Sets a float4 on a uniform variable.
  87545. * @param uniformName Name of the variable.
  87546. * @param x First float in float4.
  87547. * @param y Second float in float4.
  87548. * @param z Third float in float4.
  87549. * @param w Fourth float in float4.
  87550. * @returns this effect.
  87551. */
  87552. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  87553. /**
  87554. * Sets a Color3 on a uniform variable.
  87555. * @param uniformName Name of the variable.
  87556. * @param color3 Value to be set.
  87557. * @returns this effect.
  87558. */
  87559. setColor3(uniformName: string, color3: Color3): Effect;
  87560. /**
  87561. * Sets a Color4 on a uniform variable.
  87562. * @param uniformName Name of the variable.
  87563. * @param color3 Value to be set.
  87564. * @param alpha Alpha value to be set.
  87565. * @returns this effect.
  87566. */
  87567. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  87568. /**
  87569. * Sets a Color4 on a uniform variable
  87570. * @param uniformName defines the name of the variable
  87571. * @param color4 defines the value to be set
  87572. * @returns this effect.
  87573. */
  87574. setDirectColor4(uniformName: string, color4: Color4): Effect;
  87575. /**
  87576. * This function will add a new shader to the shader store
  87577. * @param name the name of the shader
  87578. * @param pixelShader optional pixel shader content
  87579. * @param vertexShader optional vertex shader content
  87580. */
  87581. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  87582. /**
  87583. * Store of each shader (The can be looked up using effect.key)
  87584. */
  87585. static ShadersStore: {
  87586. [key: string]: string;
  87587. };
  87588. /**
  87589. * Store of each included file for a shader (The can be looked up using effect.key)
  87590. */
  87591. static IncludesShadersStore: {
  87592. [key: string]: string;
  87593. };
  87594. /**
  87595. * Resets the cache of effects.
  87596. */
  87597. static ResetCache(): void;
  87598. }
  87599. }
  87600. declare module BABYLON {
  87601. /**
  87602. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87603. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87604. * 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;
  87605. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87606. */
  87607. export class ColorCurves {
  87608. private _dirty;
  87609. private _tempColor;
  87610. private _globalCurve;
  87611. private _highlightsCurve;
  87612. private _midtonesCurve;
  87613. private _shadowsCurve;
  87614. private _positiveCurve;
  87615. private _negativeCurve;
  87616. private _globalHue;
  87617. private _globalDensity;
  87618. private _globalSaturation;
  87619. private _globalExposure;
  87620. /**
  87621. * Gets the global Hue value.
  87622. * 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).
  87623. */
  87624. /**
  87625. * Sets the global Hue value.
  87626. * 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).
  87627. */
  87628. globalHue: number;
  87629. /**
  87630. * Gets the global Density value.
  87631. * 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.
  87632. * Values less than zero provide a filter of opposite hue.
  87633. */
  87634. /**
  87635. * Sets the global Density value.
  87636. * 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.
  87637. * Values less than zero provide a filter of opposite hue.
  87638. */
  87639. globalDensity: number;
  87640. /**
  87641. * Gets the global Saturation value.
  87642. * 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.
  87643. */
  87644. /**
  87645. * Sets the global Saturation value.
  87646. * 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.
  87647. */
  87648. globalSaturation: number;
  87649. /**
  87650. * Gets the global Exposure value.
  87651. * 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.
  87652. */
  87653. /**
  87654. * Sets the global Exposure value.
  87655. * 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.
  87656. */
  87657. globalExposure: number;
  87658. private _highlightsHue;
  87659. private _highlightsDensity;
  87660. private _highlightsSaturation;
  87661. private _highlightsExposure;
  87662. /**
  87663. * Gets the highlights Hue value.
  87664. * 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).
  87665. */
  87666. /**
  87667. * Sets the highlights Hue value.
  87668. * 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).
  87669. */
  87670. highlightsHue: number;
  87671. /**
  87672. * Gets the highlights Density value.
  87673. * 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.
  87674. * Values less than zero provide a filter of opposite hue.
  87675. */
  87676. /**
  87677. * Sets the highlights Density value.
  87678. * 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.
  87679. * Values less than zero provide a filter of opposite hue.
  87680. */
  87681. highlightsDensity: number;
  87682. /**
  87683. * Gets the highlights Saturation value.
  87684. * 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.
  87685. */
  87686. /**
  87687. * Sets the highlights Saturation value.
  87688. * 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.
  87689. */
  87690. highlightsSaturation: number;
  87691. /**
  87692. * Gets the highlights Exposure value.
  87693. * 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.
  87694. */
  87695. /**
  87696. * Sets the highlights Exposure value.
  87697. * 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.
  87698. */
  87699. highlightsExposure: number;
  87700. private _midtonesHue;
  87701. private _midtonesDensity;
  87702. private _midtonesSaturation;
  87703. private _midtonesExposure;
  87704. /**
  87705. * Gets the midtones Hue value.
  87706. * 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).
  87707. */
  87708. /**
  87709. * Sets the midtones Hue value.
  87710. * 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).
  87711. */
  87712. midtonesHue: number;
  87713. /**
  87714. * Gets the midtones Density value.
  87715. * 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.
  87716. * Values less than zero provide a filter of opposite hue.
  87717. */
  87718. /**
  87719. * Sets the midtones Density value.
  87720. * 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.
  87721. * Values less than zero provide a filter of opposite hue.
  87722. */
  87723. midtonesDensity: number;
  87724. /**
  87725. * Gets the midtones Saturation value.
  87726. * 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.
  87727. */
  87728. /**
  87729. * Sets the midtones Saturation value.
  87730. * 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.
  87731. */
  87732. midtonesSaturation: number;
  87733. /**
  87734. * Gets the midtones Exposure value.
  87735. * 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.
  87736. */
  87737. /**
  87738. * Sets the midtones Exposure value.
  87739. * 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.
  87740. */
  87741. midtonesExposure: number;
  87742. private _shadowsHue;
  87743. private _shadowsDensity;
  87744. private _shadowsSaturation;
  87745. private _shadowsExposure;
  87746. /**
  87747. * Gets the shadows Hue value.
  87748. * 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).
  87749. */
  87750. /**
  87751. * Sets the shadows Hue value.
  87752. * 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).
  87753. */
  87754. shadowsHue: number;
  87755. /**
  87756. * Gets the shadows Density value.
  87757. * 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.
  87758. * Values less than zero provide a filter of opposite hue.
  87759. */
  87760. /**
  87761. * Sets the shadows Density value.
  87762. * 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.
  87763. * Values less than zero provide a filter of opposite hue.
  87764. */
  87765. shadowsDensity: number;
  87766. /**
  87767. * Gets the shadows Saturation value.
  87768. * 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.
  87769. */
  87770. /**
  87771. * Sets the shadows Saturation value.
  87772. * 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.
  87773. */
  87774. shadowsSaturation: number;
  87775. /**
  87776. * Gets the shadows Exposure value.
  87777. * 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.
  87778. */
  87779. /**
  87780. * Sets the shadows Exposure value.
  87781. * 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.
  87782. */
  87783. shadowsExposure: number;
  87784. /**
  87785. * Returns the class name
  87786. * @returns The class name
  87787. */
  87788. getClassName(): string;
  87789. /**
  87790. * Binds the color curves to the shader.
  87791. * @param colorCurves The color curve to bind
  87792. * @param effect The effect to bind to
  87793. * @param positiveUniform The positive uniform shader parameter
  87794. * @param neutralUniform The neutral uniform shader parameter
  87795. * @param negativeUniform The negative uniform shader parameter
  87796. */
  87797. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87798. /**
  87799. * Prepare the list of uniforms associated with the ColorCurves effects.
  87800. * @param uniformsList The list of uniforms used in the effect
  87801. */
  87802. static PrepareUniforms(uniformsList: string[]): void;
  87803. /**
  87804. * Returns color grading data based on a hue, density, saturation and exposure value.
  87805. * @param filterHue The hue of the color filter.
  87806. * @param filterDensity The density of the color filter.
  87807. * @param saturation The saturation.
  87808. * @param exposure The exposure.
  87809. * @param result The result data container.
  87810. */
  87811. private getColorGradingDataToRef;
  87812. /**
  87813. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87814. * @param value The input slider value in range [-100,100].
  87815. * @returns Adjusted value.
  87816. */
  87817. private static applyColorGradingSliderNonlinear;
  87818. /**
  87819. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87820. * @param hue The hue (H) input.
  87821. * @param saturation The saturation (S) input.
  87822. * @param brightness The brightness (B) input.
  87823. * @result An RGBA color represented as Vector4.
  87824. */
  87825. private static fromHSBToRef;
  87826. /**
  87827. * Returns a value clamped between min and max
  87828. * @param value The value to clamp
  87829. * @param min The minimum of value
  87830. * @param max The maximum of value
  87831. * @returns The clamped value.
  87832. */
  87833. private static clamp;
  87834. /**
  87835. * Clones the current color curve instance.
  87836. * @return The cloned curves
  87837. */
  87838. clone(): ColorCurves;
  87839. /**
  87840. * Serializes the current color curve instance to a json representation.
  87841. * @return a JSON representation
  87842. */
  87843. serialize(): any;
  87844. /**
  87845. * Parses the color curve from a json representation.
  87846. * @param source the JSON source to parse
  87847. * @return The parsed curves
  87848. */
  87849. static Parse(source: any): ColorCurves;
  87850. }
  87851. }
  87852. declare module BABYLON {
  87853. /**
  87854. * Interface to follow in your material defines to integrate easily the
  87855. * Image proccessing functions.
  87856. * @hidden
  87857. */
  87858. export interface IImageProcessingConfigurationDefines {
  87859. IMAGEPROCESSING: boolean;
  87860. VIGNETTE: boolean;
  87861. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87862. VIGNETTEBLENDMODEOPAQUE: boolean;
  87863. TONEMAPPING: boolean;
  87864. TONEMAPPING_ACES: boolean;
  87865. CONTRAST: boolean;
  87866. EXPOSURE: boolean;
  87867. COLORCURVES: boolean;
  87868. COLORGRADING: boolean;
  87869. COLORGRADING3D: boolean;
  87870. SAMPLER3DGREENDEPTH: boolean;
  87871. SAMPLER3DBGRMAP: boolean;
  87872. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87873. }
  87874. /**
  87875. * @hidden
  87876. */
  87877. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87878. IMAGEPROCESSING: boolean;
  87879. VIGNETTE: boolean;
  87880. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87881. VIGNETTEBLENDMODEOPAQUE: boolean;
  87882. TONEMAPPING: boolean;
  87883. TONEMAPPING_ACES: boolean;
  87884. CONTRAST: boolean;
  87885. COLORCURVES: boolean;
  87886. COLORGRADING: boolean;
  87887. COLORGRADING3D: boolean;
  87888. SAMPLER3DGREENDEPTH: boolean;
  87889. SAMPLER3DBGRMAP: boolean;
  87890. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87891. EXPOSURE: boolean;
  87892. constructor();
  87893. }
  87894. /**
  87895. * This groups together the common properties used for image processing either in direct forward pass
  87896. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87897. * or not.
  87898. */
  87899. export class ImageProcessingConfiguration {
  87900. /**
  87901. * Default tone mapping applied in BabylonJS.
  87902. */
  87903. static readonly TONEMAPPING_STANDARD: number;
  87904. /**
  87905. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87906. * to other engines rendering to increase portability.
  87907. */
  87908. static readonly TONEMAPPING_ACES: number;
  87909. /**
  87910. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87911. */
  87912. colorCurves: Nullable<ColorCurves>;
  87913. private _colorCurvesEnabled;
  87914. /**
  87915. * Gets wether the color curves effect is enabled.
  87916. */
  87917. /**
  87918. * Sets wether the color curves effect is enabled.
  87919. */
  87920. colorCurvesEnabled: boolean;
  87921. private _colorGradingTexture;
  87922. /**
  87923. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87924. */
  87925. /**
  87926. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87927. */
  87928. colorGradingTexture: Nullable<BaseTexture>;
  87929. private _colorGradingEnabled;
  87930. /**
  87931. * Gets wether the color grading effect is enabled.
  87932. */
  87933. /**
  87934. * Sets wether the color grading effect is enabled.
  87935. */
  87936. colorGradingEnabled: boolean;
  87937. private _colorGradingWithGreenDepth;
  87938. /**
  87939. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87940. */
  87941. /**
  87942. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87943. */
  87944. colorGradingWithGreenDepth: boolean;
  87945. private _colorGradingBGR;
  87946. /**
  87947. * Gets wether the color grading texture contains BGR values.
  87948. */
  87949. /**
  87950. * Sets wether the color grading texture contains BGR values.
  87951. */
  87952. colorGradingBGR: boolean;
  87953. /** @hidden */
  87954. _exposure: number;
  87955. /**
  87956. * Gets the Exposure used in the effect.
  87957. */
  87958. /**
  87959. * Sets the Exposure used in the effect.
  87960. */
  87961. exposure: number;
  87962. private _toneMappingEnabled;
  87963. /**
  87964. * Gets wether the tone mapping effect is enabled.
  87965. */
  87966. /**
  87967. * Sets wether the tone mapping effect is enabled.
  87968. */
  87969. toneMappingEnabled: boolean;
  87970. private _toneMappingType;
  87971. /**
  87972. * Gets the type of tone mapping effect.
  87973. */
  87974. /**
  87975. * Sets the type of tone mapping effect used in BabylonJS.
  87976. */
  87977. toneMappingType: number;
  87978. protected _contrast: number;
  87979. /**
  87980. * Gets the contrast used in the effect.
  87981. */
  87982. /**
  87983. * Sets the contrast used in the effect.
  87984. */
  87985. contrast: number;
  87986. /**
  87987. * Vignette stretch size.
  87988. */
  87989. vignetteStretch: number;
  87990. /**
  87991. * Vignette centre X Offset.
  87992. */
  87993. vignetteCentreX: number;
  87994. /**
  87995. * Vignette centre Y Offset.
  87996. */
  87997. vignetteCentreY: number;
  87998. /**
  87999. * Vignette weight or intensity of the vignette effect.
  88000. */
  88001. vignetteWeight: number;
  88002. /**
  88003. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88004. * if vignetteEnabled is set to true.
  88005. */
  88006. vignetteColor: Color4;
  88007. /**
  88008. * Camera field of view used by the Vignette effect.
  88009. */
  88010. vignetteCameraFov: number;
  88011. private _vignetteBlendMode;
  88012. /**
  88013. * Gets the vignette blend mode allowing different kind of effect.
  88014. */
  88015. /**
  88016. * Sets the vignette blend mode allowing different kind of effect.
  88017. */
  88018. vignetteBlendMode: number;
  88019. private _vignetteEnabled;
  88020. /**
  88021. * Gets wether the vignette effect is enabled.
  88022. */
  88023. /**
  88024. * Sets wether the vignette effect is enabled.
  88025. */
  88026. vignetteEnabled: boolean;
  88027. private _applyByPostProcess;
  88028. /**
  88029. * Gets wether the image processing is applied through a post process or not.
  88030. */
  88031. /**
  88032. * Sets wether the image processing is applied through a post process or not.
  88033. */
  88034. applyByPostProcess: boolean;
  88035. private _isEnabled;
  88036. /**
  88037. * Gets wether the image processing is enabled or not.
  88038. */
  88039. /**
  88040. * Sets wether the image processing is enabled or not.
  88041. */
  88042. isEnabled: boolean;
  88043. /**
  88044. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88045. */
  88046. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88047. /**
  88048. * Method called each time the image processing information changes requires to recompile the effect.
  88049. */
  88050. protected _updateParameters(): void;
  88051. /**
  88052. * Gets the current class name.
  88053. * @return "ImageProcessingConfiguration"
  88054. */
  88055. getClassName(): string;
  88056. /**
  88057. * Prepare the list of uniforms associated with the Image Processing effects.
  88058. * @param uniforms The list of uniforms used in the effect
  88059. * @param defines the list of defines currently in use
  88060. */
  88061. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88062. /**
  88063. * Prepare the list of samplers associated with the Image Processing effects.
  88064. * @param samplersList The list of uniforms used in the effect
  88065. * @param defines the list of defines currently in use
  88066. */
  88067. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88068. /**
  88069. * Prepare the list of defines associated to the shader.
  88070. * @param defines the list of defines to complete
  88071. * @param forPostProcess Define if we are currently in post process mode or not
  88072. */
  88073. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88074. /**
  88075. * Returns true if all the image processing information are ready.
  88076. * @returns True if ready, otherwise, false
  88077. */
  88078. isReady(): boolean;
  88079. /**
  88080. * Binds the image processing to the shader.
  88081. * @param effect The effect to bind to
  88082. * @param aspectRatio Define the current aspect ratio of the effect
  88083. */
  88084. bind(effect: Effect, aspectRatio?: number): void;
  88085. /**
  88086. * Clones the current image processing instance.
  88087. * @return The cloned image processing
  88088. */
  88089. clone(): ImageProcessingConfiguration;
  88090. /**
  88091. * Serializes the current image processing instance to a json representation.
  88092. * @return a JSON representation
  88093. */
  88094. serialize(): any;
  88095. /**
  88096. * Parses the image processing from a json representation.
  88097. * @param source the JSON source to parse
  88098. * @return The parsed image processing
  88099. */
  88100. static Parse(source: any): ImageProcessingConfiguration;
  88101. private static _VIGNETTEMODE_MULTIPLY;
  88102. private static _VIGNETTEMODE_OPAQUE;
  88103. /**
  88104. * Used to apply the vignette as a mix with the pixel color.
  88105. */
  88106. static readonly VIGNETTEMODE_MULTIPLY: number;
  88107. /**
  88108. * Used to apply the vignette as a replacement of the pixel color.
  88109. */
  88110. static readonly VIGNETTEMODE_OPAQUE: number;
  88111. }
  88112. }
  88113. declare module BABYLON {
  88114. /**
  88115. * This represents all the required information to add a fresnel effect on a material:
  88116. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  88117. */
  88118. export class FresnelParameters {
  88119. private _isEnabled;
  88120. /**
  88121. * Define if the fresnel effect is enable or not.
  88122. */
  88123. isEnabled: boolean;
  88124. /**
  88125. * Define the color used on edges (grazing angle)
  88126. */
  88127. leftColor: Color3;
  88128. /**
  88129. * Define the color used on center
  88130. */
  88131. rightColor: Color3;
  88132. /**
  88133. * Define bias applied to computed fresnel term
  88134. */
  88135. bias: number;
  88136. /**
  88137. * Defined the power exponent applied to fresnel term
  88138. */
  88139. power: number;
  88140. /**
  88141. * Clones the current fresnel and its valuues
  88142. * @returns a clone fresnel configuration
  88143. */
  88144. clone(): FresnelParameters;
  88145. /**
  88146. * Serializes the current fresnel parameters to a JSON representation.
  88147. * @return the JSON serialization
  88148. */
  88149. serialize(): any;
  88150. /**
  88151. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  88152. * @param parsedFresnelParameters Define the JSON representation
  88153. * @returns the parsed parameters
  88154. */
  88155. static Parse(parsedFresnelParameters: any): FresnelParameters;
  88156. }
  88157. }
  88158. declare module BABYLON {
  88159. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  88160. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88161. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88162. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88163. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88164. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88165. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88166. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88167. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88168. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88169. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88170. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88171. /**
  88172. * Decorator used to define property that can be serialized as reference to a camera
  88173. * @param sourceName defines the name of the property to decorate
  88174. */
  88175. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88176. /**
  88177. * Class used to help serialization objects
  88178. */
  88179. export class SerializationHelper {
  88180. /** hidden */
  88181. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  88182. /** hidden */
  88183. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  88184. /** hidden */
  88185. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  88186. /** hidden */
  88187. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  88188. /**
  88189. * Appends the serialized animations from the source animations
  88190. * @param source Source containing the animations
  88191. * @param destination Target to store the animations
  88192. */
  88193. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88194. /**
  88195. * Static function used to serialized a specific entity
  88196. * @param entity defines the entity to serialize
  88197. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  88198. * @returns a JSON compatible object representing the serialization of the entity
  88199. */
  88200. static Serialize<T>(entity: T, serializationObject?: any): any;
  88201. /**
  88202. * Creates a new entity from a serialization data object
  88203. * @param creationFunction defines a function used to instanciated the new entity
  88204. * @param source defines the source serialization data
  88205. * @param scene defines the hosting scene
  88206. * @param rootUrl defines the root url for resources
  88207. * @returns a new entity
  88208. */
  88209. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  88210. /**
  88211. * Clones an object
  88212. * @param creationFunction defines the function used to instanciate the new object
  88213. * @param source defines the source object
  88214. * @returns the cloned object
  88215. */
  88216. static Clone<T>(creationFunction: () => T, source: T): T;
  88217. /**
  88218. * Instanciates a new object based on a source one (some data will be shared between both object)
  88219. * @param creationFunction defines the function used to instanciate the new object
  88220. * @param source defines the source object
  88221. * @returns the new object
  88222. */
  88223. static Instanciate<T>(creationFunction: () => T, source: T): T;
  88224. }
  88225. }
  88226. declare module BABYLON {
  88227. /**
  88228. * This is the base class of all the camera used in the application.
  88229. * @see http://doc.babylonjs.com/features/cameras
  88230. */
  88231. export class Camera extends Node {
  88232. /** @hidden */
  88233. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88234. /**
  88235. * This is the default projection mode used by the cameras.
  88236. * It helps recreating a feeling of perspective and better appreciate depth.
  88237. * This is the best way to simulate real life cameras.
  88238. */
  88239. static readonly PERSPECTIVE_CAMERA: number;
  88240. /**
  88241. * This helps creating camera with an orthographic mode.
  88242. * 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.
  88243. */
  88244. static readonly ORTHOGRAPHIC_CAMERA: number;
  88245. /**
  88246. * This is the default FOV mode for perspective cameras.
  88247. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88248. */
  88249. static readonly FOVMODE_VERTICAL_FIXED: number;
  88250. /**
  88251. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88252. */
  88253. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88254. /**
  88255. * This specifies ther is no need for a camera rig.
  88256. * Basically only one eye is rendered corresponding to the camera.
  88257. */
  88258. static readonly RIG_MODE_NONE: number;
  88259. /**
  88260. * Simulates a camera Rig with one blue eye and one red eye.
  88261. * This can be use with 3d blue and red glasses.
  88262. */
  88263. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88264. /**
  88265. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88266. */
  88267. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88268. /**
  88269. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88270. */
  88271. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88272. /**
  88273. * Defines that both eyes of the camera will be rendered over under each other.
  88274. */
  88275. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88276. /**
  88277. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88278. */
  88279. static readonly RIG_MODE_VR: number;
  88280. /**
  88281. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88282. */
  88283. static readonly RIG_MODE_WEBVR: number;
  88284. /**
  88285. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88286. */
  88287. static readonly RIG_MODE_CUSTOM: number;
  88288. /**
  88289. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88290. */
  88291. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88292. /**
  88293. * @hidden
  88294. * Might be removed once multiview will be a thing
  88295. */
  88296. static UseAlternateWebVRRendering: boolean;
  88297. /**
  88298. * Define the input manager associated with the camera.
  88299. */
  88300. inputs: CameraInputsManager<Camera>;
  88301. /** @hidden */
  88302. _position: Vector3;
  88303. /**
  88304. * Define the current local position of the camera in the scene
  88305. */
  88306. position: Vector3;
  88307. /**
  88308. * The vector the camera should consider as up.
  88309. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88310. */
  88311. upVector: Vector3;
  88312. /**
  88313. * Define the current limit on the left side for an orthographic camera
  88314. * In scene unit
  88315. */
  88316. orthoLeft: Nullable<number>;
  88317. /**
  88318. * Define the current limit on the right side for an orthographic camera
  88319. * In scene unit
  88320. */
  88321. orthoRight: Nullable<number>;
  88322. /**
  88323. * Define the current limit on the bottom side for an orthographic camera
  88324. * In scene unit
  88325. */
  88326. orthoBottom: Nullable<number>;
  88327. /**
  88328. * Define the current limit on the top side for an orthographic camera
  88329. * In scene unit
  88330. */
  88331. orthoTop: Nullable<number>;
  88332. /**
  88333. * Field Of View is set in Radians. (default is 0.8)
  88334. */
  88335. fov: number;
  88336. /**
  88337. * Define the minimum distance the camera can see from.
  88338. * This is important to note that the depth buffer are not infinite and the closer it starts
  88339. * the more your scene might encounter depth fighting issue.
  88340. */
  88341. minZ: number;
  88342. /**
  88343. * Define the maximum distance the camera can see to.
  88344. * This is important to note that the depth buffer are not infinite and the further it end
  88345. * the more your scene might encounter depth fighting issue.
  88346. */
  88347. maxZ: number;
  88348. /**
  88349. * Define the default inertia of the camera.
  88350. * This helps giving a smooth feeling to the camera movement.
  88351. */
  88352. inertia: number;
  88353. /**
  88354. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  88355. */
  88356. mode: number;
  88357. /**
  88358. * Define wether the camera is intermediate.
  88359. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88360. */
  88361. isIntermediate: boolean;
  88362. /**
  88363. * Define the viewport of the camera.
  88364. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88365. */
  88366. viewport: Viewport;
  88367. /**
  88368. * Restricts the camera to viewing objects with the same layerMask.
  88369. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88370. */
  88371. layerMask: number;
  88372. /**
  88373. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88374. */
  88375. fovMode: number;
  88376. /**
  88377. * Rig mode of the camera.
  88378. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88379. * This is normally controlled byt the camera themselves as internal use.
  88380. */
  88381. cameraRigMode: number;
  88382. /**
  88383. * Defines the distance between both "eyes" in case of a RIG
  88384. */
  88385. interaxialDistance: number;
  88386. /**
  88387. * Defines if stereoscopic rendering is done side by side or over under.
  88388. */
  88389. isStereoscopicSideBySide: boolean;
  88390. /**
  88391. * 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
  88392. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88393. * else in the scene.
  88394. */
  88395. customRenderTargets: RenderTargetTexture[];
  88396. /**
  88397. * When set, the camera will render to this render target instead of the default canvas
  88398. */
  88399. outputRenderTarget: Nullable<RenderTargetTexture>;
  88400. /**
  88401. * Observable triggered when the camera view matrix has changed.
  88402. */
  88403. onViewMatrixChangedObservable: Observable<Camera>;
  88404. /**
  88405. * Observable triggered when the camera Projection matrix has changed.
  88406. */
  88407. onProjectionMatrixChangedObservable: Observable<Camera>;
  88408. /**
  88409. * Observable triggered when the inputs have been processed.
  88410. */
  88411. onAfterCheckInputsObservable: Observable<Camera>;
  88412. /**
  88413. * Observable triggered when reset has been called and applied to the camera.
  88414. */
  88415. onRestoreStateObservable: Observable<Camera>;
  88416. /** @hidden */
  88417. _cameraRigParams: any;
  88418. /** @hidden */
  88419. _rigCameras: Camera[];
  88420. /** @hidden */
  88421. _rigPostProcess: Nullable<PostProcess>;
  88422. protected _webvrViewMatrix: Matrix;
  88423. /** @hidden */
  88424. _skipRendering: boolean;
  88425. /** @hidden */
  88426. _alternateCamera: Camera;
  88427. /** @hidden */
  88428. _projectionMatrix: Matrix;
  88429. /** @hidden */
  88430. _postProcesses: Nullable<PostProcess>[];
  88431. /** @hidden */
  88432. _activeMeshes: SmartArray<AbstractMesh>;
  88433. protected _globalPosition: Vector3;
  88434. /** hidden */
  88435. _computedViewMatrix: Matrix;
  88436. private _doNotComputeProjectionMatrix;
  88437. private _transformMatrix;
  88438. private _frustumPlanes;
  88439. private _refreshFrustumPlanes;
  88440. private _storedFov;
  88441. private _stateStored;
  88442. /**
  88443. * Instantiates a new camera object.
  88444. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88445. * @see http://doc.babylonjs.com/features/cameras
  88446. * @param name Defines the name of the camera in the scene
  88447. * @param position Defines the position of the camera
  88448. * @param scene Defines the scene the camera belongs too
  88449. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88450. */
  88451. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88452. /**
  88453. * Store current camera state (fov, position, etc..)
  88454. * @returns the camera
  88455. */
  88456. storeState(): Camera;
  88457. /**
  88458. * Restores the camera state values if it has been stored. You must call storeState() first
  88459. */
  88460. protected _restoreStateValues(): boolean;
  88461. /**
  88462. * Restored camera state. You must call storeState() first.
  88463. * @returns true if restored and false otherwise
  88464. */
  88465. restoreState(): boolean;
  88466. /**
  88467. * Gets the class name of the camera.
  88468. * @returns the class name
  88469. */
  88470. getClassName(): string;
  88471. /** @hidden */
  88472. readonly _isCamera: boolean;
  88473. /**
  88474. * Gets a string representation of the camera useful for debug purpose.
  88475. * @param fullDetails Defines that a more verboe level of logging is required
  88476. * @returns the string representation
  88477. */
  88478. toString(fullDetails?: boolean): string;
  88479. /**
  88480. * Gets the current world space position of the camera.
  88481. */
  88482. readonly globalPosition: Vector3;
  88483. /**
  88484. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88485. * @returns the active meshe list
  88486. */
  88487. getActiveMeshes(): SmartArray<AbstractMesh>;
  88488. /**
  88489. * Check wether a mesh is part of the current active mesh list of the camera
  88490. * @param mesh Defines the mesh to check
  88491. * @returns true if active, false otherwise
  88492. */
  88493. isActiveMesh(mesh: Mesh): boolean;
  88494. /**
  88495. * Is this camera ready to be used/rendered
  88496. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88497. * @return true if the camera is ready
  88498. */
  88499. isReady(completeCheck?: boolean): boolean;
  88500. /** @hidden */
  88501. _initCache(): void;
  88502. /** @hidden */
  88503. _updateCache(ignoreParentClass?: boolean): void;
  88504. /** @hidden */
  88505. _isSynchronized(): boolean;
  88506. /** @hidden */
  88507. _isSynchronizedViewMatrix(): boolean;
  88508. /** @hidden */
  88509. _isSynchronizedProjectionMatrix(): boolean;
  88510. /**
  88511. * Attach the input controls to a specific dom element to get the input from.
  88512. * @param element Defines the element the controls should be listened from
  88513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88514. */
  88515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88516. /**
  88517. * Detach the current controls from the specified dom element.
  88518. * @param element Defines the element to stop listening the inputs from
  88519. */
  88520. detachControl(element: HTMLElement): void;
  88521. /**
  88522. * Update the camera state according to the different inputs gathered during the frame.
  88523. */
  88524. update(): void;
  88525. /** @hidden */
  88526. _checkInputs(): void;
  88527. /** @hidden */
  88528. readonly rigCameras: Camera[];
  88529. /**
  88530. * Gets the post process used by the rig cameras
  88531. */
  88532. readonly rigPostProcess: Nullable<PostProcess>;
  88533. /**
  88534. * Internal, gets the first post proces.
  88535. * @returns the first post process to be run on this camera.
  88536. */
  88537. _getFirstPostProcess(): Nullable<PostProcess>;
  88538. private _cascadePostProcessesToRigCams;
  88539. /**
  88540. * Attach a post process to the camera.
  88541. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88542. * @param postProcess The post process to attach to the camera
  88543. * @param insertAt The position of the post process in case several of them are in use in the scene
  88544. * @returns the position the post process has been inserted at
  88545. */
  88546. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88547. /**
  88548. * Detach a post process to the camera.
  88549. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88550. * @param postProcess The post process to detach from the camera
  88551. */
  88552. detachPostProcess(postProcess: PostProcess): void;
  88553. /**
  88554. * Gets the current world matrix of the camera
  88555. */
  88556. getWorldMatrix(): Matrix;
  88557. /** @hidden */
  88558. _getViewMatrix(): Matrix;
  88559. /**
  88560. * Gets the current view matrix of the camera.
  88561. * @param force forces the camera to recompute the matrix without looking at the cached state
  88562. * @returns the view matrix
  88563. */
  88564. getViewMatrix(force?: boolean): Matrix;
  88565. /**
  88566. * Freeze the projection matrix.
  88567. * It will prevent the cache check of the camera projection compute and can speed up perf
  88568. * if no parameter of the camera are meant to change
  88569. * @param projection Defines manually a projection if necessary
  88570. */
  88571. freezeProjectionMatrix(projection?: Matrix): void;
  88572. /**
  88573. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88574. */
  88575. unfreezeProjectionMatrix(): void;
  88576. /**
  88577. * Gets the current projection matrix of the camera.
  88578. * @param force forces the camera to recompute the matrix without looking at the cached state
  88579. * @returns the projection matrix
  88580. */
  88581. getProjectionMatrix(force?: boolean): Matrix;
  88582. /**
  88583. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88584. * @returns a Matrix
  88585. */
  88586. getTransformationMatrix(): Matrix;
  88587. private _updateFrustumPlanes;
  88588. /**
  88589. * Checks if a cullable object (mesh...) is in the camera frustum
  88590. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88591. * @param target The object to check
  88592. * @returns true if the object is in frustum otherwise false
  88593. */
  88594. isInFrustum(target: ICullable): boolean;
  88595. /**
  88596. * Checks if a cullable object (mesh...) is in the camera frustum
  88597. * Unlike isInFrustum this cheks the full bounding box
  88598. * @param target The object to check
  88599. * @returns true if the object is in frustum otherwise false
  88600. */
  88601. isCompletelyInFrustum(target: ICullable): boolean;
  88602. /**
  88603. * Gets a ray in the forward direction from the camera.
  88604. * @param length Defines the length of the ray to create
  88605. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88606. * @param origin Defines the start point of the ray which defaults to the camera position
  88607. * @returns the forward ray
  88608. */
  88609. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88610. /**
  88611. * Releases resources associated with this node.
  88612. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88613. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88614. */
  88615. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88616. /** @hidden */
  88617. _isLeftCamera: boolean;
  88618. /**
  88619. * Gets the left camera of a rig setup in case of Rigged Camera
  88620. */
  88621. readonly isLeftCamera: boolean;
  88622. /** @hidden */
  88623. _isRightCamera: boolean;
  88624. /**
  88625. * Gets the right camera of a rig setup in case of Rigged Camera
  88626. */
  88627. readonly isRightCamera: boolean;
  88628. /**
  88629. * Gets the left camera of a rig setup in case of Rigged Camera
  88630. */
  88631. readonly leftCamera: Nullable<FreeCamera>;
  88632. /**
  88633. * Gets the right camera of a rig setup in case of Rigged Camera
  88634. */
  88635. readonly rightCamera: Nullable<FreeCamera>;
  88636. /**
  88637. * Gets the left camera target of a rig setup in case of Rigged Camera
  88638. * @returns the target position
  88639. */
  88640. getLeftTarget(): Nullable<Vector3>;
  88641. /**
  88642. * Gets the right camera target of a rig setup in case of Rigged Camera
  88643. * @returns the target position
  88644. */
  88645. getRightTarget(): Nullable<Vector3>;
  88646. /**
  88647. * @hidden
  88648. */
  88649. setCameraRigMode(mode: number, rigParams: any): void;
  88650. /** @hidden */
  88651. static _setStereoscopicRigMode(camera: Camera): void;
  88652. /** @hidden */
  88653. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88654. /** @hidden */
  88655. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88656. /** @hidden */
  88657. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88658. /** @hidden */
  88659. _getVRProjectionMatrix(): Matrix;
  88660. protected _updateCameraRotationMatrix(): void;
  88661. protected _updateWebVRCameraRotationMatrix(): void;
  88662. /**
  88663. * This function MUST be overwritten by the different WebVR cameras available.
  88664. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88665. * @hidden
  88666. */
  88667. _getWebVRProjectionMatrix(): Matrix;
  88668. /**
  88669. * This function MUST be overwritten by the different WebVR cameras available.
  88670. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88671. * @hidden
  88672. */
  88673. _getWebVRViewMatrix(): Matrix;
  88674. /** @hidden */
  88675. setCameraRigParameter(name: string, value: any): void;
  88676. /**
  88677. * needs to be overridden by children so sub has required properties to be copied
  88678. * @hidden
  88679. */
  88680. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88681. /**
  88682. * May need to be overridden by children
  88683. * @hidden
  88684. */
  88685. _updateRigCameras(): void;
  88686. /** @hidden */
  88687. _setupInputs(): void;
  88688. /**
  88689. * Serialiaze the camera setup to a json represention
  88690. * @returns the JSON representation
  88691. */
  88692. serialize(): any;
  88693. /**
  88694. * Clones the current camera.
  88695. * @param name The cloned camera name
  88696. * @returns the cloned camera
  88697. */
  88698. clone(name: string): Camera;
  88699. /**
  88700. * Gets the direction of the camera relative to a given local axis.
  88701. * @param localAxis Defines the reference axis to provide a relative direction.
  88702. * @return the direction
  88703. */
  88704. getDirection(localAxis: Vector3): Vector3;
  88705. /**
  88706. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88707. * @param localAxis Defines the reference axis to provide a relative direction.
  88708. * @param result Defines the vector to store the result in
  88709. */
  88710. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88711. /**
  88712. * Gets a camera constructor for a given camera type
  88713. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88714. * @param name The name of the camera the result will be able to instantiate
  88715. * @param scene The scene the result will construct the camera in
  88716. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88717. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88718. * @returns a factory method to construc the camera
  88719. */
  88720. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88721. /**
  88722. * Compute the world matrix of the camera.
  88723. * @returns the camera workd matrix
  88724. */
  88725. computeWorldMatrix(): Matrix;
  88726. /**
  88727. * Parse a JSON and creates the camera from the parsed information
  88728. * @param parsedCamera The JSON to parse
  88729. * @param scene The scene to instantiate the camera in
  88730. * @returns the newly constructed camera
  88731. */
  88732. static Parse(parsedCamera: any, scene: Scene): Camera;
  88733. }
  88734. }
  88735. declare module BABYLON {
  88736. /**
  88737. * Interface for any object that can request an animation frame
  88738. */
  88739. export interface ICustomAnimationFrameRequester {
  88740. /**
  88741. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  88742. */
  88743. renderFunction?: Function;
  88744. /**
  88745. * Called to request the next frame to render to
  88746. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  88747. */
  88748. requestAnimationFrame: Function;
  88749. /**
  88750. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  88751. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  88752. */
  88753. requestID?: number;
  88754. }
  88755. /**
  88756. * Interface containing an array of animations
  88757. */
  88758. export interface IAnimatable {
  88759. /**
  88760. * Array of animations
  88761. */
  88762. animations: Array<Animation>;
  88763. }
  88764. /** Interface used by value gradients (color, factor, ...) */
  88765. export interface IValueGradient {
  88766. /**
  88767. * Gets or sets the gradient value (between 0 and 1)
  88768. */
  88769. gradient: number;
  88770. }
  88771. /** Class used to store color4 gradient */
  88772. export class ColorGradient implements IValueGradient {
  88773. /**
  88774. * Gets or sets the gradient value (between 0 and 1)
  88775. */
  88776. gradient: number;
  88777. /**
  88778. * Gets or sets first associated color
  88779. */
  88780. color1: Color4;
  88781. /**
  88782. * Gets or sets second associated color
  88783. */
  88784. color2?: Color4;
  88785. /**
  88786. * Will get a color picked randomly between color1 and color2.
  88787. * If color2 is undefined then color1 will be used
  88788. * @param result defines the target Color4 to store the result in
  88789. */
  88790. getColorToRef(result: Color4): void;
  88791. }
  88792. /** Class used to store color 3 gradient */
  88793. export class Color3Gradient implements IValueGradient {
  88794. /**
  88795. * Gets or sets the gradient value (between 0 and 1)
  88796. */
  88797. gradient: number;
  88798. /**
  88799. * Gets or sets the associated color
  88800. */
  88801. color: Color3;
  88802. }
  88803. /** Class used to store factor gradient */
  88804. export class FactorGradient implements IValueGradient {
  88805. /**
  88806. * Gets or sets the gradient value (between 0 and 1)
  88807. */
  88808. gradient: number;
  88809. /**
  88810. * Gets or sets first associated factor
  88811. */
  88812. factor1: number;
  88813. /**
  88814. * Gets or sets second associated factor
  88815. */
  88816. factor2?: number;
  88817. /**
  88818. * Will get a number picked randomly between factor1 and factor2.
  88819. * If factor2 is undefined then factor1 will be used
  88820. * @returns the picked number
  88821. */
  88822. getFactor(): number;
  88823. }
  88824. /**
  88825. * @ignore
  88826. * Application error to support additional information when loading a file
  88827. */
  88828. export class LoadFileError extends Error {
  88829. /** defines the optional web request */
  88830. request?: WebRequest | undefined;
  88831. private static _setPrototypeOf;
  88832. /**
  88833. * Creates a new LoadFileError
  88834. * @param message defines the message of the error
  88835. * @param request defines the optional web request
  88836. */
  88837. constructor(message: string,
  88838. /** defines the optional web request */
  88839. request?: WebRequest | undefined);
  88840. }
  88841. /**
  88842. * Class used to define a retry strategy when error happens while loading assets
  88843. */
  88844. export class RetryStrategy {
  88845. /**
  88846. * Function used to defines an exponential back off strategy
  88847. * @param maxRetries defines the maximum number of retries (3 by default)
  88848. * @param baseInterval defines the interval between retries
  88849. * @returns the strategy function to use
  88850. */
  88851. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  88852. }
  88853. /**
  88854. * File request interface
  88855. */
  88856. export interface IFileRequest {
  88857. /**
  88858. * Raised when the request is complete (success or error).
  88859. */
  88860. onCompleteObservable: Observable<IFileRequest>;
  88861. /**
  88862. * Aborts the request for a file.
  88863. */
  88864. abort: () => void;
  88865. }
  88866. /**
  88867. * Class containing a set of static utilities functions
  88868. */
  88869. export class Tools {
  88870. /**
  88871. * Gets or sets the base URL to use to load assets
  88872. */
  88873. static BaseUrl: string;
  88874. /**
  88875. * Enable/Disable Custom HTTP Request Headers globally.
  88876. * default = false
  88877. * @see CustomRequestHeaders
  88878. */
  88879. static UseCustomRequestHeaders: boolean;
  88880. /**
  88881. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  88882. * i.e. when loading files, where the server/service expects an Authorization header
  88883. */
  88884. static CustomRequestHeaders: {
  88885. [key: string]: string;
  88886. };
  88887. /**
  88888. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  88889. */
  88890. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  88891. /**
  88892. * Default behaviour for cors in the application.
  88893. * It can be a string if the expected behavior is identical in the entire app.
  88894. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  88895. */
  88896. static CorsBehavior: string | ((url: string | string[]) => string);
  88897. /**
  88898. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  88899. * @ignorenaming
  88900. */
  88901. static UseFallbackTexture: boolean;
  88902. /**
  88903. * Use this object to register external classes like custom textures or material
  88904. * to allow the laoders to instantiate them
  88905. */
  88906. static RegisteredExternalClasses: {
  88907. [key: string]: Object;
  88908. };
  88909. /**
  88910. * Texture content used if a texture cannot loaded
  88911. * @ignorenaming
  88912. */
  88913. static fallbackTexture: string;
  88914. /**
  88915. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  88916. * @param u defines the coordinate on X axis
  88917. * @param v defines the coordinate on Y axis
  88918. * @param width defines the width of the source data
  88919. * @param height defines the height of the source data
  88920. * @param pixels defines the source byte array
  88921. * @param color defines the output color
  88922. */
  88923. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  88924. /**
  88925. * Interpolates between a and b via alpha
  88926. * @param a The lower value (returned when alpha = 0)
  88927. * @param b The upper value (returned when alpha = 1)
  88928. * @param alpha The interpolation-factor
  88929. * @return The mixed value
  88930. */
  88931. static Mix(a: number, b: number, alpha: number): number;
  88932. /**
  88933. * Tries to instantiate a new object from a given class name
  88934. * @param className defines the class name to instantiate
  88935. * @returns the new object or null if the system was not able to do the instantiation
  88936. */
  88937. static Instantiate(className: string): any;
  88938. /**
  88939. * Provides a slice function that will work even on IE
  88940. * @param data defines the array to slice
  88941. * @param start defines the start of the data (optional)
  88942. * @param end defines the end of the data (optional)
  88943. * @returns the new sliced array
  88944. */
  88945. static Slice<T>(data: T, start?: number, end?: number): T;
  88946. /**
  88947. * Polyfill for setImmediate
  88948. * @param action defines the action to execute after the current execution block
  88949. */
  88950. static SetImmediate(action: () => void): void;
  88951. /**
  88952. * Function indicating if a number is an exponent of 2
  88953. * @param value defines the value to test
  88954. * @returns true if the value is an exponent of 2
  88955. */
  88956. static IsExponentOfTwo(value: number): boolean;
  88957. private static _tmpFloatArray;
  88958. /**
  88959. * Returns the nearest 32-bit single precision float representation of a Number
  88960. * @param value A Number. If the parameter is of a different type, it will get converted
  88961. * to a number or to NaN if it cannot be converted
  88962. * @returns number
  88963. */
  88964. static FloatRound(value: number): number;
  88965. /**
  88966. * Find the next highest power of two.
  88967. * @param x Number to start search from.
  88968. * @return Next highest power of two.
  88969. */
  88970. static CeilingPOT(x: number): number;
  88971. /**
  88972. * Find the next lowest power of two.
  88973. * @param x Number to start search from.
  88974. * @return Next lowest power of two.
  88975. */
  88976. static FloorPOT(x: number): number;
  88977. /**
  88978. * Find the nearest power of two.
  88979. * @param x Number to start search from.
  88980. * @return Next nearest power of two.
  88981. */
  88982. static NearestPOT(x: number): number;
  88983. /**
  88984. * Get the closest exponent of two
  88985. * @param value defines the value to approximate
  88986. * @param max defines the maximum value to return
  88987. * @param mode defines how to define the closest value
  88988. * @returns closest exponent of two of the given value
  88989. */
  88990. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  88991. /**
  88992. * Extracts the filename from a path
  88993. * @param path defines the path to use
  88994. * @returns the filename
  88995. */
  88996. static GetFilename(path: string): string;
  88997. /**
  88998. * Extracts the "folder" part of a path (everything before the filename).
  88999. * @param uri The URI to extract the info from
  89000. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  89001. * @returns The "folder" part of the path
  89002. */
  89003. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  89004. /**
  89005. * Extracts text content from a DOM element hierarchy
  89006. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  89007. */
  89008. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  89009. /**
  89010. * Convert an angle in radians to degrees
  89011. * @param angle defines the angle to convert
  89012. * @returns the angle in degrees
  89013. */
  89014. static ToDegrees(angle: number): number;
  89015. /**
  89016. * Convert an angle in degrees to radians
  89017. * @param angle defines the angle to convert
  89018. * @returns the angle in radians
  89019. */
  89020. static ToRadians(angle: number): number;
  89021. /**
  89022. * Encode a buffer to a base64 string
  89023. * @param buffer defines the buffer to encode
  89024. * @returns the encoded string
  89025. */
  89026. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  89027. /**
  89028. * Extracts minimum and maximum values from a list of indexed positions
  89029. * @param positions defines the positions to use
  89030. * @param indices defines the indices to the positions
  89031. * @param indexStart defines the start index
  89032. * @param indexCount defines the end index
  89033. * @param bias defines bias value to add to the result
  89034. * @return minimum and maximum values
  89035. */
  89036. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89037. minimum: Vector3;
  89038. maximum: Vector3;
  89039. };
  89040. /**
  89041. * Extracts minimum and maximum values from a list of positions
  89042. * @param positions defines the positions to use
  89043. * @param start defines the start index in the positions array
  89044. * @param count defines the number of positions to handle
  89045. * @param bias defines bias value to add to the result
  89046. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89047. * @return minimum and maximum values
  89048. */
  89049. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89050. minimum: Vector3;
  89051. maximum: Vector3;
  89052. };
  89053. /**
  89054. * Returns an array if obj is not an array
  89055. * @param obj defines the object to evaluate as an array
  89056. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  89057. * @returns either obj directly if obj is an array or a new array containing obj
  89058. */
  89059. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  89060. /**
  89061. * Gets the pointer prefix to use
  89062. * @returns "pointer" if touch is enabled. Else returns "mouse"
  89063. */
  89064. static GetPointerPrefix(): string;
  89065. /**
  89066. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  89067. * @param func - the function to be called
  89068. * @param requester - the object that will request the next frame. Falls back to window.
  89069. * @returns frame number
  89070. */
  89071. static QueueNewFrame(func: () => void, requester?: any): number;
  89072. /**
  89073. * Ask the browser to promote the current element to fullscreen rendering mode
  89074. * @param element defines the DOM element to promote
  89075. */
  89076. static RequestFullscreen(element: HTMLElement): void;
  89077. /**
  89078. * Asks the browser to exit fullscreen mode
  89079. */
  89080. static ExitFullscreen(): void;
  89081. /**
  89082. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89083. * @param url define the url we are trying
  89084. * @param element define the dom element where to configure the cors policy
  89085. */
  89086. static SetCorsBehavior(url: string | string[], element: {
  89087. crossOrigin: string | null;
  89088. }): void;
  89089. /**
  89090. * Removes unwanted characters from an url
  89091. * @param url defines the url to clean
  89092. * @returns the cleaned url
  89093. */
  89094. static CleanUrl(url: string): string;
  89095. /**
  89096. * Gets or sets a function used to pre-process url before using them to load assets
  89097. */
  89098. static PreprocessUrl: (url: string) => string;
  89099. /**
  89100. * Loads an image as an HTMLImageElement.
  89101. * @param input url string, ArrayBuffer, or Blob to load
  89102. * @param onLoad callback called when the image successfully loads
  89103. * @param onError callback called when the image fails to load
  89104. * @param offlineProvider offline provider for caching
  89105. * @returns the HTMLImageElement of the loaded image
  89106. */
  89107. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  89108. /**
  89109. * Loads a file
  89110. * @param url url string, ArrayBuffer, or Blob to load
  89111. * @param onSuccess callback called when the file successfully loads
  89112. * @param onProgress callback called while file is loading (if the server supports this mode)
  89113. * @param offlineProvider defines the offline provider for caching
  89114. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  89115. * @param onError callback called when the file fails to load
  89116. * @returns a file request object
  89117. */
  89118. 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;
  89119. /**
  89120. * Load a script (identified by an url). When the url returns, the
  89121. * content of this file is added into a new script element, attached to the DOM (body element)
  89122. * @param scriptUrl defines the url of the script to laod
  89123. * @param onSuccess defines the callback called when the script is loaded
  89124. * @param onError defines the callback to call if an error occurs
  89125. */
  89126. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  89127. /**
  89128. * Loads a file from a blob
  89129. * @param fileToLoad defines the blob to use
  89130. * @param callback defines the callback to call when data is loaded
  89131. * @param progressCallback defines the callback to call during loading process
  89132. * @returns a file request object
  89133. */
  89134. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  89135. /**
  89136. * Loads a file
  89137. * @param fileToLoad defines the file to load
  89138. * @param callback defines the callback to call when data is loaded
  89139. * @param progressCallBack defines the callback to call during loading process
  89140. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  89141. * @returns a file request object
  89142. */
  89143. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  89144. /**
  89145. * Creates a data url from a given string content
  89146. * @param content defines the content to convert
  89147. * @returns the new data url link
  89148. */
  89149. static FileAsURL(content: string): string;
  89150. /**
  89151. * Format the given number to a specific decimal format
  89152. * @param value defines the number to format
  89153. * @param decimals defines the number of decimals to use
  89154. * @returns the formatted string
  89155. */
  89156. static Format(value: number, decimals?: number): string;
  89157. /**
  89158. * Checks if a given vector is inside a specific range
  89159. * @param v defines the vector to test
  89160. * @param min defines the minimum range
  89161. * @param max defines the maximum range
  89162. */
  89163. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  89164. /**
  89165. * Tries to copy an object by duplicating every property
  89166. * @param source defines the source object
  89167. * @param destination defines the target object
  89168. * @param doNotCopyList defines a list of properties to avoid
  89169. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  89170. */
  89171. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  89172. /**
  89173. * Gets a boolean indicating if the given object has no own property
  89174. * @param obj defines the object to test
  89175. * @returns true if object has no own property
  89176. */
  89177. static IsEmpty(obj: any): boolean;
  89178. /**
  89179. * Function used to register events at window level
  89180. * @param events defines the events to register
  89181. */
  89182. static RegisterTopRootEvents(events: {
  89183. name: string;
  89184. handler: Nullable<(e: FocusEvent) => any>;
  89185. }[]): void;
  89186. /**
  89187. * Function used to unregister events from window level
  89188. * @param events defines the events to unregister
  89189. */
  89190. static UnregisterTopRootEvents(events: {
  89191. name: string;
  89192. handler: Nullable<(e: FocusEvent) => any>;
  89193. }[]): void;
  89194. /**
  89195. * @ignore
  89196. */
  89197. static _ScreenshotCanvas: HTMLCanvasElement;
  89198. /**
  89199. * Dumps the current bound framebuffer
  89200. * @param width defines the rendering width
  89201. * @param height defines the rendering height
  89202. * @param engine defines the hosting engine
  89203. * @param successCallback defines the callback triggered once the data are available
  89204. * @param mimeType defines the mime type of the result
  89205. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  89206. */
  89207. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89208. /**
  89209. * Converts the canvas data to blob.
  89210. * This acts as a polyfill for browsers not supporting the to blob function.
  89211. * @param canvas Defines the canvas to extract the data from
  89212. * @param successCallback Defines the callback triggered once the data are available
  89213. * @param mimeType Defines the mime type of the result
  89214. */
  89215. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  89216. /**
  89217. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  89218. * @param successCallback defines the callback triggered once the data are available
  89219. * @param mimeType defines the mime type of the result
  89220. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  89221. */
  89222. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89223. /**
  89224. * Downloads a blob in the browser
  89225. * @param blob defines the blob to download
  89226. * @param fileName defines the name of the downloaded file
  89227. */
  89228. static Download(blob: Blob, fileName: string): void;
  89229. /**
  89230. * Captures a screenshot of the current rendering
  89231. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89232. * @param engine defines the rendering engine
  89233. * @param camera defines the source camera
  89234. * @param size This parameter can be set to a single number or to an object with the
  89235. * following (optional) properties: precision, width, height. If a single number is passed,
  89236. * it will be used for both width and height. If an object is passed, the screenshot size
  89237. * will be derived from the parameters. The precision property is a multiplier allowing
  89238. * rendering at a higher or lower resolution
  89239. * @param successCallback defines the callback receives a single parameter which contains the
  89240. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89241. * src parameter of an <img> to display it
  89242. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  89243. * Check your browser for supported MIME types
  89244. */
  89245. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  89246. /**
  89247. * Generates an image screenshot from the specified camera.
  89248. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89249. * @param engine The engine to use for rendering
  89250. * @param camera The camera to use for rendering
  89251. * @param size This parameter can be set to a single number or to an object with the
  89252. * following (optional) properties: precision, width, height. If a single number is passed,
  89253. * it will be used for both width and height. If an object is passed, the screenshot size
  89254. * will be derived from the parameters. The precision property is a multiplier allowing
  89255. * rendering at a higher or lower resolution
  89256. * @param successCallback The callback receives a single parameter which contains the
  89257. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89258. * src parameter of an <img> to display it
  89259. * @param mimeType The MIME type of the screenshot image (default: image/png).
  89260. * Check your browser for supported MIME types
  89261. * @param samples Texture samples (default: 1)
  89262. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  89263. * @param fileName A name for for the downloaded file.
  89264. */
  89265. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  89266. /**
  89267. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89268. * Be aware Math.random() could cause collisions, but:
  89269. * "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"
  89270. * @returns a pseudo random id
  89271. */
  89272. static RandomId(): string;
  89273. /**
  89274. * Test if the given uri is a base64 string
  89275. * @param uri The uri to test
  89276. * @return True if the uri is a base64 string or false otherwise
  89277. */
  89278. static IsBase64(uri: string): boolean;
  89279. /**
  89280. * Decode the given base64 uri.
  89281. * @param uri The uri to decode
  89282. * @return The decoded base64 data.
  89283. */
  89284. static DecodeBase64(uri: string): ArrayBuffer;
  89285. /**
  89286. * No log
  89287. */
  89288. static readonly NoneLogLevel: number;
  89289. /**
  89290. * Only message logs
  89291. */
  89292. static readonly MessageLogLevel: number;
  89293. /**
  89294. * Only warning logs
  89295. */
  89296. static readonly WarningLogLevel: number;
  89297. /**
  89298. * Only error logs
  89299. */
  89300. static readonly ErrorLogLevel: number;
  89301. /**
  89302. * All logs
  89303. */
  89304. static readonly AllLogLevel: number;
  89305. /**
  89306. * Gets a value indicating the number of loading errors
  89307. * @ignorenaming
  89308. */
  89309. static readonly errorsCount: number;
  89310. /**
  89311. * Callback called when a new log is added
  89312. */
  89313. static OnNewCacheEntry: (entry: string) => void;
  89314. /**
  89315. * Log a message to the console
  89316. * @param message defines the message to log
  89317. */
  89318. static Log(message: string): void;
  89319. /**
  89320. * Write a warning message to the console
  89321. * @param message defines the message to log
  89322. */
  89323. static Warn(message: string): void;
  89324. /**
  89325. * Write an error message to the console
  89326. * @param message defines the message to log
  89327. */
  89328. static Error(message: string): void;
  89329. /**
  89330. * Gets current log cache (list of logs)
  89331. */
  89332. static readonly LogCache: string;
  89333. /**
  89334. * Clears the log cache
  89335. */
  89336. static ClearLogCache(): void;
  89337. /**
  89338. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  89339. */
  89340. static LogLevels: number;
  89341. /**
  89342. * Checks if the loaded document was accessed via `file:`-Protocol.
  89343. * @returns boolean
  89344. */
  89345. static IsFileURL(): boolean;
  89346. /**
  89347. * Checks if the window object exists
  89348. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  89349. */
  89350. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  89351. /**
  89352. * No performance log
  89353. */
  89354. static readonly PerformanceNoneLogLevel: number;
  89355. /**
  89356. * Use user marks to log performance
  89357. */
  89358. static readonly PerformanceUserMarkLogLevel: number;
  89359. /**
  89360. * Log performance to the console
  89361. */
  89362. static readonly PerformanceConsoleLogLevel: number;
  89363. private static _performance;
  89364. /**
  89365. * Sets the current performance log level
  89366. */
  89367. static PerformanceLogLevel: number;
  89368. private static _StartPerformanceCounterDisabled;
  89369. private static _EndPerformanceCounterDisabled;
  89370. private static _StartUserMark;
  89371. private static _EndUserMark;
  89372. private static _StartPerformanceConsole;
  89373. private static _EndPerformanceConsole;
  89374. /**
  89375. * Starts a performance counter
  89376. */
  89377. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89378. /**
  89379. * Ends a specific performance coutner
  89380. */
  89381. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89382. /**
  89383. * Gets either window.performance.now() if supported or Date.now() else
  89384. */
  89385. static readonly Now: number;
  89386. /**
  89387. * This method will return the name of the class used to create the instance of the given object.
  89388. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  89389. * @param object the object to get the class name from
  89390. * @param isType defines if the object is actually a type
  89391. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  89392. */
  89393. static GetClassName(object: any, isType?: boolean): string;
  89394. /**
  89395. * Gets the first element of an array satisfying a given predicate
  89396. * @param array defines the array to browse
  89397. * @param predicate defines the predicate to use
  89398. * @returns null if not found or the element
  89399. */
  89400. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  89401. /**
  89402. * This method will return the name of the full name of the class, including its owning module (if any).
  89403. * 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).
  89404. * @param object the object to get the class name from
  89405. * @param isType defines if the object is actually a type
  89406. * @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.
  89407. * @ignorenaming
  89408. */
  89409. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  89410. /**
  89411. * Returns a promise that resolves after the given amount of time.
  89412. * @param delay Number of milliseconds to delay
  89413. * @returns Promise that resolves after the given amount of time
  89414. */
  89415. static DelayAsync(delay: number): Promise<void>;
  89416. /**
  89417. * Gets the current gradient from an array of IValueGradient
  89418. * @param ratio defines the current ratio to get
  89419. * @param gradients defines the array of IValueGradient
  89420. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89421. */
  89422. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89423. }
  89424. /**
  89425. * This class is used to track a performance counter which is number based.
  89426. * The user has access to many properties which give statistics of different nature.
  89427. *
  89428. * The implementer can track two kinds of Performance Counter: time and count.
  89429. * 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.
  89430. * 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.
  89431. */
  89432. export class PerfCounter {
  89433. /**
  89434. * Gets or sets a global boolean to turn on and off all the counters
  89435. */
  89436. static Enabled: boolean;
  89437. /**
  89438. * Returns the smallest value ever
  89439. */
  89440. readonly min: number;
  89441. /**
  89442. * Returns the biggest value ever
  89443. */
  89444. readonly max: number;
  89445. /**
  89446. * Returns the average value since the performance counter is running
  89447. */
  89448. readonly average: number;
  89449. /**
  89450. * Returns the average value of the last second the counter was monitored
  89451. */
  89452. readonly lastSecAverage: number;
  89453. /**
  89454. * Returns the current value
  89455. */
  89456. readonly current: number;
  89457. /**
  89458. * Gets the accumulated total
  89459. */
  89460. readonly total: number;
  89461. /**
  89462. * Gets the total value count
  89463. */
  89464. readonly count: number;
  89465. /**
  89466. * Creates a new counter
  89467. */
  89468. constructor();
  89469. /**
  89470. * Call this method to start monitoring a new frame.
  89471. * 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.
  89472. */
  89473. fetchNewFrame(): void;
  89474. /**
  89475. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  89476. * @param newCount the count value to add to the monitored count
  89477. * @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.
  89478. */
  89479. addCount(newCount: number, fetchResult: boolean): void;
  89480. /**
  89481. * Start monitoring this performance counter
  89482. */
  89483. beginMonitoring(): void;
  89484. /**
  89485. * Compute the time lapsed since the previous beginMonitoring() call.
  89486. * @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
  89487. */
  89488. endMonitoring(newFrame?: boolean): void;
  89489. private _fetchResult;
  89490. private _startMonitoringTime;
  89491. private _min;
  89492. private _max;
  89493. private _average;
  89494. private _current;
  89495. private _totalValueCount;
  89496. private _totalAccumulated;
  89497. private _lastSecAverage;
  89498. private _lastSecAccumulated;
  89499. private _lastSecTime;
  89500. private _lastSecValueCount;
  89501. }
  89502. /**
  89503. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  89504. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  89505. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  89506. * @param name The name of the class, case should be preserved
  89507. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  89508. */
  89509. export function className(name: string, module?: string): (target: Object) => void;
  89510. /**
  89511. * An implementation of a loop for asynchronous functions.
  89512. */
  89513. export class AsyncLoop {
  89514. /**
  89515. * Defines the number of iterations for the loop
  89516. */
  89517. iterations: number;
  89518. /**
  89519. * Defines the current index of the loop.
  89520. */
  89521. index: number;
  89522. private _done;
  89523. private _fn;
  89524. private _successCallback;
  89525. /**
  89526. * Constructor.
  89527. * @param iterations the number of iterations.
  89528. * @param func the function to run each iteration
  89529. * @param successCallback the callback that will be called upon succesful execution
  89530. * @param offset starting offset.
  89531. */
  89532. constructor(
  89533. /**
  89534. * Defines the number of iterations for the loop
  89535. */
  89536. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  89537. /**
  89538. * Execute the next iteration. Must be called after the last iteration was finished.
  89539. */
  89540. executeNext(): void;
  89541. /**
  89542. * Break the loop and run the success callback.
  89543. */
  89544. breakLoop(): void;
  89545. /**
  89546. * Create and run an async loop.
  89547. * @param iterations the number of iterations.
  89548. * @param fn the function to run each iteration
  89549. * @param successCallback the callback that will be called upon succesful execution
  89550. * @param offset starting offset.
  89551. * @returns the created async loop object
  89552. */
  89553. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  89554. /**
  89555. * A for-loop that will run a given number of iterations synchronous and the rest async.
  89556. * @param iterations total number of iterations
  89557. * @param syncedIterations number of synchronous iterations in each async iteration.
  89558. * @param fn the function to call each iteration.
  89559. * @param callback a success call back that will be called when iterating stops.
  89560. * @param breakFunction a break condition (optional)
  89561. * @param timeout timeout settings for the setTimeout function. default - 0.
  89562. * @returns the created async loop object
  89563. */
  89564. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  89565. }
  89566. }
  89567. declare module BABYLON {
  89568. /** @hidden */
  89569. export interface ICollisionCoordinator {
  89570. createCollider(): Collider;
  89571. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89572. init(scene: Scene): void;
  89573. }
  89574. /** @hidden */
  89575. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  89576. private _scene;
  89577. private _scaledPosition;
  89578. private _scaledVelocity;
  89579. private _finalPosition;
  89580. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89581. createCollider(): Collider;
  89582. init(scene: Scene): void;
  89583. private _collideWithWorld;
  89584. }
  89585. }
  89586. declare module BABYLON {
  89587. /**
  89588. * This class defines the direct association between an animation and a target
  89589. */
  89590. export class TargetedAnimation {
  89591. /**
  89592. * Animation to perform
  89593. */
  89594. animation: Animation;
  89595. /**
  89596. * Target to animate
  89597. */
  89598. target: any;
  89599. }
  89600. /**
  89601. * Use this class to create coordinated animations on multiple targets
  89602. */
  89603. export class AnimationGroup implements IDisposable {
  89604. /** The name of the animation group */
  89605. name: string;
  89606. private _scene;
  89607. private _targetedAnimations;
  89608. private _animatables;
  89609. private _from;
  89610. private _to;
  89611. private _isStarted;
  89612. private _isPaused;
  89613. private _speedRatio;
  89614. /**
  89615. * Gets or sets the unique id of the node
  89616. */
  89617. uniqueId: number;
  89618. /**
  89619. * This observable will notify when one animation have ended
  89620. */
  89621. onAnimationEndObservable: Observable<TargetedAnimation>;
  89622. /**
  89623. * Observer raised when one animation loops
  89624. */
  89625. onAnimationLoopObservable: Observable<TargetedAnimation>;
  89626. /**
  89627. * This observable will notify when all animations have ended.
  89628. */
  89629. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  89630. /**
  89631. * This observable will notify when all animations have paused.
  89632. */
  89633. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  89634. /**
  89635. * This observable will notify when all animations are playing.
  89636. */
  89637. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  89638. /**
  89639. * Gets the first frame
  89640. */
  89641. readonly from: number;
  89642. /**
  89643. * Gets the last frame
  89644. */
  89645. readonly to: number;
  89646. /**
  89647. * Define if the animations are started
  89648. */
  89649. readonly isStarted: boolean;
  89650. /**
  89651. * Gets a value indicating that the current group is playing
  89652. */
  89653. readonly isPlaying: boolean;
  89654. /**
  89655. * Gets or sets the speed ratio to use for all animations
  89656. */
  89657. /**
  89658. * Gets or sets the speed ratio to use for all animations
  89659. */
  89660. speedRatio: number;
  89661. /**
  89662. * Gets the targeted animations for this animation group
  89663. */
  89664. readonly targetedAnimations: Array<TargetedAnimation>;
  89665. /**
  89666. * returning the list of animatables controlled by this animation group.
  89667. */
  89668. readonly animatables: Array<Animatable>;
  89669. /**
  89670. * Instantiates a new Animation Group.
  89671. * This helps managing several animations at once.
  89672. * @see http://doc.babylonjs.com/how_to/group
  89673. * @param name Defines the name of the group
  89674. * @param scene Defines the scene the group belongs to
  89675. */
  89676. constructor(
  89677. /** The name of the animation group */
  89678. name: string, scene?: Nullable<Scene>);
  89679. /**
  89680. * Add an animation (with its target) in the group
  89681. * @param animation defines the animation we want to add
  89682. * @param target defines the target of the animation
  89683. * @returns the TargetedAnimation object
  89684. */
  89685. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  89686. /**
  89687. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  89688. * It can add constant keys at begin or end
  89689. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  89690. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  89691. * @returns the animation group
  89692. */
  89693. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  89694. /**
  89695. * Start all animations on given targets
  89696. * @param loop defines if animations must loop
  89697. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  89698. * @param from defines the from key (optional)
  89699. * @param to defines the to key (optional)
  89700. * @returns the current animation group
  89701. */
  89702. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  89703. /**
  89704. * Pause all animations
  89705. * @returns the animation group
  89706. */
  89707. pause(): AnimationGroup;
  89708. /**
  89709. * Play all animations to initial state
  89710. * This function will start() the animations if they were not started or will restart() them if they were paused
  89711. * @param loop defines if animations must loop
  89712. * @returns the animation group
  89713. */
  89714. play(loop?: boolean): AnimationGroup;
  89715. /**
  89716. * Reset all animations to initial state
  89717. * @returns the animation group
  89718. */
  89719. reset(): AnimationGroup;
  89720. /**
  89721. * Restart animations from key 0
  89722. * @returns the animation group
  89723. */
  89724. restart(): AnimationGroup;
  89725. /**
  89726. * Stop all animations
  89727. * @returns the animation group
  89728. */
  89729. stop(): AnimationGroup;
  89730. /**
  89731. * Set animation weight for all animatables
  89732. * @param weight defines the weight to use
  89733. * @return the animationGroup
  89734. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89735. */
  89736. setWeightForAllAnimatables(weight: number): AnimationGroup;
  89737. /**
  89738. * Synchronize and normalize all animatables with a source animatable
  89739. * @param root defines the root animatable to synchronize with
  89740. * @return the animationGroup
  89741. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89742. */
  89743. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  89744. /**
  89745. * Goes to a specific frame in this animation group
  89746. * @param frame the frame number to go to
  89747. * @return the animationGroup
  89748. */
  89749. goToFrame(frame: number): AnimationGroup;
  89750. /**
  89751. * Dispose all associated resources
  89752. */
  89753. dispose(): void;
  89754. private _checkAnimationGroupEnded;
  89755. /**
  89756. * Clone the current animation group and returns a copy
  89757. * @param newName defines the name of the new group
  89758. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  89759. * @returns the new aniamtion group
  89760. */
  89761. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  89762. /**
  89763. * Returns a new AnimationGroup object parsed from the source provided.
  89764. * @param parsedAnimationGroup defines the source
  89765. * @param scene defines the scene that will receive the animationGroup
  89766. * @returns a new AnimationGroup
  89767. */
  89768. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  89769. /**
  89770. * Returns the string "AnimationGroup"
  89771. * @returns "AnimationGroup"
  89772. */
  89773. getClassName(): string;
  89774. /**
  89775. * Creates a detailled string about the object
  89776. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  89777. * @returns a string representing the object
  89778. */
  89779. toString(fullDetails?: boolean): string;
  89780. }
  89781. }
  89782. declare module BABYLON {
  89783. /**
  89784. * Define an interface for all classes that will hold resources
  89785. */
  89786. export interface IDisposable {
  89787. /**
  89788. * Releases all held resources
  89789. */
  89790. dispose(): void;
  89791. }
  89792. /** Interface defining initialization parameters for Scene class */
  89793. export interface SceneOptions {
  89794. /**
  89795. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  89796. * It will improve performance when the number of geometries becomes important.
  89797. */
  89798. useGeometryUniqueIdsMap?: boolean;
  89799. /**
  89800. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  89801. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89802. */
  89803. useMaterialMeshMap?: boolean;
  89804. /**
  89805. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  89806. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89807. */
  89808. useClonedMeshhMap?: boolean;
  89809. }
  89810. /**
  89811. * Represents a scene to be rendered by the engine.
  89812. * @see http://doc.babylonjs.com/features/scene
  89813. */
  89814. export class Scene extends AbstractScene implements IAnimatable {
  89815. private static _uniqueIdCounter;
  89816. /** The fog is deactivated */
  89817. static readonly FOGMODE_NONE: number;
  89818. /** The fog density is following an exponential function */
  89819. static readonly FOGMODE_EXP: number;
  89820. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  89821. static readonly FOGMODE_EXP2: number;
  89822. /** The fog density is following a linear function. */
  89823. static readonly FOGMODE_LINEAR: number;
  89824. /**
  89825. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  89826. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89827. */
  89828. static MinDeltaTime: number;
  89829. /**
  89830. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  89831. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89832. */
  89833. static MaxDeltaTime: number;
  89834. /**
  89835. * Factory used to create the default material.
  89836. * @param name The name of the material to create
  89837. * @param scene The scene to create the material for
  89838. * @returns The default material
  89839. */
  89840. static DefaultMaterialFactory(scene: Scene): Material;
  89841. /**
  89842. * Factory used to create the a collision coordinator.
  89843. * @returns The collision coordinator
  89844. */
  89845. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  89846. /** @hidden */
  89847. readonly _isScene: boolean;
  89848. /**
  89849. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  89850. */
  89851. autoClear: boolean;
  89852. /**
  89853. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  89854. */
  89855. autoClearDepthAndStencil: boolean;
  89856. /**
  89857. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  89858. */
  89859. clearColor: Color4;
  89860. /**
  89861. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  89862. */
  89863. ambientColor: Color3;
  89864. /** @hidden */
  89865. _environmentBRDFTexture: BaseTexture;
  89866. /** @hidden */
  89867. protected _environmentTexture: Nullable<BaseTexture>;
  89868. /**
  89869. * Texture used in all pbr material as the reflection texture.
  89870. * As in the majority of the scene they are the same (exception for multi room and so on),
  89871. * this is easier to reference from here than from all the materials.
  89872. */
  89873. /**
  89874. * Texture used in all pbr material as the reflection texture.
  89875. * As in the majority of the scene they are the same (exception for multi room and so on),
  89876. * this is easier to set here than in all the materials.
  89877. */
  89878. environmentTexture: Nullable<BaseTexture>;
  89879. /** @hidden */
  89880. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89881. /**
  89882. * Default image processing configuration used either in the rendering
  89883. * Forward main pass or through the imageProcessingPostProcess if present.
  89884. * As in the majority of the scene they are the same (exception for multi camera),
  89885. * this is easier to reference from here than from all the materials and post process.
  89886. *
  89887. * No setter as we it is a shared configuration, you can set the values instead.
  89888. */
  89889. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  89890. private _forceWireframe;
  89891. /**
  89892. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  89893. */
  89894. forceWireframe: boolean;
  89895. private _forcePointsCloud;
  89896. /**
  89897. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  89898. */
  89899. forcePointsCloud: boolean;
  89900. /**
  89901. * Gets or sets the active clipplane 1
  89902. */
  89903. clipPlane: Nullable<Plane>;
  89904. /**
  89905. * Gets or sets the active clipplane 2
  89906. */
  89907. clipPlane2: Nullable<Plane>;
  89908. /**
  89909. * Gets or sets the active clipplane 3
  89910. */
  89911. clipPlane3: Nullable<Plane>;
  89912. /**
  89913. * Gets or sets the active clipplane 4
  89914. */
  89915. clipPlane4: Nullable<Plane>;
  89916. /**
  89917. * Gets or sets a boolean indicating if animations are enabled
  89918. */
  89919. animationsEnabled: boolean;
  89920. private _animationPropertiesOverride;
  89921. /**
  89922. * Gets or sets the animation properties override
  89923. */
  89924. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89925. /**
  89926. * Gets or sets a boolean indicating if a constant deltatime has to be used
  89927. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  89928. */
  89929. useConstantAnimationDeltaTime: boolean;
  89930. /**
  89931. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  89932. * Please note that it requires to run a ray cast through the scene on every frame
  89933. */
  89934. constantlyUpdateMeshUnderPointer: boolean;
  89935. /**
  89936. * Defines the HTML cursor to use when hovering over interactive elements
  89937. */
  89938. hoverCursor: string;
  89939. /**
  89940. * Defines the HTML default cursor to use (empty by default)
  89941. */
  89942. defaultCursor: string;
  89943. /**
  89944. * This is used to call preventDefault() on pointer down
  89945. * in order to block unwanted artifacts like system double clicks
  89946. */
  89947. preventDefaultOnPointerDown: boolean;
  89948. /**
  89949. * This is used to call preventDefault() on pointer up
  89950. * in order to block unwanted artifacts like system double clicks
  89951. */
  89952. preventDefaultOnPointerUp: boolean;
  89953. /**
  89954. * Gets or sets user defined metadata
  89955. */
  89956. metadata: any;
  89957. /**
  89958. * For internal use only. Please do not use.
  89959. */
  89960. reservedDataStore: any;
  89961. /**
  89962. * Gets the name of the plugin used to load this scene (null by default)
  89963. */
  89964. loadingPluginName: string;
  89965. /**
  89966. * Use this array to add regular expressions used to disable offline support for specific urls
  89967. */
  89968. disableOfflineSupportExceptionRules: RegExp[];
  89969. /**
  89970. * An event triggered when the scene is disposed.
  89971. */
  89972. onDisposeObservable: Observable<Scene>;
  89973. private _onDisposeObserver;
  89974. /** Sets a function to be executed when this scene is disposed. */
  89975. onDispose: () => void;
  89976. /**
  89977. * An event triggered before rendering the scene (right after animations and physics)
  89978. */
  89979. onBeforeRenderObservable: Observable<Scene>;
  89980. private _onBeforeRenderObserver;
  89981. /** Sets a function to be executed before rendering this scene */
  89982. beforeRender: Nullable<() => void>;
  89983. /**
  89984. * An event triggered after rendering the scene
  89985. */
  89986. onAfterRenderObservable: Observable<Scene>;
  89987. private _onAfterRenderObserver;
  89988. /** Sets a function to be executed after rendering this scene */
  89989. afterRender: Nullable<() => void>;
  89990. /**
  89991. * An event triggered before animating the scene
  89992. */
  89993. onBeforeAnimationsObservable: Observable<Scene>;
  89994. /**
  89995. * An event triggered after animations processing
  89996. */
  89997. onAfterAnimationsObservable: Observable<Scene>;
  89998. /**
  89999. * An event triggered before draw calls are ready to be sent
  90000. */
  90001. onBeforeDrawPhaseObservable: Observable<Scene>;
  90002. /**
  90003. * An event triggered after draw calls have been sent
  90004. */
  90005. onAfterDrawPhaseObservable: Observable<Scene>;
  90006. /**
  90007. * An event triggered when the scene is ready
  90008. */
  90009. onReadyObservable: Observable<Scene>;
  90010. /**
  90011. * An event triggered before rendering a camera
  90012. */
  90013. onBeforeCameraRenderObservable: Observable<Camera>;
  90014. private _onBeforeCameraRenderObserver;
  90015. /** Sets a function to be executed before rendering a camera*/
  90016. beforeCameraRender: () => void;
  90017. /**
  90018. * An event triggered after rendering a camera
  90019. */
  90020. onAfterCameraRenderObservable: Observable<Camera>;
  90021. private _onAfterCameraRenderObserver;
  90022. /** Sets a function to be executed after rendering a camera*/
  90023. afterCameraRender: () => void;
  90024. /**
  90025. * An event triggered when active meshes evaluation is about to start
  90026. */
  90027. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  90028. /**
  90029. * An event triggered when active meshes evaluation is done
  90030. */
  90031. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  90032. /**
  90033. * An event triggered when particles rendering is about to start
  90034. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90035. */
  90036. onBeforeParticlesRenderingObservable: Observable<Scene>;
  90037. /**
  90038. * An event triggered when particles rendering is done
  90039. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90040. */
  90041. onAfterParticlesRenderingObservable: Observable<Scene>;
  90042. /**
  90043. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  90044. */
  90045. onDataLoadedObservable: Observable<Scene>;
  90046. /**
  90047. * An event triggered when a camera is created
  90048. */
  90049. onNewCameraAddedObservable: Observable<Camera>;
  90050. /**
  90051. * An event triggered when a camera is removed
  90052. */
  90053. onCameraRemovedObservable: Observable<Camera>;
  90054. /**
  90055. * An event triggered when a light is created
  90056. */
  90057. onNewLightAddedObservable: Observable<Light>;
  90058. /**
  90059. * An event triggered when a light is removed
  90060. */
  90061. onLightRemovedObservable: Observable<Light>;
  90062. /**
  90063. * An event triggered when a geometry is created
  90064. */
  90065. onNewGeometryAddedObservable: Observable<Geometry>;
  90066. /**
  90067. * An event triggered when a geometry is removed
  90068. */
  90069. onGeometryRemovedObservable: Observable<Geometry>;
  90070. /**
  90071. * An event triggered when a transform node is created
  90072. */
  90073. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  90074. /**
  90075. * An event triggered when a transform node is removed
  90076. */
  90077. onTransformNodeRemovedObservable: Observable<TransformNode>;
  90078. /**
  90079. * An event triggered when a mesh is created
  90080. */
  90081. onNewMeshAddedObservable: Observable<AbstractMesh>;
  90082. /**
  90083. * An event triggered when a mesh is removed
  90084. */
  90085. onMeshRemovedObservable: Observable<AbstractMesh>;
  90086. /**
  90087. * An event triggered when a skeleton is created
  90088. */
  90089. onNewSkeletonAddedObservable: Observable<Skeleton>;
  90090. /**
  90091. * An event triggered when a skeleton is removed
  90092. */
  90093. onSkeletonRemovedObservable: Observable<Skeleton>;
  90094. /**
  90095. * An event triggered when a material is created
  90096. */
  90097. onNewMaterialAddedObservable: Observable<Material>;
  90098. /**
  90099. * An event triggered when a material is removed
  90100. */
  90101. onMaterialRemovedObservable: Observable<Material>;
  90102. /**
  90103. * An event triggered when a texture is created
  90104. */
  90105. onNewTextureAddedObservable: Observable<BaseTexture>;
  90106. /**
  90107. * An event triggered when a texture is removed
  90108. */
  90109. onTextureRemovedObservable: Observable<BaseTexture>;
  90110. /**
  90111. * An event triggered when render targets are about to be rendered
  90112. * Can happen multiple times per frame.
  90113. */
  90114. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  90115. /**
  90116. * An event triggered when render targets were rendered.
  90117. * Can happen multiple times per frame.
  90118. */
  90119. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  90120. /**
  90121. * An event triggered before calculating deterministic simulation step
  90122. */
  90123. onBeforeStepObservable: Observable<Scene>;
  90124. /**
  90125. * An event triggered after calculating deterministic simulation step
  90126. */
  90127. onAfterStepObservable: Observable<Scene>;
  90128. /**
  90129. * An event triggered when the activeCamera property is updated
  90130. */
  90131. onActiveCameraChanged: Observable<Scene>;
  90132. /**
  90133. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  90134. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90135. * 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)
  90136. */
  90137. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90138. /**
  90139. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  90140. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90141. * 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)
  90142. */
  90143. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90144. /**
  90145. * This Observable will when a mesh has been imported into the scene.
  90146. */
  90147. onMeshImportedObservable: Observable<AbstractMesh>;
  90148. /**
  90149. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  90150. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  90151. */
  90152. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  90153. /** @hidden */
  90154. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  90155. /**
  90156. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  90157. */
  90158. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  90159. /**
  90160. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  90161. */
  90162. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  90163. /**
  90164. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  90165. */
  90166. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  90167. private _onPointerMove;
  90168. private _onPointerDown;
  90169. private _onPointerUp;
  90170. /** Callback called when a pointer move is detected */
  90171. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90172. /** Callback called when a pointer down is detected */
  90173. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90174. /** Callback called when a pointer up is detected */
  90175. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  90176. /** Callback called when a pointer pick is detected */
  90177. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  90178. /**
  90179. * 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).
  90180. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  90181. */
  90182. onPrePointerObservable: Observable<PointerInfoPre>;
  90183. /**
  90184. * Observable event triggered each time an input event is received from the rendering canvas
  90185. */
  90186. onPointerObservable: Observable<PointerInfo>;
  90187. /**
  90188. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  90189. */
  90190. readonly unTranslatedPointer: Vector2;
  90191. /** The distance in pixel that you have to move to prevent some events */
  90192. static DragMovementThreshold: number;
  90193. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  90194. static LongPressDelay: number;
  90195. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  90196. static DoubleClickDelay: number;
  90197. /** If you need to check double click without raising a single click at first click, enable this flag */
  90198. static ExclusiveDoubleClickMode: boolean;
  90199. private _initClickEvent;
  90200. private _initActionManager;
  90201. private _delayedSimpleClick;
  90202. private _delayedSimpleClickTimeout;
  90203. private _previousDelayedSimpleClickTimeout;
  90204. private _meshPickProceed;
  90205. private _previousButtonPressed;
  90206. private _currentPickResult;
  90207. private _previousPickResult;
  90208. private _totalPointersPressed;
  90209. private _doubleClickOccured;
  90210. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  90211. cameraToUseForPointers: Nullable<Camera>;
  90212. private _pointerX;
  90213. private _pointerY;
  90214. private _unTranslatedPointerX;
  90215. private _unTranslatedPointerY;
  90216. private _startingPointerPosition;
  90217. private _previousStartingPointerPosition;
  90218. private _startingPointerTime;
  90219. private _previousStartingPointerTime;
  90220. private _pointerCaptures;
  90221. private _timeAccumulator;
  90222. private _currentStepId;
  90223. private _currentInternalStep;
  90224. /** @hidden */
  90225. _mirroredCameraPosition: Nullable<Vector3>;
  90226. /**
  90227. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  90228. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  90229. */
  90230. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  90231. /**
  90232. * Observable event triggered each time an keyboard event is received from the hosting window
  90233. */
  90234. onKeyboardObservable: Observable<KeyboardInfo>;
  90235. private _onKeyDown;
  90236. private _onKeyUp;
  90237. private _onCanvasFocusObserver;
  90238. private _onCanvasBlurObserver;
  90239. private _useRightHandedSystem;
  90240. /**
  90241. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  90242. */
  90243. useRightHandedSystem: boolean;
  90244. /**
  90245. * Sets the step Id used by deterministic lock step
  90246. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90247. * @param newStepId defines the step Id
  90248. */
  90249. setStepId(newStepId: number): void;
  90250. /**
  90251. * Gets the step Id used by deterministic lock step
  90252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90253. * @returns the step Id
  90254. */
  90255. getStepId(): number;
  90256. /**
  90257. * Gets the internal step used by deterministic lock step
  90258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90259. * @returns the internal step
  90260. */
  90261. getInternalStep(): number;
  90262. private _fogEnabled;
  90263. /**
  90264. * Gets or sets a boolean indicating if fog is enabled on this scene
  90265. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90266. * (Default is true)
  90267. */
  90268. fogEnabled: boolean;
  90269. private _fogMode;
  90270. /**
  90271. * Gets or sets the fog mode to use
  90272. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90273. * | mode | value |
  90274. * | --- | --- |
  90275. * | FOGMODE_NONE | 0 |
  90276. * | FOGMODE_EXP | 1 |
  90277. * | FOGMODE_EXP2 | 2 |
  90278. * | FOGMODE_LINEAR | 3 |
  90279. */
  90280. fogMode: number;
  90281. /**
  90282. * Gets or sets the fog color to use
  90283. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90284. * (Default is Color3(0.2, 0.2, 0.3))
  90285. */
  90286. fogColor: Color3;
  90287. /**
  90288. * Gets or sets the fog density to use
  90289. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90290. * (Default is 0.1)
  90291. */
  90292. fogDensity: number;
  90293. /**
  90294. * Gets or sets the fog start distance to use
  90295. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90296. * (Default is 0)
  90297. */
  90298. fogStart: number;
  90299. /**
  90300. * Gets or sets the fog end distance to use
  90301. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90302. * (Default is 1000)
  90303. */
  90304. fogEnd: number;
  90305. private _shadowsEnabled;
  90306. /**
  90307. * Gets or sets a boolean indicating if shadows are enabled on this scene
  90308. */
  90309. shadowsEnabled: boolean;
  90310. private _lightsEnabled;
  90311. /**
  90312. * Gets or sets a boolean indicating if lights are enabled on this scene
  90313. */
  90314. lightsEnabled: boolean;
  90315. /** All of the active cameras added to this scene. */
  90316. activeCameras: Camera[];
  90317. private _activeCamera;
  90318. /** Gets or sets the current active camera */
  90319. activeCamera: Nullable<Camera>;
  90320. private _defaultMaterial;
  90321. /** The default material used on meshes when no material is affected */
  90322. /** The default material used on meshes when no material is affected */
  90323. defaultMaterial: Material;
  90324. private _texturesEnabled;
  90325. /**
  90326. * Gets or sets a boolean indicating if textures are enabled on this scene
  90327. */
  90328. texturesEnabled: boolean;
  90329. /**
  90330. * Gets or sets a boolean indicating if particles are enabled on this scene
  90331. */
  90332. particlesEnabled: boolean;
  90333. /**
  90334. * Gets or sets a boolean indicating if sprites are enabled on this scene
  90335. */
  90336. spritesEnabled: boolean;
  90337. private _skeletonsEnabled;
  90338. /**
  90339. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  90340. */
  90341. skeletonsEnabled: boolean;
  90342. /**
  90343. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  90344. */
  90345. lensFlaresEnabled: boolean;
  90346. /**
  90347. * Gets or sets a boolean indicating if collisions are enabled on this scene
  90348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90349. */
  90350. collisionsEnabled: boolean;
  90351. private _collisionCoordinator;
  90352. /** @hidden */
  90353. readonly collisionCoordinator: ICollisionCoordinator;
  90354. /**
  90355. * Defines the gravity applied to this scene (used only for collisions)
  90356. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90357. */
  90358. gravity: Vector3;
  90359. /**
  90360. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  90361. */
  90362. postProcessesEnabled: boolean;
  90363. /**
  90364. * The list of postprocesses added to the scene
  90365. */
  90366. postProcesses: PostProcess[];
  90367. /**
  90368. * Gets the current postprocess manager
  90369. */
  90370. postProcessManager: PostProcessManager;
  90371. /**
  90372. * Gets or sets a boolean indicating if render targets are enabled on this scene
  90373. */
  90374. renderTargetsEnabled: boolean;
  90375. /**
  90376. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  90377. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  90378. */
  90379. dumpNextRenderTargets: boolean;
  90380. /**
  90381. * The list of user defined render targets added to the scene
  90382. */
  90383. customRenderTargets: RenderTargetTexture[];
  90384. /**
  90385. * Defines if texture loading must be delayed
  90386. * If true, textures will only be loaded when they need to be rendered
  90387. */
  90388. useDelayedTextureLoading: boolean;
  90389. /**
  90390. * Gets the list of meshes imported to the scene through SceneLoader
  90391. */
  90392. importedMeshesFiles: String[];
  90393. /**
  90394. * Gets or sets a boolean indicating if probes are enabled on this scene
  90395. */
  90396. probesEnabled: boolean;
  90397. /**
  90398. * Gets or sets the current offline provider to use to store scene data
  90399. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  90400. */
  90401. offlineProvider: IOfflineProvider;
  90402. /**
  90403. * Gets or sets the action manager associated with the scene
  90404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90405. */
  90406. actionManager: AbstractActionManager;
  90407. private _meshesForIntersections;
  90408. /**
  90409. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  90410. */
  90411. proceduralTexturesEnabled: boolean;
  90412. private _engine;
  90413. private _totalVertices;
  90414. /** @hidden */
  90415. _activeIndices: PerfCounter;
  90416. /** @hidden */
  90417. _activeParticles: PerfCounter;
  90418. /** @hidden */
  90419. _activeBones: PerfCounter;
  90420. private _animationRatio;
  90421. /** @hidden */
  90422. _animationTimeLast: number;
  90423. /** @hidden */
  90424. _animationTime: number;
  90425. /**
  90426. * Gets or sets a general scale for animation speed
  90427. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  90428. */
  90429. animationTimeScale: number;
  90430. /** @hidden */
  90431. _cachedMaterial: Nullable<Material>;
  90432. /** @hidden */
  90433. _cachedEffect: Nullable<Effect>;
  90434. /** @hidden */
  90435. _cachedVisibility: Nullable<number>;
  90436. private _renderId;
  90437. private _frameId;
  90438. private _executeWhenReadyTimeoutId;
  90439. private _intermediateRendering;
  90440. private _viewUpdateFlag;
  90441. private _projectionUpdateFlag;
  90442. private _alternateViewUpdateFlag;
  90443. private _alternateProjectionUpdateFlag;
  90444. /** @hidden */
  90445. _toBeDisposed: Nullable<IDisposable>[];
  90446. private _activeRequests;
  90447. /** @hidden */
  90448. _pendingData: any[];
  90449. private _isDisposed;
  90450. /**
  90451. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  90452. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  90453. */
  90454. dispatchAllSubMeshesOfActiveMeshes: boolean;
  90455. private _activeMeshes;
  90456. private _processedMaterials;
  90457. private _renderTargets;
  90458. /** @hidden */
  90459. _activeParticleSystems: SmartArray<IParticleSystem>;
  90460. private _activeSkeletons;
  90461. private _softwareSkinnedMeshes;
  90462. private _renderingManager;
  90463. /** @hidden */
  90464. _activeAnimatables: Animatable[];
  90465. private _transformMatrix;
  90466. private _sceneUbo;
  90467. private _alternateSceneUbo;
  90468. private _viewMatrix;
  90469. private _projectionMatrix;
  90470. private _alternateViewMatrix;
  90471. private _alternateProjectionMatrix;
  90472. private _alternateTransformMatrix;
  90473. private _useAlternateCameraConfiguration;
  90474. private _alternateRendering;
  90475. private _wheelEventName;
  90476. /** @hidden */
  90477. _forcedViewPosition: Nullable<Vector3>;
  90478. /** @hidden */
  90479. readonly _isAlternateRenderingEnabled: boolean;
  90480. private _frustumPlanes;
  90481. /**
  90482. * Gets the list of frustum planes (built from the active camera)
  90483. */
  90484. readonly frustumPlanes: Plane[];
  90485. /**
  90486. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  90487. * This is useful if there are more lights that the maximum simulteanous authorized
  90488. */
  90489. requireLightSorting: boolean;
  90490. /** @hidden */
  90491. readonly useMaterialMeshMap: boolean;
  90492. /** @hidden */
  90493. readonly useClonedMeshhMap: boolean;
  90494. private _pointerOverMesh;
  90495. private _pickedDownMesh;
  90496. private _pickedUpMesh;
  90497. private _externalData;
  90498. private _uid;
  90499. /**
  90500. * @hidden
  90501. * Backing store of defined scene components.
  90502. */
  90503. _components: ISceneComponent[];
  90504. /**
  90505. * @hidden
  90506. * Backing store of defined scene components.
  90507. */
  90508. _serializableComponents: ISceneSerializableComponent[];
  90509. /**
  90510. * List of components to register on the next registration step.
  90511. */
  90512. private _transientComponents;
  90513. /**
  90514. * Registers the transient components if needed.
  90515. */
  90516. private _registerTransientComponents;
  90517. /**
  90518. * @hidden
  90519. * Add a component to the scene.
  90520. * Note that the ccomponent could be registered on th next frame if this is called after
  90521. * the register component stage.
  90522. * @param component Defines the component to add to the scene
  90523. */
  90524. _addComponent(component: ISceneComponent): void;
  90525. /**
  90526. * @hidden
  90527. * Gets a component from the scene.
  90528. * @param name defines the name of the component to retrieve
  90529. * @returns the component or null if not present
  90530. */
  90531. _getComponent(name: string): Nullable<ISceneComponent>;
  90532. /**
  90533. * @hidden
  90534. * Defines the actions happening before camera updates.
  90535. */
  90536. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  90537. /**
  90538. * @hidden
  90539. * Defines the actions happening before clear the canvas.
  90540. */
  90541. _beforeClearStage: Stage<SimpleStageAction>;
  90542. /**
  90543. * @hidden
  90544. * Defines the actions when collecting render targets for the frame.
  90545. */
  90546. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90547. /**
  90548. * @hidden
  90549. * Defines the actions happening for one camera in the frame.
  90550. */
  90551. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90552. /**
  90553. * @hidden
  90554. * Defines the actions happening during the per mesh ready checks.
  90555. */
  90556. _isReadyForMeshStage: Stage<MeshStageAction>;
  90557. /**
  90558. * @hidden
  90559. * Defines the actions happening before evaluate active mesh checks.
  90560. */
  90561. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  90562. /**
  90563. * @hidden
  90564. * Defines the actions happening during the evaluate sub mesh checks.
  90565. */
  90566. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  90567. /**
  90568. * @hidden
  90569. * Defines the actions happening during the active mesh stage.
  90570. */
  90571. _activeMeshStage: Stage<ActiveMeshStageAction>;
  90572. /**
  90573. * @hidden
  90574. * Defines the actions happening during the per camera render target step.
  90575. */
  90576. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  90577. /**
  90578. * @hidden
  90579. * Defines the actions happening just before the active camera is drawing.
  90580. */
  90581. _beforeCameraDrawStage: Stage<CameraStageAction>;
  90582. /**
  90583. * @hidden
  90584. * Defines the actions happening just before a render target is drawing.
  90585. */
  90586. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90587. /**
  90588. * @hidden
  90589. * Defines the actions happening just before a rendering group is drawing.
  90590. */
  90591. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90592. /**
  90593. * @hidden
  90594. * Defines the actions happening just before a mesh is drawing.
  90595. */
  90596. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90597. /**
  90598. * @hidden
  90599. * Defines the actions happening just after a mesh has been drawn.
  90600. */
  90601. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90602. /**
  90603. * @hidden
  90604. * Defines the actions happening just after a rendering group has been drawn.
  90605. */
  90606. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90607. /**
  90608. * @hidden
  90609. * Defines the actions happening just after the active camera has been drawn.
  90610. */
  90611. _afterCameraDrawStage: Stage<CameraStageAction>;
  90612. /**
  90613. * @hidden
  90614. * Defines the actions happening just after a render target has been drawn.
  90615. */
  90616. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90617. /**
  90618. * @hidden
  90619. * Defines the actions happening just after rendering all cameras and computing intersections.
  90620. */
  90621. _afterRenderStage: Stage<SimpleStageAction>;
  90622. /**
  90623. * @hidden
  90624. * Defines the actions happening when a pointer move event happens.
  90625. */
  90626. _pointerMoveStage: Stage<PointerMoveStageAction>;
  90627. /**
  90628. * @hidden
  90629. * Defines the actions happening when a pointer down event happens.
  90630. */
  90631. _pointerDownStage: Stage<PointerUpDownStageAction>;
  90632. /**
  90633. * @hidden
  90634. * Defines the actions happening when a pointer up event happens.
  90635. */
  90636. _pointerUpStage: Stage<PointerUpDownStageAction>;
  90637. /**
  90638. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  90639. */
  90640. private geometriesByUniqueId;
  90641. /**
  90642. * Creates a new Scene
  90643. * @param engine defines the engine to use to render this scene
  90644. * @param options defines the scene options
  90645. */
  90646. constructor(engine: Engine, options?: SceneOptions);
  90647. private _defaultMeshCandidates;
  90648. /**
  90649. * @hidden
  90650. */
  90651. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  90652. private _defaultSubMeshCandidates;
  90653. /**
  90654. * @hidden
  90655. */
  90656. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  90657. /**
  90658. * Sets the default candidate providers for the scene.
  90659. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  90660. * and getCollidingSubMeshCandidates to their default function
  90661. */
  90662. setDefaultCandidateProviders(): void;
  90663. /**
  90664. * Gets the mesh that is currently under the pointer
  90665. */
  90666. readonly meshUnderPointer: Nullable<AbstractMesh>;
  90667. /**
  90668. * Gets or sets the current on-screen X position of the pointer
  90669. */
  90670. pointerX: number;
  90671. /**
  90672. * Gets or sets the current on-screen Y position of the pointer
  90673. */
  90674. pointerY: number;
  90675. /**
  90676. * Gets the cached material (ie. the latest rendered one)
  90677. * @returns the cached material
  90678. */
  90679. getCachedMaterial(): Nullable<Material>;
  90680. /**
  90681. * Gets the cached effect (ie. the latest rendered one)
  90682. * @returns the cached effect
  90683. */
  90684. getCachedEffect(): Nullable<Effect>;
  90685. /**
  90686. * Gets the cached visibility state (ie. the latest rendered one)
  90687. * @returns the cached visibility state
  90688. */
  90689. getCachedVisibility(): Nullable<number>;
  90690. /**
  90691. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  90692. * @param material defines the current material
  90693. * @param effect defines the current effect
  90694. * @param visibility defines the current visibility state
  90695. * @returns true if one parameter is not cached
  90696. */
  90697. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  90698. /**
  90699. * Gets the engine associated with the scene
  90700. * @returns an Engine
  90701. */
  90702. getEngine(): Engine;
  90703. /**
  90704. * Gets the total number of vertices rendered per frame
  90705. * @returns the total number of vertices rendered per frame
  90706. */
  90707. getTotalVertices(): number;
  90708. /**
  90709. * Gets the performance counter for total vertices
  90710. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90711. */
  90712. readonly totalVerticesPerfCounter: PerfCounter;
  90713. /**
  90714. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  90715. * @returns the total number of active indices rendered per frame
  90716. */
  90717. getActiveIndices(): number;
  90718. /**
  90719. * Gets the performance counter for active indices
  90720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90721. */
  90722. readonly totalActiveIndicesPerfCounter: PerfCounter;
  90723. /**
  90724. * Gets the total number of active particles rendered per frame
  90725. * @returns the total number of active particles rendered per frame
  90726. */
  90727. getActiveParticles(): number;
  90728. /**
  90729. * Gets the performance counter for active particles
  90730. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90731. */
  90732. readonly activeParticlesPerfCounter: PerfCounter;
  90733. /**
  90734. * Gets the total number of active bones rendered per frame
  90735. * @returns the total number of active bones rendered per frame
  90736. */
  90737. getActiveBones(): number;
  90738. /**
  90739. * Gets the performance counter for active bones
  90740. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90741. */
  90742. readonly activeBonesPerfCounter: PerfCounter;
  90743. /**
  90744. * Gets the array of active meshes
  90745. * @returns an array of AbstractMesh
  90746. */
  90747. getActiveMeshes(): SmartArray<AbstractMesh>;
  90748. /**
  90749. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  90750. * @returns a number
  90751. */
  90752. getAnimationRatio(): number;
  90753. /**
  90754. * Gets an unique Id for the current render phase
  90755. * @returns a number
  90756. */
  90757. getRenderId(): number;
  90758. /**
  90759. * Gets an unique Id for the current frame
  90760. * @returns a number
  90761. */
  90762. getFrameId(): number;
  90763. /** Call this function if you want to manually increment the render Id*/
  90764. incrementRenderId(): void;
  90765. private _updatePointerPosition;
  90766. private _createUbo;
  90767. private _createAlternateUbo;
  90768. private _setRayOnPointerInfo;
  90769. /**
  90770. * Use this method to simulate a pointer move on a mesh
  90771. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90772. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90773. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90774. * @returns the current scene
  90775. */
  90776. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90777. private _processPointerMove;
  90778. private _checkPrePointerObservable;
  90779. /**
  90780. * Use this method to simulate a pointer down on a mesh
  90781. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90782. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90783. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90784. * @returns the current scene
  90785. */
  90786. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90787. private _processPointerDown;
  90788. /**
  90789. * Use this method to simulate a pointer up on a mesh
  90790. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90791. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90792. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90793. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  90794. * @returns the current scene
  90795. */
  90796. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  90797. private _processPointerUp;
  90798. /**
  90799. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  90800. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  90801. * @returns true if the pointer was captured
  90802. */
  90803. isPointerCaptured(pointerId?: number): boolean;
  90804. /** @hidden */
  90805. _isPointerSwiping(): boolean;
  90806. /**
  90807. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  90808. * @param attachUp defines if you want to attach events to pointerup
  90809. * @param attachDown defines if you want to attach events to pointerdown
  90810. * @param attachMove defines if you want to attach events to pointermove
  90811. */
  90812. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  90813. /** Detaches all event handlers*/
  90814. detachControl(): void;
  90815. /**
  90816. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  90817. * Delay loaded resources are not taking in account
  90818. * @return true if all required resources are ready
  90819. */
  90820. isReady(): boolean;
  90821. /** Resets all cached information relative to material (including effect and visibility) */
  90822. resetCachedMaterial(): void;
  90823. /**
  90824. * Registers a function to be called before every frame render
  90825. * @param func defines the function to register
  90826. */
  90827. registerBeforeRender(func: () => void): void;
  90828. /**
  90829. * Unregisters a function called before every frame render
  90830. * @param func defines the function to unregister
  90831. */
  90832. unregisterBeforeRender(func: () => void): void;
  90833. /**
  90834. * Registers a function to be called after every frame render
  90835. * @param func defines the function to register
  90836. */
  90837. registerAfterRender(func: () => void): void;
  90838. /**
  90839. * Unregisters a function called after every frame render
  90840. * @param func defines the function to unregister
  90841. */
  90842. unregisterAfterRender(func: () => void): void;
  90843. private _executeOnceBeforeRender;
  90844. /**
  90845. * The provided function will run before render once and will be disposed afterwards.
  90846. * A timeout delay can be provided so that the function will be executed in N ms.
  90847. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  90848. * @param func The function to be executed.
  90849. * @param timeout optional delay in ms
  90850. */
  90851. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  90852. /** @hidden */
  90853. _addPendingData(data: any): void;
  90854. /** @hidden */
  90855. _removePendingData(data: any): void;
  90856. /**
  90857. * Returns the number of items waiting to be loaded
  90858. * @returns the number of items waiting to be loaded
  90859. */
  90860. getWaitingItemsCount(): number;
  90861. /**
  90862. * Returns a boolean indicating if the scene is still loading data
  90863. */
  90864. readonly isLoading: boolean;
  90865. /**
  90866. * Registers a function to be executed when the scene is ready
  90867. * @param {Function} func - the function to be executed
  90868. */
  90869. executeWhenReady(func: () => void): void;
  90870. /**
  90871. * Returns a promise that resolves when the scene is ready
  90872. * @returns A promise that resolves when the scene is ready
  90873. */
  90874. whenReadyAsync(): Promise<void>;
  90875. /** @hidden */
  90876. _checkIsReady(): void;
  90877. /**
  90878. * Gets all animatable attached to the scene
  90879. */
  90880. readonly animatables: Animatable[];
  90881. /**
  90882. * Resets the last animation time frame.
  90883. * Useful to override when animations start running when loading a scene for the first time.
  90884. */
  90885. resetLastAnimationTimeFrame(): void;
  90886. /** @hidden */
  90887. _switchToAlternateCameraConfiguration(active: boolean): void;
  90888. /**
  90889. * Gets the current view matrix
  90890. * @returns a Matrix
  90891. */
  90892. getViewMatrix(): Matrix;
  90893. /**
  90894. * Gets the current projection matrix
  90895. * @returns a Matrix
  90896. */
  90897. getProjectionMatrix(): Matrix;
  90898. /**
  90899. * Gets the current transform matrix
  90900. * @returns a Matrix made of View * Projection
  90901. */
  90902. getTransformMatrix(): Matrix;
  90903. /**
  90904. * Sets the current transform matrix
  90905. * @param view defines the View matrix to use
  90906. * @param projection defines the Projection matrix to use
  90907. */
  90908. setTransformMatrix(view: Matrix, projection: Matrix): void;
  90909. /** @hidden */
  90910. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  90911. /**
  90912. * Gets the uniform buffer used to store scene data
  90913. * @returns a UniformBuffer
  90914. */
  90915. getSceneUniformBuffer(): UniformBuffer;
  90916. /**
  90917. * Gets an unique (relatively to the current scene) Id
  90918. * @returns an unique number for the scene
  90919. */
  90920. getUniqueId(): number;
  90921. /**
  90922. * Add a mesh to the list of scene's meshes
  90923. * @param newMesh defines the mesh to add
  90924. * @param recursive if all child meshes should also be added to the scene
  90925. */
  90926. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  90927. /**
  90928. * Remove a mesh for the list of scene's meshes
  90929. * @param toRemove defines the mesh to remove
  90930. * @param recursive if all child meshes should also be removed from the scene
  90931. * @returns the index where the mesh was in the mesh list
  90932. */
  90933. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  90934. /**
  90935. * Add a transform node to the list of scene's transform nodes
  90936. * @param newTransformNode defines the transform node to add
  90937. */
  90938. addTransformNode(newTransformNode: TransformNode): void;
  90939. /**
  90940. * Remove a transform node for the list of scene's transform nodes
  90941. * @param toRemove defines the transform node to remove
  90942. * @returns the index where the transform node was in the transform node list
  90943. */
  90944. removeTransformNode(toRemove: TransformNode): number;
  90945. /**
  90946. * Remove a skeleton for the list of scene's skeletons
  90947. * @param toRemove defines the skeleton to remove
  90948. * @returns the index where the skeleton was in the skeleton list
  90949. */
  90950. removeSkeleton(toRemove: Skeleton): number;
  90951. /**
  90952. * Remove a morph target for the list of scene's morph targets
  90953. * @param toRemove defines the morph target to remove
  90954. * @returns the index where the morph target was in the morph target list
  90955. */
  90956. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  90957. /**
  90958. * Remove a light for the list of scene's lights
  90959. * @param toRemove defines the light to remove
  90960. * @returns the index where the light was in the light list
  90961. */
  90962. removeLight(toRemove: Light): number;
  90963. /**
  90964. * Remove a camera for the list of scene's cameras
  90965. * @param toRemove defines the camera to remove
  90966. * @returns the index where the camera was in the camera list
  90967. */
  90968. removeCamera(toRemove: Camera): number;
  90969. /**
  90970. * Remove a particle system for the list of scene's particle systems
  90971. * @param toRemove defines the particle system to remove
  90972. * @returns the index where the particle system was in the particle system list
  90973. */
  90974. removeParticleSystem(toRemove: IParticleSystem): number;
  90975. /**
  90976. * Remove a animation for the list of scene's animations
  90977. * @param toRemove defines the animation to remove
  90978. * @returns the index where the animation was in the animation list
  90979. */
  90980. removeAnimation(toRemove: Animation): number;
  90981. /**
  90982. * Removes the given animation group from this scene.
  90983. * @param toRemove The animation group to remove
  90984. * @returns The index of the removed animation group
  90985. */
  90986. removeAnimationGroup(toRemove: AnimationGroup): number;
  90987. /**
  90988. * Removes the given multi-material from this scene.
  90989. * @param toRemove The multi-material to remove
  90990. * @returns The index of the removed multi-material
  90991. */
  90992. removeMultiMaterial(toRemove: MultiMaterial): number;
  90993. /**
  90994. * Removes the given material from this scene.
  90995. * @param toRemove The material to remove
  90996. * @returns The index of the removed material
  90997. */
  90998. removeMaterial(toRemove: Material): number;
  90999. /**
  91000. * Removes the given action manager from this scene.
  91001. * @param toRemove The action manager to remove
  91002. * @returns The index of the removed action manager
  91003. */
  91004. removeActionManager(toRemove: AbstractActionManager): number;
  91005. /**
  91006. * Removes the given texture from this scene.
  91007. * @param toRemove The texture to remove
  91008. * @returns The index of the removed texture
  91009. */
  91010. removeTexture(toRemove: BaseTexture): number;
  91011. /**
  91012. * Adds the given light to this scene
  91013. * @param newLight The light to add
  91014. */
  91015. addLight(newLight: Light): void;
  91016. /**
  91017. * Sorts the list list based on light priorities
  91018. */
  91019. sortLightsByPriority(): void;
  91020. /**
  91021. * Adds the given camera to this scene
  91022. * @param newCamera The camera to add
  91023. */
  91024. addCamera(newCamera: Camera): void;
  91025. /**
  91026. * Adds the given skeleton to this scene
  91027. * @param newSkeleton The skeleton to add
  91028. */
  91029. addSkeleton(newSkeleton: Skeleton): void;
  91030. /**
  91031. * Adds the given particle system to this scene
  91032. * @param newParticleSystem The particle system to add
  91033. */
  91034. addParticleSystem(newParticleSystem: IParticleSystem): void;
  91035. /**
  91036. * Adds the given animation to this scene
  91037. * @param newAnimation The animation to add
  91038. */
  91039. addAnimation(newAnimation: Animation): void;
  91040. /**
  91041. * Adds the given animation group to this scene.
  91042. * @param newAnimationGroup The animation group to add
  91043. */
  91044. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  91045. /**
  91046. * Adds the given multi-material to this scene
  91047. * @param newMultiMaterial The multi-material to add
  91048. */
  91049. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  91050. /**
  91051. * Adds the given material to this scene
  91052. * @param newMaterial The material to add
  91053. */
  91054. addMaterial(newMaterial: Material): void;
  91055. /**
  91056. * Adds the given morph target to this scene
  91057. * @param newMorphTargetManager The morph target to add
  91058. */
  91059. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  91060. /**
  91061. * Adds the given geometry to this scene
  91062. * @param newGeometry The geometry to add
  91063. */
  91064. addGeometry(newGeometry: Geometry): void;
  91065. /**
  91066. * Adds the given action manager to this scene
  91067. * @param newActionManager The action manager to add
  91068. */
  91069. addActionManager(newActionManager: AbstractActionManager): void;
  91070. /**
  91071. * Adds the given texture to this scene.
  91072. * @param newTexture The texture to add
  91073. */
  91074. addTexture(newTexture: BaseTexture): void;
  91075. /**
  91076. * Switch active camera
  91077. * @param newCamera defines the new active camera
  91078. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  91079. */
  91080. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  91081. /**
  91082. * sets the active camera of the scene using its ID
  91083. * @param id defines the camera's ID
  91084. * @return the new active camera or null if none found.
  91085. */
  91086. setActiveCameraByID(id: string): Nullable<Camera>;
  91087. /**
  91088. * sets the active camera of the scene using its name
  91089. * @param name defines the camera's name
  91090. * @returns the new active camera or null if none found.
  91091. */
  91092. setActiveCameraByName(name: string): Nullable<Camera>;
  91093. /**
  91094. * get an animation group using its name
  91095. * @param name defines the material's name
  91096. * @return the animation group or null if none found.
  91097. */
  91098. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  91099. /**
  91100. * Get a material using its unique id
  91101. * @param uniqueId defines the material's unique id
  91102. * @return the material or null if none found.
  91103. */
  91104. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  91105. /**
  91106. * get a material using its id
  91107. * @param id defines the material's ID
  91108. * @return the material or null if none found.
  91109. */
  91110. getMaterialByID(id: string): Nullable<Material>;
  91111. /**
  91112. * Gets a material using its name
  91113. * @param name defines the material's name
  91114. * @return the material or null if none found.
  91115. */
  91116. getMaterialByName(name: string): Nullable<Material>;
  91117. /**
  91118. * Gets a camera using its id
  91119. * @param id defines the id to look for
  91120. * @returns the camera or null if not found
  91121. */
  91122. getCameraByID(id: string): Nullable<Camera>;
  91123. /**
  91124. * Gets a camera using its unique id
  91125. * @param uniqueId defines the unique id to look for
  91126. * @returns the camera or null if not found
  91127. */
  91128. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  91129. /**
  91130. * Gets a camera using its name
  91131. * @param name defines the camera's name
  91132. * @return the camera or null if none found.
  91133. */
  91134. getCameraByName(name: string): Nullable<Camera>;
  91135. /**
  91136. * Gets a bone using its id
  91137. * @param id defines the bone's id
  91138. * @return the bone or null if not found
  91139. */
  91140. getBoneByID(id: string): Nullable<Bone>;
  91141. /**
  91142. * Gets a bone using its id
  91143. * @param name defines the bone's name
  91144. * @return the bone or null if not found
  91145. */
  91146. getBoneByName(name: string): Nullable<Bone>;
  91147. /**
  91148. * Gets a light node using its name
  91149. * @param name defines the the light's name
  91150. * @return the light or null if none found.
  91151. */
  91152. getLightByName(name: string): Nullable<Light>;
  91153. /**
  91154. * Gets a light node using its id
  91155. * @param id defines the light's id
  91156. * @return the light or null if none found.
  91157. */
  91158. getLightByID(id: string): Nullable<Light>;
  91159. /**
  91160. * Gets a light node using its scene-generated unique ID
  91161. * @param uniqueId defines the light's unique id
  91162. * @return the light or null if none found.
  91163. */
  91164. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  91165. /**
  91166. * Gets a particle system by id
  91167. * @param id defines the particle system id
  91168. * @return the corresponding system or null if none found
  91169. */
  91170. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  91171. /**
  91172. * Gets a geometry using its ID
  91173. * @param id defines the geometry's id
  91174. * @return the geometry or null if none found.
  91175. */
  91176. getGeometryByID(id: string): Nullable<Geometry>;
  91177. private _getGeometryByUniqueID;
  91178. /**
  91179. * Add a new geometry to this scene
  91180. * @param geometry defines the geometry to be added to the scene.
  91181. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  91182. * @return a boolean defining if the geometry was added or not
  91183. */
  91184. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  91185. /**
  91186. * Removes an existing geometry
  91187. * @param geometry defines the geometry to be removed from the scene
  91188. * @return a boolean defining if the geometry was removed or not
  91189. */
  91190. removeGeometry(geometry: Geometry): boolean;
  91191. /**
  91192. * Gets the list of geometries attached to the scene
  91193. * @returns an array of Geometry
  91194. */
  91195. getGeometries(): Geometry[];
  91196. /**
  91197. * Gets the first added mesh found of a given ID
  91198. * @param id defines the id to search for
  91199. * @return the mesh found or null if not found at all
  91200. */
  91201. getMeshByID(id: string): Nullable<AbstractMesh>;
  91202. /**
  91203. * Gets a list of meshes using their id
  91204. * @param id defines the id to search for
  91205. * @returns a list of meshes
  91206. */
  91207. getMeshesByID(id: string): Array<AbstractMesh>;
  91208. /**
  91209. * Gets the first added transform node found of a given ID
  91210. * @param id defines the id to search for
  91211. * @return the found transform node or null if not found at all.
  91212. */
  91213. getTransformNodeByID(id: string): Nullable<TransformNode>;
  91214. /**
  91215. * Gets a transform node with its auto-generated unique id
  91216. * @param uniqueId efines the unique id to search for
  91217. * @return the found transform node or null if not found at all.
  91218. */
  91219. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  91220. /**
  91221. * Gets a list of transform nodes using their id
  91222. * @param id defines the id to search for
  91223. * @returns a list of transform nodes
  91224. */
  91225. getTransformNodesByID(id: string): Array<TransformNode>;
  91226. /**
  91227. * Gets a mesh with its auto-generated unique id
  91228. * @param uniqueId defines the unique id to search for
  91229. * @return the found mesh or null if not found at all.
  91230. */
  91231. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  91232. /**
  91233. * Gets a the last added mesh using a given id
  91234. * @param id defines the id to search for
  91235. * @return the found mesh or null if not found at all.
  91236. */
  91237. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  91238. /**
  91239. * Gets a the last added node (Mesh, Camera, Light) using a given id
  91240. * @param id defines the id to search for
  91241. * @return the found node or null if not found at all
  91242. */
  91243. getLastEntryByID(id: string): Nullable<Node>;
  91244. /**
  91245. * Gets a node (Mesh, Camera, Light) using a given id
  91246. * @param id defines the id to search for
  91247. * @return the found node or null if not found at all
  91248. */
  91249. getNodeByID(id: string): Nullable<Node>;
  91250. /**
  91251. * Gets a node (Mesh, Camera, Light) using a given name
  91252. * @param name defines the name to search for
  91253. * @return the found node or null if not found at all.
  91254. */
  91255. getNodeByName(name: string): Nullable<Node>;
  91256. /**
  91257. * Gets a mesh using a given name
  91258. * @param name defines the name to search for
  91259. * @return the found mesh or null if not found at all.
  91260. */
  91261. getMeshByName(name: string): Nullable<AbstractMesh>;
  91262. /**
  91263. * Gets a transform node using a given name
  91264. * @param name defines the name to search for
  91265. * @return the found transform node or null if not found at all.
  91266. */
  91267. getTransformNodeByName(name: string): Nullable<TransformNode>;
  91268. /**
  91269. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  91270. * @param id defines the id to search for
  91271. * @return the found skeleton or null if not found at all.
  91272. */
  91273. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  91274. /**
  91275. * Gets a skeleton using a given auto generated unique id
  91276. * @param uniqueId defines the unique id to search for
  91277. * @return the found skeleton or null if not found at all.
  91278. */
  91279. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  91280. /**
  91281. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  91282. * @param id defines the id to search for
  91283. * @return the found skeleton or null if not found at all.
  91284. */
  91285. getSkeletonById(id: string): Nullable<Skeleton>;
  91286. /**
  91287. * Gets a skeleton using a given name
  91288. * @param name defines the name to search for
  91289. * @return the found skeleton or null if not found at all.
  91290. */
  91291. getSkeletonByName(name: string): Nullable<Skeleton>;
  91292. /**
  91293. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  91294. * @param id defines the id to search for
  91295. * @return the found morph target manager or null if not found at all.
  91296. */
  91297. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  91298. /**
  91299. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  91300. * @param id defines the id to search for
  91301. * @return the found morph target or null if not found at all.
  91302. */
  91303. getMorphTargetById(id: string): Nullable<MorphTarget>;
  91304. /**
  91305. * Gets a boolean indicating if the given mesh is active
  91306. * @param mesh defines the mesh to look for
  91307. * @returns true if the mesh is in the active list
  91308. */
  91309. isActiveMesh(mesh: AbstractMesh): boolean;
  91310. /**
  91311. * Return a unique id as a string which can serve as an identifier for the scene
  91312. */
  91313. readonly uid: string;
  91314. /**
  91315. * Add an externaly attached data from its key.
  91316. * This method call will fail and return false, if such key already exists.
  91317. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91318. * @param key the unique key that identifies the data
  91319. * @param data the data object to associate to the key for this Engine instance
  91320. * @return true if no such key were already present and the data was added successfully, false otherwise
  91321. */
  91322. addExternalData<T>(key: string, data: T): boolean;
  91323. /**
  91324. * Get an externaly attached data from its key
  91325. * @param key the unique key that identifies the data
  91326. * @return the associated data, if present (can be null), or undefined if not present
  91327. */
  91328. getExternalData<T>(key: string): Nullable<T>;
  91329. /**
  91330. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91331. * @param key the unique key that identifies the data
  91332. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91333. * @return the associated data, can be null if the factory returned null.
  91334. */
  91335. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91336. /**
  91337. * Remove an externaly attached data from the Engine instance
  91338. * @param key the unique key that identifies the data
  91339. * @return true if the data was successfully removed, false if it doesn't exist
  91340. */
  91341. removeExternalData(key: string): boolean;
  91342. private _evaluateSubMesh;
  91343. /**
  91344. * Clear the processed materials smart array preventing retention point in material dispose.
  91345. */
  91346. freeProcessedMaterials(): void;
  91347. private _preventFreeActiveMeshesAndRenderingGroups;
  91348. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  91349. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  91350. * when disposing several meshes in a row or a hierarchy of meshes.
  91351. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  91352. */
  91353. blockfreeActiveMeshesAndRenderingGroups: boolean;
  91354. /**
  91355. * Clear the active meshes smart array preventing retention point in mesh dispose.
  91356. */
  91357. freeActiveMeshes(): void;
  91358. /**
  91359. * Clear the info related to rendering groups preventing retention points during dispose.
  91360. */
  91361. freeRenderingGroups(): void;
  91362. /** @hidden */
  91363. _isInIntermediateRendering(): boolean;
  91364. /**
  91365. * Lambda returning the list of potentially active meshes.
  91366. */
  91367. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  91368. /**
  91369. * Lambda returning the list of potentially active sub meshes.
  91370. */
  91371. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  91372. /**
  91373. * Lambda returning the list of potentially intersecting sub meshes.
  91374. */
  91375. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  91376. /**
  91377. * Lambda returning the list of potentially colliding sub meshes.
  91378. */
  91379. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  91380. private _activeMeshesFrozen;
  91381. /**
  91382. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  91383. * @returns the current scene
  91384. */
  91385. freezeActiveMeshes(): Scene;
  91386. /**
  91387. * Use this function to restart evaluating active meshes on every frame
  91388. * @returns the current scene
  91389. */
  91390. unfreezeActiveMeshes(): Scene;
  91391. private _evaluateActiveMeshes;
  91392. private _activeMesh;
  91393. /**
  91394. * Update the transform matrix to update from the current active camera
  91395. * @param force defines a boolean used to force the update even if cache is up to date
  91396. */
  91397. updateTransformMatrix(force?: boolean): void;
  91398. /**
  91399. * 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)
  91400. * @param alternateCamera defines the camera to use
  91401. */
  91402. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  91403. /** @hidden */
  91404. _allowPostProcessClearColor: boolean;
  91405. private _renderForCamera;
  91406. private _processSubCameras;
  91407. private _checkIntersections;
  91408. /** @hidden */
  91409. _advancePhysicsEngineStep(step: number): void;
  91410. /**
  91411. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  91412. */
  91413. getDeterministicFrameTime: () => number;
  91414. /** @hidden */
  91415. _animate(): void;
  91416. /**
  91417. * Render the scene
  91418. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  91419. */
  91420. render(updateCameras?: boolean): void;
  91421. /**
  91422. * Freeze all materials
  91423. * A frozen material will not be updatable but should be faster to render
  91424. */
  91425. freezeMaterials(): void;
  91426. /**
  91427. * Unfreeze all materials
  91428. * A frozen material will not be updatable but should be faster to render
  91429. */
  91430. unfreezeMaterials(): void;
  91431. /**
  91432. * Releases all held ressources
  91433. */
  91434. dispose(): void;
  91435. /**
  91436. * Gets if the scene is already disposed
  91437. */
  91438. readonly isDisposed: boolean;
  91439. /**
  91440. * Call this function to reduce memory footprint of the scene.
  91441. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  91442. */
  91443. clearCachedVertexData(): void;
  91444. /**
  91445. * This function will remove the local cached buffer data from texture.
  91446. * It will save memory but will prevent the texture from being rebuilt
  91447. */
  91448. cleanCachedTextureBuffer(): void;
  91449. /**
  91450. * Get the world extend vectors with an optional filter
  91451. *
  91452. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  91453. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  91454. */
  91455. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  91456. min: Vector3;
  91457. max: Vector3;
  91458. };
  91459. /**
  91460. * Creates a ray that can be used to pick in the scene
  91461. * @param x defines the x coordinate of the origin (on-screen)
  91462. * @param y defines the y coordinate of the origin (on-screen)
  91463. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91464. * @param camera defines the camera to use for the picking
  91465. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91466. * @returns a Ray
  91467. */
  91468. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  91469. /**
  91470. * Creates a ray that can be used to pick in the scene
  91471. * @param x defines the x coordinate of the origin (on-screen)
  91472. * @param y defines the y coordinate of the origin (on-screen)
  91473. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91474. * @param result defines the ray where to store the picking ray
  91475. * @param camera defines the camera to use for the picking
  91476. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91477. * @returns the current scene
  91478. */
  91479. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  91480. /**
  91481. * Creates a ray that can be used to pick in the scene
  91482. * @param x defines the x coordinate of the origin (on-screen)
  91483. * @param y defines the y coordinate of the origin (on-screen)
  91484. * @param camera defines the camera to use for the picking
  91485. * @returns a Ray
  91486. */
  91487. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  91488. /**
  91489. * Creates a ray that can be used to pick in the scene
  91490. * @param x defines the x coordinate of the origin (on-screen)
  91491. * @param y defines the y coordinate of the origin (on-screen)
  91492. * @param result defines the ray where to store the picking ray
  91493. * @param camera defines the camera to use for the picking
  91494. * @returns the current scene
  91495. */
  91496. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  91497. /** Launch a ray to try to pick a mesh in the scene
  91498. * @param x position on screen
  91499. * @param y position on screen
  91500. * @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
  91501. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  91502. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91503. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91504. * @returns a PickingInfo
  91505. */
  91506. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  91507. /** Use the given ray to pick a mesh in the scene
  91508. * @param ray The ray to use to pick meshes
  91509. * @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
  91510. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  91511. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91512. * @returns a PickingInfo
  91513. */
  91514. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91515. /**
  91516. * Launch a ray to try to pick a mesh in the scene
  91517. * @param x X position on screen
  91518. * @param y Y position on screen
  91519. * @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
  91520. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91521. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91522. * @returns an array of PickingInfo
  91523. */
  91524. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91525. /**
  91526. * Launch a ray to try to pick a mesh in the scene
  91527. * @param ray Ray to use
  91528. * @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
  91529. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91530. * @returns an array of PickingInfo
  91531. */
  91532. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91533. /**
  91534. * Force the value of meshUnderPointer
  91535. * @param mesh defines the mesh to use
  91536. */
  91537. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91538. /**
  91539. * Gets the mesh under the pointer
  91540. * @returns a Mesh or null if no mesh is under the pointer
  91541. */
  91542. getPointerOverMesh(): Nullable<AbstractMesh>;
  91543. /** @hidden */
  91544. _rebuildGeometries(): void;
  91545. /** @hidden */
  91546. _rebuildTextures(): void;
  91547. private _getByTags;
  91548. /**
  91549. * Get a list of meshes by tags
  91550. * @param tagsQuery defines the tags query to use
  91551. * @param forEach defines a predicate used to filter results
  91552. * @returns an array of Mesh
  91553. */
  91554. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  91555. /**
  91556. * Get a list of cameras by tags
  91557. * @param tagsQuery defines the tags query to use
  91558. * @param forEach defines a predicate used to filter results
  91559. * @returns an array of Camera
  91560. */
  91561. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  91562. /**
  91563. * Get a list of lights by tags
  91564. * @param tagsQuery defines the tags query to use
  91565. * @param forEach defines a predicate used to filter results
  91566. * @returns an array of Light
  91567. */
  91568. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  91569. /**
  91570. * Get a list of materials by tags
  91571. * @param tagsQuery defines the tags query to use
  91572. * @param forEach defines a predicate used to filter results
  91573. * @returns an array of Material
  91574. */
  91575. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  91576. /**
  91577. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91578. * This allowed control for front to back rendering or reversly depending of the special needs.
  91579. *
  91580. * @param renderingGroupId The rendering group id corresponding to its index
  91581. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91582. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91583. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91584. */
  91585. 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;
  91586. /**
  91587. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91588. *
  91589. * @param renderingGroupId The rendering group id corresponding to its index
  91590. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91591. * @param depth Automatically clears depth between groups if true and autoClear is true.
  91592. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  91593. */
  91594. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  91595. /**
  91596. * Gets the current auto clear configuration for one rendering group of the rendering
  91597. * manager.
  91598. * @param index the rendering group index to get the information for
  91599. * @returns The auto clear setup for the requested rendering group
  91600. */
  91601. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  91602. private _blockMaterialDirtyMechanism;
  91603. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  91604. blockMaterialDirtyMechanism: boolean;
  91605. /**
  91606. * Will flag all materials as dirty to trigger new shader compilation
  91607. * @param flag defines the flag used to specify which material part must be marked as dirty
  91608. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  91609. */
  91610. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  91611. /** @hidden */
  91612. _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;
  91613. /** @hidden */
  91614. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91615. }
  91616. }
  91617. declare module BABYLON {
  91618. /**
  91619. * Set of assets to keep when moving a scene into an asset container.
  91620. */
  91621. export class KeepAssets extends AbstractScene {
  91622. }
  91623. /**
  91624. * Container with a set of assets that can be added or removed from a scene.
  91625. */
  91626. export class AssetContainer extends AbstractScene {
  91627. /**
  91628. * The scene the AssetContainer belongs to.
  91629. */
  91630. scene: Scene;
  91631. /**
  91632. * Instantiates an AssetContainer.
  91633. * @param scene The scene the AssetContainer belongs to.
  91634. */
  91635. constructor(scene: Scene);
  91636. /**
  91637. * Adds all the assets from the container to the scene.
  91638. */
  91639. addAllToScene(): void;
  91640. /**
  91641. * Removes all the assets in the container from the scene
  91642. */
  91643. removeAllFromScene(): void;
  91644. /**
  91645. * Disposes all the assets in the container
  91646. */
  91647. dispose(): void;
  91648. private _moveAssets;
  91649. /**
  91650. * Removes all the assets contained in the scene and adds them to the container.
  91651. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  91652. */
  91653. moveAllFromScene(keepAssets?: KeepAssets): void;
  91654. /**
  91655. * 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.
  91656. * @returns the root mesh
  91657. */
  91658. createRootMesh(): Mesh;
  91659. }
  91660. }
  91661. declare module BABYLON {
  91662. /**
  91663. * Defines how the parser contract is defined.
  91664. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  91665. */
  91666. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  91667. /**
  91668. * Defines how the individual parser contract is defined.
  91669. * These parser can parse an individual asset
  91670. */
  91671. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  91672. /**
  91673. * Base class of the scene acting as a container for the different elements composing a scene.
  91674. * This class is dynamically extended by the different components of the scene increasing
  91675. * flexibility and reducing coupling
  91676. */
  91677. export abstract class AbstractScene {
  91678. /**
  91679. * Stores the list of available parsers in the application.
  91680. */
  91681. private static _BabylonFileParsers;
  91682. /**
  91683. * Stores the list of available individual parsers in the application.
  91684. */
  91685. private static _IndividualBabylonFileParsers;
  91686. /**
  91687. * Adds a parser in the list of available ones
  91688. * @param name Defines the name of the parser
  91689. * @param parser Defines the parser to add
  91690. */
  91691. static AddParser(name: string, parser: BabylonFileParser): void;
  91692. /**
  91693. * Gets a general parser from the list of avaialble ones
  91694. * @param name Defines the name of the parser
  91695. * @returns the requested parser or null
  91696. */
  91697. static GetParser(name: string): Nullable<BabylonFileParser>;
  91698. /**
  91699. * Adds n individual parser in the list of available ones
  91700. * @param name Defines the name of the parser
  91701. * @param parser Defines the parser to add
  91702. */
  91703. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  91704. /**
  91705. * Gets an individual parser from the list of avaialble ones
  91706. * @param name Defines the name of the parser
  91707. * @returns the requested parser or null
  91708. */
  91709. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  91710. /**
  91711. * Parser json data and populate both a scene and its associated container object
  91712. * @param jsonData Defines the data to parse
  91713. * @param scene Defines the scene to parse the data for
  91714. * @param container Defines the container attached to the parsing sequence
  91715. * @param rootUrl Defines the root url of the data
  91716. */
  91717. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  91718. /**
  91719. * Gets the list of root nodes (ie. nodes with no parent)
  91720. */
  91721. rootNodes: Node[];
  91722. /** All of the cameras added to this scene
  91723. * @see http://doc.babylonjs.com/babylon101/cameras
  91724. */
  91725. cameras: Camera[];
  91726. /**
  91727. * All of the lights added to this scene
  91728. * @see http://doc.babylonjs.com/babylon101/lights
  91729. */
  91730. lights: Light[];
  91731. /**
  91732. * All of the (abstract) meshes added to this scene
  91733. */
  91734. meshes: AbstractMesh[];
  91735. /**
  91736. * The list of skeletons added to the scene
  91737. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91738. */
  91739. skeletons: Skeleton[];
  91740. /**
  91741. * All of the particle systems added to this scene
  91742. * @see http://doc.babylonjs.com/babylon101/particles
  91743. */
  91744. particleSystems: IParticleSystem[];
  91745. /**
  91746. * Gets a list of Animations associated with the scene
  91747. */
  91748. animations: Animation[];
  91749. /**
  91750. * All of the animation groups added to this scene
  91751. * @see http://doc.babylonjs.com/how_to/group
  91752. */
  91753. animationGroups: AnimationGroup[];
  91754. /**
  91755. * All of the multi-materials added to this scene
  91756. * @see http://doc.babylonjs.com/how_to/multi_materials
  91757. */
  91758. multiMaterials: MultiMaterial[];
  91759. /**
  91760. * All of the materials added to this scene
  91761. * In the context of a Scene, it is not supposed to be modified manually.
  91762. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  91763. * Note also that the order of the Material wihin the array is not significant and might change.
  91764. * @see http://doc.babylonjs.com/babylon101/materials
  91765. */
  91766. materials: Material[];
  91767. /**
  91768. * The list of morph target managers added to the scene
  91769. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  91770. */
  91771. morphTargetManagers: MorphTargetManager[];
  91772. /**
  91773. * The list of geometries used in the scene.
  91774. */
  91775. geometries: Geometry[];
  91776. /**
  91777. * All of the tranform nodes added to this scene
  91778. * In the context of a Scene, it is not supposed to be modified manually.
  91779. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  91780. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  91781. * @see http://doc.babylonjs.com/how_to/transformnode
  91782. */
  91783. transformNodes: TransformNode[];
  91784. /**
  91785. * ActionManagers available on the scene.
  91786. */
  91787. actionManagers: AbstractActionManager[];
  91788. /**
  91789. * Textures to keep.
  91790. */
  91791. textures: BaseTexture[];
  91792. }
  91793. }
  91794. declare module BABYLON {
  91795. /**
  91796. * Defines a sound that can be played in the application.
  91797. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  91798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91799. */
  91800. export class Sound {
  91801. /**
  91802. * The name of the sound in the scene.
  91803. */
  91804. name: string;
  91805. /**
  91806. * Does the sound autoplay once loaded.
  91807. */
  91808. autoplay: boolean;
  91809. /**
  91810. * Does the sound loop after it finishes playing once.
  91811. */
  91812. loop: boolean;
  91813. /**
  91814. * Does the sound use a custom attenuation curve to simulate the falloff
  91815. * happening when the source gets further away from the camera.
  91816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91817. */
  91818. useCustomAttenuation: boolean;
  91819. /**
  91820. * The sound track id this sound belongs to.
  91821. */
  91822. soundTrackId: number;
  91823. /**
  91824. * Is this sound currently played.
  91825. */
  91826. isPlaying: boolean;
  91827. /**
  91828. * Is this sound currently paused.
  91829. */
  91830. isPaused: boolean;
  91831. /**
  91832. * Does this sound enables spatial sound.
  91833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91834. */
  91835. spatialSound: boolean;
  91836. /**
  91837. * Define the reference distance the sound should be heard perfectly.
  91838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91839. */
  91840. refDistance: number;
  91841. /**
  91842. * Define the roll off factor of spatial sounds.
  91843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91844. */
  91845. rolloffFactor: number;
  91846. /**
  91847. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  91848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91849. */
  91850. maxDistance: number;
  91851. /**
  91852. * Define the distance attenuation model the sound will follow.
  91853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91854. */
  91855. distanceModel: string;
  91856. /**
  91857. * @hidden
  91858. * Back Compat
  91859. **/
  91860. onended: () => any;
  91861. /**
  91862. * Observable event when the current playing sound finishes.
  91863. */
  91864. onEndedObservable: Observable<Sound>;
  91865. private _panningModel;
  91866. private _playbackRate;
  91867. private _streaming;
  91868. private _startTime;
  91869. private _startOffset;
  91870. private _position;
  91871. /** @hidden */
  91872. _positionInEmitterSpace: boolean;
  91873. private _localDirection;
  91874. private _volume;
  91875. private _isReadyToPlay;
  91876. private _isDirectional;
  91877. private _readyToPlayCallback;
  91878. private _audioBuffer;
  91879. private _soundSource;
  91880. private _streamingSource;
  91881. private _soundPanner;
  91882. private _soundGain;
  91883. private _inputAudioNode;
  91884. private _outputAudioNode;
  91885. private _coneInnerAngle;
  91886. private _coneOuterAngle;
  91887. private _coneOuterGain;
  91888. private _scene;
  91889. private _connectedTransformNode;
  91890. private _customAttenuationFunction;
  91891. private _registerFunc;
  91892. private _isOutputConnected;
  91893. private _htmlAudioElement;
  91894. private _urlType;
  91895. /** @hidden */
  91896. static _SceneComponentInitialization: (scene: Scene) => void;
  91897. /**
  91898. * Create a sound and attach it to a scene
  91899. * @param name Name of your sound
  91900. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  91901. * @param scene defines the scene the sound belongs to
  91902. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  91903. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  91904. */
  91905. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  91906. /**
  91907. * Release the sound and its associated resources
  91908. */
  91909. dispose(): void;
  91910. /**
  91911. * Gets if the sounds is ready to be played or not.
  91912. * @returns true if ready, otherwise false
  91913. */
  91914. isReady(): boolean;
  91915. private _soundLoaded;
  91916. /**
  91917. * Sets the data of the sound from an audiobuffer
  91918. * @param audioBuffer The audioBuffer containing the data
  91919. */
  91920. setAudioBuffer(audioBuffer: AudioBuffer): void;
  91921. /**
  91922. * Updates the current sounds options such as maxdistance, loop...
  91923. * @param options A JSON object containing values named as the object properties
  91924. */
  91925. updateOptions(options: any): void;
  91926. private _createSpatialParameters;
  91927. private _updateSpatialParameters;
  91928. /**
  91929. * Switch the panning model to HRTF:
  91930. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91932. */
  91933. switchPanningModelToHRTF(): void;
  91934. /**
  91935. * Switch the panning model to Equal Power:
  91936. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91938. */
  91939. switchPanningModelToEqualPower(): void;
  91940. private _switchPanningModel;
  91941. /**
  91942. * Connect this sound to a sound track audio node like gain...
  91943. * @param soundTrackAudioNode the sound track audio node to connect to
  91944. */
  91945. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  91946. /**
  91947. * Transform this sound into a directional source
  91948. * @param coneInnerAngle Size of the inner cone in degree
  91949. * @param coneOuterAngle Size of the outer cone in degree
  91950. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  91951. */
  91952. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  91953. /**
  91954. * Gets or sets the inner angle for the directional cone.
  91955. */
  91956. /**
  91957. * Gets or sets the inner angle for the directional cone.
  91958. */
  91959. directionalConeInnerAngle: number;
  91960. /**
  91961. * Gets or sets the outer angle for the directional cone.
  91962. */
  91963. /**
  91964. * Gets or sets the outer angle for the directional cone.
  91965. */
  91966. directionalConeOuterAngle: number;
  91967. /**
  91968. * Sets the position of the emitter if spatial sound is enabled
  91969. * @param newPosition Defines the new posisiton
  91970. */
  91971. setPosition(newPosition: Vector3): void;
  91972. /**
  91973. * Sets the local direction of the emitter if spatial sound is enabled
  91974. * @param newLocalDirection Defines the new local direction
  91975. */
  91976. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  91977. private _updateDirection;
  91978. /** @hidden */
  91979. updateDistanceFromListener(): void;
  91980. /**
  91981. * Sets a new custom attenuation function for the sound.
  91982. * @param callback Defines the function used for the attenuation
  91983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91984. */
  91985. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  91986. /**
  91987. * Play the sound
  91988. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  91989. * @param offset (optional) Start the sound setting it at a specific time
  91990. */
  91991. play(time?: number, offset?: number): void;
  91992. private _onended;
  91993. /**
  91994. * Stop the sound
  91995. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  91996. */
  91997. stop(time?: number): void;
  91998. /**
  91999. * Put the sound in pause
  92000. */
  92001. pause(): void;
  92002. /**
  92003. * Sets a dedicated volume for this sounds
  92004. * @param newVolume Define the new volume of the sound
  92005. * @param time Define in how long the sound should be at this value
  92006. */
  92007. setVolume(newVolume: number, time?: number): void;
  92008. /**
  92009. * Set the sound play back rate
  92010. * @param newPlaybackRate Define the playback rate the sound should be played at
  92011. */
  92012. setPlaybackRate(newPlaybackRate: number): void;
  92013. /**
  92014. * Gets the volume of the sound.
  92015. * @returns the volume of the sound
  92016. */
  92017. getVolume(): number;
  92018. /**
  92019. * Attach the sound to a dedicated mesh
  92020. * @param transformNode The transform node to connect the sound with
  92021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92022. */
  92023. attachToMesh(transformNode: TransformNode): void;
  92024. /**
  92025. * Detach the sound from the previously attached mesh
  92026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92027. */
  92028. detachFromMesh(): void;
  92029. private _onRegisterAfterWorldMatrixUpdate;
  92030. /**
  92031. * Clone the current sound in the scene.
  92032. * @returns the new sound clone
  92033. */
  92034. clone(): Nullable<Sound>;
  92035. /**
  92036. * Gets the current underlying audio buffer containing the data
  92037. * @returns the audio buffer
  92038. */
  92039. getAudioBuffer(): Nullable<AudioBuffer>;
  92040. /**
  92041. * Serializes the Sound in a JSON representation
  92042. * @returns the JSON representation of the sound
  92043. */
  92044. serialize(): any;
  92045. /**
  92046. * Parse a JSON representation of a sound to innstantiate in a given scene
  92047. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  92048. * @param scene Define the scene the new parsed sound should be created in
  92049. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  92050. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  92051. * @returns the newly parsed sound
  92052. */
  92053. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  92054. }
  92055. }
  92056. declare module BABYLON {
  92057. /**
  92058. * This defines an action helpful to play a defined sound on a triggered action.
  92059. */
  92060. export class PlaySoundAction extends Action {
  92061. private _sound;
  92062. /**
  92063. * Instantiate the action
  92064. * @param triggerOptions defines the trigger options
  92065. * @param sound defines the sound to play
  92066. * @param condition defines the trigger related conditions
  92067. */
  92068. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92069. /** @hidden */
  92070. _prepare(): void;
  92071. /**
  92072. * Execute the action and play the sound.
  92073. */
  92074. execute(): void;
  92075. /**
  92076. * Serializes the actions and its related information.
  92077. * @param parent defines the object to serialize in
  92078. * @returns the serialized object
  92079. */
  92080. serialize(parent: any): any;
  92081. }
  92082. /**
  92083. * This defines an action helpful to stop a defined sound on a triggered action.
  92084. */
  92085. export class StopSoundAction extends Action {
  92086. private _sound;
  92087. /**
  92088. * Instantiate the action
  92089. * @param triggerOptions defines the trigger options
  92090. * @param sound defines the sound to stop
  92091. * @param condition defines the trigger related conditions
  92092. */
  92093. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92094. /** @hidden */
  92095. _prepare(): void;
  92096. /**
  92097. * Execute the action and stop the sound.
  92098. */
  92099. execute(): void;
  92100. /**
  92101. * Serializes the actions and its related information.
  92102. * @param parent defines the object to serialize in
  92103. * @returns the serialized object
  92104. */
  92105. serialize(parent: any): any;
  92106. }
  92107. }
  92108. declare module BABYLON {
  92109. /**
  92110. * This defines an action responsible to change the value of a property
  92111. * by interpolating between its current value and the newly set one once triggered.
  92112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92113. */
  92114. export class InterpolateValueAction extends Action {
  92115. /**
  92116. * Defines the path of the property where the value should be interpolated
  92117. */
  92118. propertyPath: string;
  92119. /**
  92120. * Defines the target value at the end of the interpolation.
  92121. */
  92122. value: any;
  92123. /**
  92124. * Defines the time it will take for the property to interpolate to the value.
  92125. */
  92126. duration: number;
  92127. /**
  92128. * Defines if the other scene animations should be stopped when the action has been triggered
  92129. */
  92130. stopOtherAnimations?: boolean;
  92131. /**
  92132. * Defines a callback raised once the interpolation animation has been done.
  92133. */
  92134. onInterpolationDone?: () => void;
  92135. /**
  92136. * Observable triggered once the interpolation animation has been done.
  92137. */
  92138. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  92139. private _target;
  92140. private _effectiveTarget;
  92141. private _property;
  92142. /**
  92143. * Instantiate the action
  92144. * @param triggerOptions defines the trigger options
  92145. * @param target defines the object containing the value to interpolate
  92146. * @param propertyPath defines the path to the property in the target object
  92147. * @param value defines the target value at the end of the interpolation
  92148. * @param duration deines the time it will take for the property to interpolate to the value.
  92149. * @param condition defines the trigger related conditions
  92150. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  92151. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  92152. */
  92153. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  92154. /** @hidden */
  92155. _prepare(): void;
  92156. /**
  92157. * Execute the action starts the value interpolation.
  92158. */
  92159. execute(): void;
  92160. /**
  92161. * Serializes the actions and its related information.
  92162. * @param parent defines the object to serialize in
  92163. * @returns the serialized object
  92164. */
  92165. serialize(parent: any): any;
  92166. }
  92167. }
  92168. declare module BABYLON {
  92169. /**
  92170. * Options allowed during the creation of a sound track.
  92171. */
  92172. export interface ISoundTrackOptions {
  92173. /**
  92174. * The volume the sound track should take during creation
  92175. */
  92176. volume?: number;
  92177. /**
  92178. * Define if the sound track is the main sound track of the scene
  92179. */
  92180. mainTrack?: boolean;
  92181. }
  92182. /**
  92183. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  92184. * It will be also used in a future release to apply effects on a specific track.
  92185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92186. */
  92187. export class SoundTrack {
  92188. /**
  92189. * The unique identifier of the sound track in the scene.
  92190. */
  92191. id: number;
  92192. /**
  92193. * The list of sounds included in the sound track.
  92194. */
  92195. soundCollection: Array<Sound>;
  92196. private _outputAudioNode;
  92197. private _scene;
  92198. private _isMainTrack;
  92199. private _connectedAnalyser;
  92200. private _options;
  92201. private _isInitialized;
  92202. /**
  92203. * Creates a new sound track.
  92204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92205. * @param scene Define the scene the sound track belongs to
  92206. * @param options
  92207. */
  92208. constructor(scene: Scene, options?: ISoundTrackOptions);
  92209. private _initializeSoundTrackAudioGraph;
  92210. /**
  92211. * Release the sound track and its associated resources
  92212. */
  92213. dispose(): void;
  92214. /**
  92215. * Adds a sound to this sound track
  92216. * @param sound define the cound to add
  92217. * @ignoreNaming
  92218. */
  92219. AddSound(sound: Sound): void;
  92220. /**
  92221. * Removes a sound to this sound track
  92222. * @param sound define the cound to remove
  92223. * @ignoreNaming
  92224. */
  92225. RemoveSound(sound: Sound): void;
  92226. /**
  92227. * Set a global volume for the full sound track.
  92228. * @param newVolume Define the new volume of the sound track
  92229. */
  92230. setVolume(newVolume: number): void;
  92231. /**
  92232. * Switch the panning model to HRTF:
  92233. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92235. */
  92236. switchPanningModelToHRTF(): void;
  92237. /**
  92238. * Switch the panning model to Equal Power:
  92239. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92241. */
  92242. switchPanningModelToEqualPower(): void;
  92243. /**
  92244. * Connect the sound track to an audio analyser allowing some amazing
  92245. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92247. * @param analyser The analyser to connect to the engine
  92248. */
  92249. connectToAnalyser(analyser: Analyser): void;
  92250. }
  92251. }
  92252. declare module BABYLON {
  92253. interface AbstractScene {
  92254. /**
  92255. * The list of sounds used in the scene.
  92256. */
  92257. sounds: Nullable<Array<Sound>>;
  92258. }
  92259. interface Scene {
  92260. /**
  92261. * @hidden
  92262. * Backing field
  92263. */
  92264. _mainSoundTrack: SoundTrack;
  92265. /**
  92266. * The main sound track played by the scene.
  92267. * It cotains your primary collection of sounds.
  92268. */
  92269. mainSoundTrack: SoundTrack;
  92270. /**
  92271. * The list of sound tracks added to the scene
  92272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92273. */
  92274. soundTracks: Nullable<Array<SoundTrack>>;
  92275. /**
  92276. * Gets a sound using a given name
  92277. * @param name defines the name to search for
  92278. * @return the found sound or null if not found at all.
  92279. */
  92280. getSoundByName(name: string): Nullable<Sound>;
  92281. /**
  92282. * Gets or sets if audio support is enabled
  92283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92284. */
  92285. audioEnabled: boolean;
  92286. /**
  92287. * Gets or sets if audio will be output to headphones
  92288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92289. */
  92290. headphone: boolean;
  92291. }
  92292. /**
  92293. * Defines the sound scene component responsible to manage any sounds
  92294. * in a given scene.
  92295. */
  92296. export class AudioSceneComponent implements ISceneSerializableComponent {
  92297. /**
  92298. * The component name helpfull to identify the component in the list of scene components.
  92299. */
  92300. readonly name: string;
  92301. /**
  92302. * The scene the component belongs to.
  92303. */
  92304. scene: Scene;
  92305. private _audioEnabled;
  92306. /**
  92307. * Gets whether audio is enabled or not.
  92308. * Please use related enable/disable method to switch state.
  92309. */
  92310. readonly audioEnabled: boolean;
  92311. private _headphone;
  92312. /**
  92313. * Gets whether audio is outputing to headphone or not.
  92314. * Please use the according Switch methods to change output.
  92315. */
  92316. readonly headphone: boolean;
  92317. /**
  92318. * Creates a new instance of the component for the given scene
  92319. * @param scene Defines the scene to register the component in
  92320. */
  92321. constructor(scene: Scene);
  92322. /**
  92323. * Registers the component in a given scene
  92324. */
  92325. register(): void;
  92326. /**
  92327. * Rebuilds the elements related to this component in case of
  92328. * context lost for instance.
  92329. */
  92330. rebuild(): void;
  92331. /**
  92332. * Serializes the component data to the specified json object
  92333. * @param serializationObject The object to serialize to
  92334. */
  92335. serialize(serializationObject: any): void;
  92336. /**
  92337. * Adds all the element from the container to the scene
  92338. * @param container the container holding the elements
  92339. */
  92340. addFromContainer(container: AbstractScene): void;
  92341. /**
  92342. * Removes all the elements in the container from the scene
  92343. * @param container contains the elements to remove
  92344. */
  92345. removeFromContainer(container: AbstractScene): void;
  92346. /**
  92347. * Disposes the component and the associated ressources.
  92348. */
  92349. dispose(): void;
  92350. /**
  92351. * Disables audio in the associated scene.
  92352. */
  92353. disableAudio(): void;
  92354. /**
  92355. * Enables audio in the associated scene.
  92356. */
  92357. enableAudio(): void;
  92358. /**
  92359. * Switch audio to headphone output.
  92360. */
  92361. switchAudioModeForHeadphones(): void;
  92362. /**
  92363. * Switch audio to normal speakers.
  92364. */
  92365. switchAudioModeForNormalSpeakers(): void;
  92366. private _afterRender;
  92367. }
  92368. }
  92369. declare module BABYLON {
  92370. /**
  92371. * Wraps one or more Sound objects and selects one with random weight for playback.
  92372. */
  92373. export class WeightedSound {
  92374. /** When true a Sound will be selected and played when the current playing Sound completes. */
  92375. loop: boolean;
  92376. private _coneInnerAngle;
  92377. private _coneOuterAngle;
  92378. private _volume;
  92379. /** A Sound is currently playing. */
  92380. isPlaying: boolean;
  92381. /** A Sound is currently paused. */
  92382. isPaused: boolean;
  92383. private _sounds;
  92384. private _weights;
  92385. private _currentIndex?;
  92386. /**
  92387. * Creates a new WeightedSound from the list of sounds given.
  92388. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  92389. * @param sounds Array of Sounds that will be selected from.
  92390. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  92391. */
  92392. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  92393. /**
  92394. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  92395. */
  92396. /**
  92397. * The size of cone in degress for a directional sound in which there will be no attenuation.
  92398. */
  92399. directionalConeInnerAngle: number;
  92400. /**
  92401. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92402. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92403. */
  92404. /**
  92405. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92406. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92407. */
  92408. directionalConeOuterAngle: number;
  92409. /**
  92410. * Playback volume.
  92411. */
  92412. /**
  92413. * Playback volume.
  92414. */
  92415. volume: number;
  92416. private _onended;
  92417. /**
  92418. * Suspend playback
  92419. */
  92420. pause(): void;
  92421. /**
  92422. * Stop playback
  92423. */
  92424. stop(): void;
  92425. /**
  92426. * Start playback.
  92427. * @param startOffset Position the clip head at a specific time in seconds.
  92428. */
  92429. play(startOffset?: number): void;
  92430. }
  92431. }
  92432. declare module BABYLON {
  92433. /**
  92434. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  92435. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92436. */
  92437. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  92438. /**
  92439. * Gets the name of the behavior.
  92440. */
  92441. readonly name: string;
  92442. /**
  92443. * The easing function used by animations
  92444. */
  92445. static EasingFunction: BackEase;
  92446. /**
  92447. * The easing mode used by animations
  92448. */
  92449. static EasingMode: number;
  92450. /**
  92451. * The duration of the animation, in milliseconds
  92452. */
  92453. transitionDuration: number;
  92454. /**
  92455. * Length of the distance animated by the transition when lower radius is reached
  92456. */
  92457. lowerRadiusTransitionRange: number;
  92458. /**
  92459. * Length of the distance animated by the transition when upper radius is reached
  92460. */
  92461. upperRadiusTransitionRange: number;
  92462. private _autoTransitionRange;
  92463. /**
  92464. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92465. */
  92466. /**
  92467. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92468. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  92469. */
  92470. autoTransitionRange: boolean;
  92471. private _attachedCamera;
  92472. private _onAfterCheckInputsObserver;
  92473. private _onMeshTargetChangedObserver;
  92474. /**
  92475. * Initializes the behavior.
  92476. */
  92477. init(): void;
  92478. /**
  92479. * Attaches the behavior to its arc rotate camera.
  92480. * @param camera Defines the camera to attach the behavior to
  92481. */
  92482. attach(camera: ArcRotateCamera): void;
  92483. /**
  92484. * Detaches the behavior from its current arc rotate camera.
  92485. */
  92486. detach(): void;
  92487. private _radiusIsAnimating;
  92488. private _radiusBounceTransition;
  92489. private _animatables;
  92490. private _cachedWheelPrecision;
  92491. /**
  92492. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  92493. * @param radiusLimit The limit to check against.
  92494. * @return Bool to indicate if at limit.
  92495. */
  92496. private _isRadiusAtLimit;
  92497. /**
  92498. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  92499. * @param radiusDelta The delta by which to animate to. Can be negative.
  92500. */
  92501. private _applyBoundRadiusAnimation;
  92502. /**
  92503. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  92504. */
  92505. protected _clearAnimationLocks(): void;
  92506. /**
  92507. * Stops and removes all animations that have been applied to the camera
  92508. */
  92509. stopAllAnimations(): void;
  92510. }
  92511. }
  92512. declare module BABYLON {
  92513. /**
  92514. * 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.
  92515. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92516. */
  92517. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  92518. /**
  92519. * Gets the name of the behavior.
  92520. */
  92521. readonly name: string;
  92522. private _mode;
  92523. private _radiusScale;
  92524. private _positionScale;
  92525. private _defaultElevation;
  92526. private _elevationReturnTime;
  92527. private _elevationReturnWaitTime;
  92528. private _zoomStopsAnimation;
  92529. private _framingTime;
  92530. /**
  92531. * The easing function used by animations
  92532. */
  92533. static EasingFunction: ExponentialEase;
  92534. /**
  92535. * The easing mode used by animations
  92536. */
  92537. static EasingMode: number;
  92538. /**
  92539. * Sets the current mode used by the behavior
  92540. */
  92541. /**
  92542. * Gets current mode used by the behavior.
  92543. */
  92544. mode: number;
  92545. /**
  92546. * Sets the scale applied to the radius (1 by default)
  92547. */
  92548. /**
  92549. * Gets the scale applied to the radius
  92550. */
  92551. radiusScale: number;
  92552. /**
  92553. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92554. */
  92555. /**
  92556. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92557. */
  92558. positionScale: number;
  92559. /**
  92560. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92561. * behaviour is triggered, in radians.
  92562. */
  92563. /**
  92564. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92565. * behaviour is triggered, in radians.
  92566. */
  92567. defaultElevation: number;
  92568. /**
  92569. * Sets the time (in milliseconds) taken to return to the default beta position.
  92570. * Negative value indicates camera should not return to default.
  92571. */
  92572. /**
  92573. * Gets the time (in milliseconds) taken to return to the default beta position.
  92574. * Negative value indicates camera should not return to default.
  92575. */
  92576. elevationReturnTime: number;
  92577. /**
  92578. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92579. */
  92580. /**
  92581. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92582. */
  92583. elevationReturnWaitTime: number;
  92584. /**
  92585. * Sets the flag that indicates if user zooming should stop animation.
  92586. */
  92587. /**
  92588. * Gets the flag that indicates if user zooming should stop animation.
  92589. */
  92590. zoomStopsAnimation: boolean;
  92591. /**
  92592. * Sets the transition time when framing the mesh, in milliseconds
  92593. */
  92594. /**
  92595. * Gets the transition time when framing the mesh, in milliseconds
  92596. */
  92597. framingTime: number;
  92598. /**
  92599. * Define if the behavior should automatically change the configured
  92600. * camera limits and sensibilities.
  92601. */
  92602. autoCorrectCameraLimitsAndSensibility: boolean;
  92603. private _onPrePointerObservableObserver;
  92604. private _onAfterCheckInputsObserver;
  92605. private _onMeshTargetChangedObserver;
  92606. private _attachedCamera;
  92607. private _isPointerDown;
  92608. private _lastInteractionTime;
  92609. /**
  92610. * Initializes the behavior.
  92611. */
  92612. init(): void;
  92613. /**
  92614. * Attaches the behavior to its arc rotate camera.
  92615. * @param camera Defines the camera to attach the behavior to
  92616. */
  92617. attach(camera: ArcRotateCamera): void;
  92618. /**
  92619. * Detaches the behavior from its current arc rotate camera.
  92620. */
  92621. detach(): void;
  92622. private _animatables;
  92623. private _betaIsAnimating;
  92624. private _betaTransition;
  92625. private _radiusTransition;
  92626. private _vectorTransition;
  92627. /**
  92628. * Targets the given mesh and updates zoom level accordingly.
  92629. * @param mesh The mesh to target.
  92630. * @param radius Optional. If a cached radius position already exists, overrides default.
  92631. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92632. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92633. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92634. */
  92635. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92636. /**
  92637. * Targets the given mesh with its children and updates zoom level accordingly.
  92638. * @param mesh The mesh to target.
  92639. * @param radius Optional. If a cached radius position already exists, overrides default.
  92640. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92641. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92642. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92643. */
  92644. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92645. /**
  92646. * Targets the given meshes with their children and updates zoom level accordingly.
  92647. * @param meshes The mesh to target.
  92648. * @param radius Optional. If a cached radius position already exists, overrides default.
  92649. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92650. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92651. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92652. */
  92653. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92654. /**
  92655. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  92656. * @param minimumWorld Determines the smaller position of the bounding box extend
  92657. * @param maximumWorld Determines the bigger position of the bounding box extend
  92658. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92659. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92660. */
  92661. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92662. /**
  92663. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  92664. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  92665. * frustum width.
  92666. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  92667. * to fully enclose the mesh in the viewing frustum.
  92668. */
  92669. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  92670. /**
  92671. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  92672. * is automatically returned to its default position (expected to be above ground plane).
  92673. */
  92674. private _maintainCameraAboveGround;
  92675. /**
  92676. * Returns the frustum slope based on the canvas ratio and camera FOV
  92677. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  92678. */
  92679. private _getFrustumSlope;
  92680. /**
  92681. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  92682. */
  92683. private _clearAnimationLocks;
  92684. /**
  92685. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92686. */
  92687. private _applyUserInteraction;
  92688. /**
  92689. * Stops and removes all animations that have been applied to the camera
  92690. */
  92691. stopAllAnimations(): void;
  92692. /**
  92693. * Gets a value indicating if the user is moving the camera
  92694. */
  92695. readonly isUserIsMoving: boolean;
  92696. /**
  92697. * The camera can move all the way towards the mesh.
  92698. */
  92699. static IgnoreBoundsSizeMode: number;
  92700. /**
  92701. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  92702. */
  92703. static FitFrustumSidesMode: number;
  92704. }
  92705. }
  92706. declare module BABYLON {
  92707. /**
  92708. * Base class for Camera Pointer Inputs.
  92709. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  92710. * for example usage.
  92711. */
  92712. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  92713. /**
  92714. * Defines the camera the input is attached to.
  92715. */
  92716. abstract camera: Camera;
  92717. /**
  92718. * Whether keyboard modifier keys are pressed at time of last mouse event.
  92719. */
  92720. protected _altKey: boolean;
  92721. protected _ctrlKey: boolean;
  92722. protected _metaKey: boolean;
  92723. protected _shiftKey: boolean;
  92724. /**
  92725. * Which mouse buttons were pressed at time of last mouse event.
  92726. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  92727. */
  92728. protected _buttonsPressed: number;
  92729. /**
  92730. * Defines the buttons associated with the input to handle camera move.
  92731. */
  92732. buttons: number[];
  92733. /**
  92734. * Attach the input controls to a specific dom element to get the input from.
  92735. * @param element Defines the element the controls should be listened from
  92736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92737. */
  92738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92739. /**
  92740. * Detach the current controls from the specified dom element.
  92741. * @param element Defines the element to stop listening the inputs from
  92742. */
  92743. detachControl(element: Nullable<HTMLElement>): void;
  92744. /**
  92745. * Gets the class name of the current input.
  92746. * @returns the class name
  92747. */
  92748. getClassName(): string;
  92749. /**
  92750. * Get the friendly name associated with the input class.
  92751. * @returns the input friendly name
  92752. */
  92753. getSimpleName(): string;
  92754. /**
  92755. * Called on pointer POINTERDOUBLETAP event.
  92756. * Override this method to provide functionality on POINTERDOUBLETAP event.
  92757. */
  92758. protected onDoubleTap(type: string): void;
  92759. /**
  92760. * Called on pointer POINTERMOVE event if only a single touch is active.
  92761. * Override this method to provide functionality.
  92762. */
  92763. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92764. /**
  92765. * Called on pointer POINTERMOVE event if multiple touches are active.
  92766. * Override this method to provide functionality.
  92767. */
  92768. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92769. /**
  92770. * Called on JS contextmenu event.
  92771. * Override this method to provide functionality.
  92772. */
  92773. protected onContextMenu(evt: PointerEvent): void;
  92774. /**
  92775. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92776. * press.
  92777. * Override this method to provide functionality.
  92778. */
  92779. protected onButtonDown(evt: PointerEvent): void;
  92780. /**
  92781. * Called each time a new POINTERUP event occurs. Ie, for each button
  92782. * release.
  92783. * Override this method to provide functionality.
  92784. */
  92785. protected onButtonUp(evt: PointerEvent): void;
  92786. /**
  92787. * Called when window becomes inactive.
  92788. * Override this method to provide functionality.
  92789. */
  92790. protected onLostFocus(): void;
  92791. private _pointerInput;
  92792. private _observer;
  92793. private _onLostFocus;
  92794. private pointA;
  92795. private pointB;
  92796. }
  92797. }
  92798. declare module BABYLON {
  92799. /**
  92800. * Manage the pointers inputs to control an arc rotate camera.
  92801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92802. */
  92803. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  92804. /**
  92805. * Defines the camera the input is attached to.
  92806. */
  92807. camera: ArcRotateCamera;
  92808. /**
  92809. * Gets the class name of the current input.
  92810. * @returns the class name
  92811. */
  92812. getClassName(): string;
  92813. /**
  92814. * Defines the buttons associated with the input to handle camera move.
  92815. */
  92816. buttons: number[];
  92817. /**
  92818. * Defines the pointer angular sensibility along the X axis or how fast is
  92819. * the camera rotating.
  92820. */
  92821. angularSensibilityX: number;
  92822. /**
  92823. * Defines the pointer angular sensibility along the Y axis or how fast is
  92824. * the camera rotating.
  92825. */
  92826. angularSensibilityY: number;
  92827. /**
  92828. * Defines the pointer pinch precision or how fast is the camera zooming.
  92829. */
  92830. pinchPrecision: number;
  92831. /**
  92832. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  92833. * from 0.
  92834. * It defines the percentage of current camera.radius to use as delta when
  92835. * pinch zoom is used.
  92836. */
  92837. pinchDeltaPercentage: number;
  92838. /**
  92839. * Defines the pointer panning sensibility or how fast is the camera moving.
  92840. */
  92841. panningSensibility: number;
  92842. /**
  92843. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  92844. */
  92845. multiTouchPanning: boolean;
  92846. /**
  92847. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  92848. * zoom (pinch) through multitouch.
  92849. */
  92850. multiTouchPanAndZoom: boolean;
  92851. /**
  92852. * Revers pinch action direction.
  92853. */
  92854. pinchInwards: boolean;
  92855. private _isPanClick;
  92856. private _twoFingerActivityCount;
  92857. private _isPinching;
  92858. /**
  92859. * Called on pointer POINTERMOVE event if only a single touch is active.
  92860. */
  92861. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92862. /**
  92863. * Called on pointer POINTERDOUBLETAP event.
  92864. */
  92865. protected onDoubleTap(type: string): void;
  92866. /**
  92867. * Called on pointer POINTERMOVE event if multiple touches are active.
  92868. */
  92869. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92870. /**
  92871. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92872. * press.
  92873. */
  92874. protected onButtonDown(evt: PointerEvent): void;
  92875. /**
  92876. * Called each time a new POINTERUP event occurs. Ie, for each button
  92877. * release.
  92878. */
  92879. protected onButtonUp(evt: PointerEvent): void;
  92880. /**
  92881. * Called when window becomes inactive.
  92882. */
  92883. protected onLostFocus(): void;
  92884. }
  92885. }
  92886. declare module BABYLON {
  92887. /**
  92888. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  92889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92890. */
  92891. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  92892. /**
  92893. * Defines the camera the input is attached to.
  92894. */
  92895. camera: ArcRotateCamera;
  92896. /**
  92897. * Defines the list of key codes associated with the up action (increase alpha)
  92898. */
  92899. keysUp: number[];
  92900. /**
  92901. * Defines the list of key codes associated with the down action (decrease alpha)
  92902. */
  92903. keysDown: number[];
  92904. /**
  92905. * Defines the list of key codes associated with the left action (increase beta)
  92906. */
  92907. keysLeft: number[];
  92908. /**
  92909. * Defines the list of key codes associated with the right action (decrease beta)
  92910. */
  92911. keysRight: number[];
  92912. /**
  92913. * Defines the list of key codes associated with the reset action.
  92914. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  92915. */
  92916. keysReset: number[];
  92917. /**
  92918. * Defines the panning sensibility of the inputs.
  92919. * (How fast is the camera paning)
  92920. */
  92921. panningSensibility: number;
  92922. /**
  92923. * Defines the zooming sensibility of the inputs.
  92924. * (How fast is the camera zooming)
  92925. */
  92926. zoomingSensibility: number;
  92927. /**
  92928. * Defines wether maintaining the alt key down switch the movement mode from
  92929. * orientation to zoom.
  92930. */
  92931. useAltToZoom: boolean;
  92932. /**
  92933. * Rotation speed of the camera
  92934. */
  92935. angularSpeed: number;
  92936. private _keys;
  92937. private _ctrlPressed;
  92938. private _altPressed;
  92939. private _onCanvasBlurObserver;
  92940. private _onKeyboardObserver;
  92941. private _engine;
  92942. private _scene;
  92943. /**
  92944. * Attach the input controls to a specific dom element to get the input from.
  92945. * @param element Defines the element the controls should be listened from
  92946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92947. */
  92948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92949. /**
  92950. * Detach the current controls from the specified dom element.
  92951. * @param element Defines the element to stop listening the inputs from
  92952. */
  92953. detachControl(element: Nullable<HTMLElement>): void;
  92954. /**
  92955. * Update the current camera state depending on the inputs that have been used this frame.
  92956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92957. */
  92958. checkInputs(): void;
  92959. /**
  92960. * Gets the class name of the current intput.
  92961. * @returns the class name
  92962. */
  92963. getClassName(): string;
  92964. /**
  92965. * Get the friendly name associated with the input class.
  92966. * @returns the input friendly name
  92967. */
  92968. getSimpleName(): string;
  92969. }
  92970. }
  92971. declare module BABYLON {
  92972. /**
  92973. * Manage the mouse wheel inputs to control an arc rotate camera.
  92974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92975. */
  92976. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  92977. /**
  92978. * Defines the camera the input is attached to.
  92979. */
  92980. camera: ArcRotateCamera;
  92981. /**
  92982. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92983. */
  92984. wheelPrecision: number;
  92985. /**
  92986. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92987. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92988. */
  92989. wheelDeltaPercentage: number;
  92990. private _wheel;
  92991. private _observer;
  92992. /**
  92993. * Attach the input controls to a specific dom element to get the input from.
  92994. * @param element Defines the element the controls should be listened from
  92995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92996. */
  92997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92998. /**
  92999. * Detach the current controls from the specified dom element.
  93000. * @param element Defines the element to stop listening the inputs from
  93001. */
  93002. detachControl(element: Nullable<HTMLElement>): void;
  93003. /**
  93004. * Gets the class name of the current intput.
  93005. * @returns the class name
  93006. */
  93007. getClassName(): string;
  93008. /**
  93009. * Get the friendly name associated with the input class.
  93010. * @returns the input friendly name
  93011. */
  93012. getSimpleName(): string;
  93013. }
  93014. }
  93015. declare module BABYLON {
  93016. /**
  93017. * Default Inputs manager for the ArcRotateCamera.
  93018. * It groups all the default supported inputs for ease of use.
  93019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93020. */
  93021. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  93022. /**
  93023. * Instantiates a new ArcRotateCameraInputsManager.
  93024. * @param camera Defines the camera the inputs belong to
  93025. */
  93026. constructor(camera: ArcRotateCamera);
  93027. /**
  93028. * Add mouse wheel input support to the input manager.
  93029. * @returns the current input manager
  93030. */
  93031. addMouseWheel(): ArcRotateCameraInputsManager;
  93032. /**
  93033. * Add pointers input support to the input manager.
  93034. * @returns the current input manager
  93035. */
  93036. addPointers(): ArcRotateCameraInputsManager;
  93037. /**
  93038. * Add keyboard input support to the input manager.
  93039. * @returns the current input manager
  93040. */
  93041. addKeyboard(): ArcRotateCameraInputsManager;
  93042. }
  93043. }
  93044. declare module BABYLON {
  93045. /**
  93046. * This represents an orbital type of camera.
  93047. *
  93048. * 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.
  93049. * 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.
  93050. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  93051. */
  93052. export class ArcRotateCamera extends TargetCamera {
  93053. /**
  93054. * Defines the rotation angle of the camera along the longitudinal axis.
  93055. */
  93056. alpha: number;
  93057. /**
  93058. * Defines the rotation angle of the camera along the latitudinal axis.
  93059. */
  93060. beta: number;
  93061. /**
  93062. * Defines the radius of the camera from it s target point.
  93063. */
  93064. radius: number;
  93065. protected _target: Vector3;
  93066. protected _targetHost: Nullable<AbstractMesh>;
  93067. /**
  93068. * Defines the target point of the camera.
  93069. * The camera looks towards it form the radius distance.
  93070. */
  93071. target: Vector3;
  93072. /**
  93073. * Define the current local position of the camera in the scene
  93074. */
  93075. position: Vector3;
  93076. /**
  93077. * Current inertia value on the longitudinal axis.
  93078. * The bigger this number the longer it will take for the camera to stop.
  93079. */
  93080. inertialAlphaOffset: number;
  93081. /**
  93082. * Current inertia value on the latitudinal axis.
  93083. * The bigger this number the longer it will take for the camera to stop.
  93084. */
  93085. inertialBetaOffset: number;
  93086. /**
  93087. * Current inertia value on the radius axis.
  93088. * The bigger this number the longer it will take for the camera to stop.
  93089. */
  93090. inertialRadiusOffset: number;
  93091. /**
  93092. * Minimum allowed angle on the longitudinal axis.
  93093. * This can help limiting how the Camera is able to move in the scene.
  93094. */
  93095. lowerAlphaLimit: Nullable<number>;
  93096. /**
  93097. * Maximum allowed angle on the longitudinal axis.
  93098. * This can help limiting how the Camera is able to move in the scene.
  93099. */
  93100. upperAlphaLimit: Nullable<number>;
  93101. /**
  93102. * Minimum allowed angle on the latitudinal axis.
  93103. * This can help limiting how the Camera is able to move in the scene.
  93104. */
  93105. lowerBetaLimit: number;
  93106. /**
  93107. * Maximum allowed angle on the latitudinal axis.
  93108. * This can help limiting how the Camera is able to move in the scene.
  93109. */
  93110. upperBetaLimit: number;
  93111. /**
  93112. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  93113. * This can help limiting how the Camera is able to move in the scene.
  93114. */
  93115. lowerRadiusLimit: Nullable<number>;
  93116. /**
  93117. * Maximum allowed distance of the camera to the target (The camera can not get further).
  93118. * This can help limiting how the Camera is able to move in the scene.
  93119. */
  93120. upperRadiusLimit: Nullable<number>;
  93121. /**
  93122. * Defines the current inertia value used during panning of the camera along the X axis.
  93123. */
  93124. inertialPanningX: number;
  93125. /**
  93126. * Defines the current inertia value used during panning of the camera along the Y axis.
  93127. */
  93128. inertialPanningY: number;
  93129. /**
  93130. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  93131. * Basically if your fingers moves away from more than this distance you will be considered
  93132. * in pinch mode.
  93133. */
  93134. pinchToPanMaxDistance: number;
  93135. /**
  93136. * Defines the maximum distance the camera can pan.
  93137. * This could help keeping the cammera always in your scene.
  93138. */
  93139. panningDistanceLimit: Nullable<number>;
  93140. /**
  93141. * Defines the target of the camera before paning.
  93142. */
  93143. panningOriginTarget: Vector3;
  93144. /**
  93145. * Defines the value of the inertia used during panning.
  93146. * 0 would mean stop inertia and one would mean no decelleration at all.
  93147. */
  93148. panningInertia: number;
  93149. /**
  93150. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  93151. */
  93152. angularSensibilityX: number;
  93153. /**
  93154. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  93155. */
  93156. angularSensibilityY: number;
  93157. /**
  93158. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  93159. */
  93160. pinchPrecision: number;
  93161. /**
  93162. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  93163. * It will be used instead of pinchDeltaPrecision if different from 0.
  93164. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93165. */
  93166. pinchDeltaPercentage: number;
  93167. /**
  93168. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  93169. */
  93170. panningSensibility: number;
  93171. /**
  93172. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  93173. */
  93174. keysUp: number[];
  93175. /**
  93176. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  93177. */
  93178. keysDown: number[];
  93179. /**
  93180. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  93181. */
  93182. keysLeft: number[];
  93183. /**
  93184. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  93185. */
  93186. keysRight: number[];
  93187. /**
  93188. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93189. */
  93190. wheelPrecision: number;
  93191. /**
  93192. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  93193. * It will be used instead of pinchDeltaPrecision if different from 0.
  93194. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93195. */
  93196. wheelDeltaPercentage: number;
  93197. /**
  93198. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  93199. */
  93200. zoomOnFactor: number;
  93201. /**
  93202. * Defines a screen offset for the camera position.
  93203. */
  93204. targetScreenOffset: Vector2;
  93205. /**
  93206. * Allows the camera to be completely reversed.
  93207. * If false the camera can not arrive upside down.
  93208. */
  93209. allowUpsideDown: boolean;
  93210. /**
  93211. * Define if double tap/click is used to restore the previously saved state of the camera.
  93212. */
  93213. useInputToRestoreState: boolean;
  93214. /** @hidden */
  93215. _viewMatrix: Matrix;
  93216. /** @hidden */
  93217. _useCtrlForPanning: boolean;
  93218. /** @hidden */
  93219. _panningMouseButton: number;
  93220. /**
  93221. * Defines the input associated to the camera.
  93222. */
  93223. inputs: ArcRotateCameraInputsManager;
  93224. /** @hidden */
  93225. _reset: () => void;
  93226. /**
  93227. * Defines the allowed panning axis.
  93228. */
  93229. panningAxis: Vector3;
  93230. protected _localDirection: Vector3;
  93231. protected _transformedDirection: Vector3;
  93232. private _bouncingBehavior;
  93233. /**
  93234. * Gets the bouncing behavior of the camera if it has been enabled.
  93235. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93236. */
  93237. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  93238. /**
  93239. * Defines if the bouncing behavior of the camera is enabled on the camera.
  93240. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93241. */
  93242. useBouncingBehavior: boolean;
  93243. private _framingBehavior;
  93244. /**
  93245. * Gets the framing behavior of the camera if it has been enabled.
  93246. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93247. */
  93248. readonly framingBehavior: Nullable<FramingBehavior>;
  93249. /**
  93250. * Defines if the framing behavior of the camera is enabled on the camera.
  93251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93252. */
  93253. useFramingBehavior: boolean;
  93254. private _autoRotationBehavior;
  93255. /**
  93256. * Gets the auto rotation behavior of the camera if it has been enabled.
  93257. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93258. */
  93259. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  93260. /**
  93261. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  93262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93263. */
  93264. useAutoRotationBehavior: boolean;
  93265. /**
  93266. * Observable triggered when the mesh target has been changed on the camera.
  93267. */
  93268. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  93269. /**
  93270. * Event raised when the camera is colliding with a mesh.
  93271. */
  93272. onCollide: (collidedMesh: AbstractMesh) => void;
  93273. /**
  93274. * Defines whether the camera should check collision with the objects oh the scene.
  93275. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  93276. */
  93277. checkCollisions: boolean;
  93278. /**
  93279. * Defines the collision radius of the camera.
  93280. * This simulates a sphere around the camera.
  93281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93282. */
  93283. collisionRadius: Vector3;
  93284. protected _collider: Collider;
  93285. protected _previousPosition: Vector3;
  93286. protected _collisionVelocity: Vector3;
  93287. protected _newPosition: Vector3;
  93288. protected _previousAlpha: number;
  93289. protected _previousBeta: number;
  93290. protected _previousRadius: number;
  93291. protected _collisionTriggered: boolean;
  93292. protected _targetBoundingCenter: Nullable<Vector3>;
  93293. private _computationVector;
  93294. private _tempAxisVector;
  93295. private _tempAxisRotationMatrix;
  93296. /**
  93297. * Instantiates a new ArcRotateCamera in a given scene
  93298. * @param name Defines the name of the camera
  93299. * @param alpha Defines the camera rotation along the logitudinal axis
  93300. * @param beta Defines the camera rotation along the latitudinal axis
  93301. * @param radius Defines the camera distance from its target
  93302. * @param target Defines the camera target
  93303. * @param scene Defines the scene the camera belongs to
  93304. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  93305. */
  93306. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93307. /** @hidden */
  93308. _initCache(): void;
  93309. /** @hidden */
  93310. _updateCache(ignoreParentClass?: boolean): void;
  93311. protected _getTargetPosition(): Vector3;
  93312. private _storedAlpha;
  93313. private _storedBeta;
  93314. private _storedRadius;
  93315. private _storedTarget;
  93316. /**
  93317. * Stores the current state of the camera (alpha, beta, radius and target)
  93318. * @returns the camera itself
  93319. */
  93320. storeState(): Camera;
  93321. /**
  93322. * @hidden
  93323. * Restored camera state. You must call storeState() first
  93324. */
  93325. _restoreStateValues(): boolean;
  93326. /** @hidden */
  93327. _isSynchronizedViewMatrix(): boolean;
  93328. /**
  93329. * Attached controls to the current camera.
  93330. * @param element Defines the element the controls should be listened from
  93331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93332. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  93333. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  93334. */
  93335. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  93336. /**
  93337. * Detach the current controls from the camera.
  93338. * The camera will stop reacting to inputs.
  93339. * @param element Defines the element to stop listening the inputs from
  93340. */
  93341. detachControl(element: HTMLElement): void;
  93342. /** @hidden */
  93343. _checkInputs(): void;
  93344. protected _checkLimits(): void;
  93345. /**
  93346. * Rebuilds angles (alpha, beta) and radius from the give position and target
  93347. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  93348. */
  93349. rebuildAnglesAndRadius(updateView?: boolean): void;
  93350. /**
  93351. * Use a position to define the current camera related information like aplha, beta and radius
  93352. * @param position Defines the position to set the camera at
  93353. */
  93354. setPosition(position: Vector3): void;
  93355. /**
  93356. * Defines the target the camera should look at.
  93357. * This will automatically adapt alpha beta and radius to fit within the new target.
  93358. * @param target Defines the new target as a Vector or a mesh
  93359. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  93360. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  93361. */
  93362. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  93363. /** @hidden */
  93364. _getViewMatrix(): Matrix;
  93365. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  93366. /**
  93367. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  93368. * @param meshes Defines the mesh to zoom on
  93369. * @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)
  93370. */
  93371. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  93372. /**
  93373. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  93374. * The target will be changed but the radius
  93375. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  93376. * @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)
  93377. */
  93378. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  93379. min: Vector3;
  93380. max: Vector3;
  93381. distance: number;
  93382. }, doNotUpdateMaxZ?: boolean): void;
  93383. /**
  93384. * @override
  93385. * Override Camera.createRigCamera
  93386. */
  93387. createRigCamera(name: string, cameraIndex: number): Camera;
  93388. /**
  93389. * @hidden
  93390. * @override
  93391. * Override Camera._updateRigCameras
  93392. */
  93393. _updateRigCameras(): void;
  93394. /**
  93395. * Destroy the camera and release the current resources hold by it.
  93396. */
  93397. dispose(): void;
  93398. /**
  93399. * Gets the current object class name.
  93400. * @return the class name
  93401. */
  93402. getClassName(): string;
  93403. }
  93404. }
  93405. declare module BABYLON {
  93406. /**
  93407. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  93408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93409. */
  93410. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  93411. /**
  93412. * Gets the name of the behavior.
  93413. */
  93414. readonly name: string;
  93415. private _zoomStopsAnimation;
  93416. private _idleRotationSpeed;
  93417. private _idleRotationWaitTime;
  93418. private _idleRotationSpinupTime;
  93419. /**
  93420. * Sets the flag that indicates if user zooming should stop animation.
  93421. */
  93422. /**
  93423. * Gets the flag that indicates if user zooming should stop animation.
  93424. */
  93425. zoomStopsAnimation: boolean;
  93426. /**
  93427. * Sets the default speed at which the camera rotates around the model.
  93428. */
  93429. /**
  93430. * Gets the default speed at which the camera rotates around the model.
  93431. */
  93432. idleRotationSpeed: number;
  93433. /**
  93434. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  93435. */
  93436. /**
  93437. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  93438. */
  93439. idleRotationWaitTime: number;
  93440. /**
  93441. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93442. */
  93443. /**
  93444. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93445. */
  93446. idleRotationSpinupTime: number;
  93447. /**
  93448. * Gets a value indicating if the camera is currently rotating because of this behavior
  93449. */
  93450. readonly rotationInProgress: boolean;
  93451. private _onPrePointerObservableObserver;
  93452. private _onAfterCheckInputsObserver;
  93453. private _attachedCamera;
  93454. private _isPointerDown;
  93455. private _lastFrameTime;
  93456. private _lastInteractionTime;
  93457. private _cameraRotationSpeed;
  93458. /**
  93459. * Initializes the behavior.
  93460. */
  93461. init(): void;
  93462. /**
  93463. * Attaches the behavior to its arc rotate camera.
  93464. * @param camera Defines the camera to attach the behavior to
  93465. */
  93466. attach(camera: ArcRotateCamera): void;
  93467. /**
  93468. * Detaches the behavior from its current arc rotate camera.
  93469. */
  93470. detach(): void;
  93471. /**
  93472. * Returns true if user is scrolling.
  93473. * @return true if user is scrolling.
  93474. */
  93475. private _userIsZooming;
  93476. private _lastFrameRadius;
  93477. private _shouldAnimationStopForInteraction;
  93478. /**
  93479. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93480. */
  93481. private _applyUserInteraction;
  93482. private _userIsMoving;
  93483. }
  93484. }
  93485. declare module BABYLON {
  93486. /**
  93487. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  93488. */
  93489. export class AttachToBoxBehavior implements Behavior<Mesh> {
  93490. private ui;
  93491. /**
  93492. * The name of the behavior
  93493. */
  93494. name: string;
  93495. /**
  93496. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  93497. */
  93498. distanceAwayFromFace: number;
  93499. /**
  93500. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  93501. */
  93502. distanceAwayFromBottomOfFace: number;
  93503. private _faceVectors;
  93504. private _target;
  93505. private _scene;
  93506. private _onRenderObserver;
  93507. private _tmpMatrix;
  93508. private _tmpVector;
  93509. /**
  93510. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  93511. * @param ui The transform node that should be attched to the mesh
  93512. */
  93513. constructor(ui: TransformNode);
  93514. /**
  93515. * Initializes the behavior
  93516. */
  93517. init(): void;
  93518. private _closestFace;
  93519. private _zeroVector;
  93520. private _lookAtTmpMatrix;
  93521. private _lookAtToRef;
  93522. /**
  93523. * Attaches the AttachToBoxBehavior to the passed in mesh
  93524. * @param target The mesh that the specified node will be attached to
  93525. */
  93526. attach(target: Mesh): void;
  93527. /**
  93528. * Detaches the behavior from the mesh
  93529. */
  93530. detach(): void;
  93531. }
  93532. }
  93533. declare module BABYLON {
  93534. /**
  93535. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  93536. */
  93537. export class FadeInOutBehavior implements Behavior<Mesh> {
  93538. /**
  93539. * Time in milliseconds to delay before fading in (Default: 0)
  93540. */
  93541. delay: number;
  93542. /**
  93543. * Time in milliseconds for the mesh to fade in (Default: 300)
  93544. */
  93545. fadeInTime: number;
  93546. private _millisecondsPerFrame;
  93547. private _hovered;
  93548. private _hoverValue;
  93549. private _ownerNode;
  93550. /**
  93551. * Instatiates the FadeInOutBehavior
  93552. */
  93553. constructor();
  93554. /**
  93555. * The name of the behavior
  93556. */
  93557. readonly name: string;
  93558. /**
  93559. * Initializes the behavior
  93560. */
  93561. init(): void;
  93562. /**
  93563. * Attaches the fade behavior on the passed in mesh
  93564. * @param ownerNode The mesh that will be faded in/out once attached
  93565. */
  93566. attach(ownerNode: Mesh): void;
  93567. /**
  93568. * Detaches the behavior from the mesh
  93569. */
  93570. detach(): void;
  93571. /**
  93572. * Triggers the mesh to begin fading in or out
  93573. * @param value if the object should fade in or out (true to fade in)
  93574. */
  93575. fadeIn(value: boolean): void;
  93576. private _update;
  93577. private _setAllVisibility;
  93578. }
  93579. }
  93580. declare module BABYLON {
  93581. /**
  93582. * Class containing a set of static utilities functions for managing Pivots
  93583. * @hidden
  93584. */
  93585. export class PivotTools {
  93586. private static _PivotCached;
  93587. private static _OldPivotPoint;
  93588. private static _PivotTranslation;
  93589. private static _PivotTmpVector;
  93590. /** @hidden */
  93591. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  93592. /** @hidden */
  93593. static _RestorePivotPoint(mesh: AbstractMesh): void;
  93594. }
  93595. }
  93596. declare module BABYLON {
  93597. /**
  93598. * Class containing static functions to help procedurally build meshes
  93599. */
  93600. export class PlaneBuilder {
  93601. /**
  93602. * Creates a plane mesh
  93603. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  93604. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  93605. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  93606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93609. * @param name defines the name of the mesh
  93610. * @param options defines the options used to create the mesh
  93611. * @param scene defines the hosting scene
  93612. * @returns the plane mesh
  93613. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  93614. */
  93615. static CreatePlane(name: string, options: {
  93616. size?: number;
  93617. width?: number;
  93618. height?: number;
  93619. sideOrientation?: number;
  93620. frontUVs?: Vector4;
  93621. backUVs?: Vector4;
  93622. updatable?: boolean;
  93623. sourcePlane?: Plane;
  93624. }, scene: Scene): Mesh;
  93625. }
  93626. }
  93627. declare module BABYLON {
  93628. /**
  93629. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  93630. */
  93631. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  93632. private static _AnyMouseID;
  93633. private _attachedNode;
  93634. private _dragPlane;
  93635. private _scene;
  93636. private _pointerObserver;
  93637. private _beforeRenderObserver;
  93638. private static _planeScene;
  93639. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  93640. /**
  93641. * 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)
  93642. */
  93643. maxDragAngle: number;
  93644. /**
  93645. * @hidden
  93646. */
  93647. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  93648. /**
  93649. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93650. */
  93651. currentDraggingPointerID: number;
  93652. /**
  93653. * The last position where the pointer hit the drag plane in world space
  93654. */
  93655. lastDragPosition: Vector3;
  93656. /**
  93657. * If the behavior is currently in a dragging state
  93658. */
  93659. dragging: boolean;
  93660. /**
  93661. * 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)
  93662. */
  93663. dragDeltaRatio: number;
  93664. /**
  93665. * If the drag plane orientation should be updated during the dragging (Default: true)
  93666. */
  93667. updateDragPlane: boolean;
  93668. private _debugMode;
  93669. private _moving;
  93670. /**
  93671. * Fires each time the attached mesh is dragged with the pointer
  93672. * * delta between last drag position and current drag position in world space
  93673. * * dragDistance along the drag axis
  93674. * * dragPlaneNormal normal of the current drag plane used during the drag
  93675. * * dragPlanePoint in world space where the drag intersects the drag plane
  93676. */
  93677. onDragObservable: Observable<{
  93678. delta: Vector3;
  93679. dragPlanePoint: Vector3;
  93680. dragPlaneNormal: Vector3;
  93681. dragDistance: number;
  93682. pointerId: number;
  93683. }>;
  93684. /**
  93685. * Fires each time a drag begins (eg. mouse down on mesh)
  93686. */
  93687. onDragStartObservable: Observable<{
  93688. dragPlanePoint: Vector3;
  93689. pointerId: number;
  93690. }>;
  93691. /**
  93692. * Fires each time a drag ends (eg. mouse release after drag)
  93693. */
  93694. onDragEndObservable: Observable<{
  93695. dragPlanePoint: Vector3;
  93696. pointerId: number;
  93697. }>;
  93698. /**
  93699. * If the attached mesh should be moved when dragged
  93700. */
  93701. moveAttached: boolean;
  93702. /**
  93703. * If the drag behavior will react to drag events (Default: true)
  93704. */
  93705. enabled: boolean;
  93706. /**
  93707. * If camera controls should be detached during the drag
  93708. */
  93709. detachCameraControls: boolean;
  93710. /**
  93711. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  93712. */
  93713. useObjectOrienationForDragging: boolean;
  93714. private _options;
  93715. /**
  93716. * Creates a pointer drag behavior that can be attached to a mesh
  93717. * @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)
  93718. */
  93719. constructor(options?: {
  93720. dragAxis?: Vector3;
  93721. dragPlaneNormal?: Vector3;
  93722. });
  93723. /**
  93724. * Predicate to determine if it is valid to move the object to a new position when it is moved
  93725. */
  93726. validateDrag: (targetPosition: Vector3) => boolean;
  93727. /**
  93728. * The name of the behavior
  93729. */
  93730. readonly name: string;
  93731. /**
  93732. * Initializes the behavior
  93733. */
  93734. init(): void;
  93735. private _tmpVector;
  93736. private _alternatePickedPoint;
  93737. private _worldDragAxis;
  93738. private _targetPosition;
  93739. private _attachedElement;
  93740. /**
  93741. * Attaches the drag behavior the passed in mesh
  93742. * @param ownerNode The mesh that will be dragged around once attached
  93743. */
  93744. attach(ownerNode: AbstractMesh): void;
  93745. /**
  93746. * Force relase the drag action by code.
  93747. */
  93748. releaseDrag(): void;
  93749. private _startDragRay;
  93750. private _lastPointerRay;
  93751. /**
  93752. * Simulates the start of a pointer drag event on the behavior
  93753. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  93754. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  93755. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  93756. */
  93757. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  93758. private _startDrag;
  93759. private _dragDelta;
  93760. private _moveDrag;
  93761. private _pickWithRayOnDragPlane;
  93762. private _pointA;
  93763. private _pointB;
  93764. private _pointC;
  93765. private _lineA;
  93766. private _lineB;
  93767. private _localAxis;
  93768. private _lookAt;
  93769. private _updateDragPlanePosition;
  93770. /**
  93771. * Detaches the behavior from the mesh
  93772. */
  93773. detach(): void;
  93774. }
  93775. }
  93776. declare module BABYLON {
  93777. /**
  93778. * A behavior that when attached to a mesh will allow the mesh to be scaled
  93779. */
  93780. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  93781. private _dragBehaviorA;
  93782. private _dragBehaviorB;
  93783. private _startDistance;
  93784. private _initialScale;
  93785. private _targetScale;
  93786. private _ownerNode;
  93787. private _sceneRenderObserver;
  93788. /**
  93789. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  93790. */
  93791. constructor();
  93792. /**
  93793. * The name of the behavior
  93794. */
  93795. readonly name: string;
  93796. /**
  93797. * Initializes the behavior
  93798. */
  93799. init(): void;
  93800. private _getCurrentDistance;
  93801. /**
  93802. * Attaches the scale behavior the passed in mesh
  93803. * @param ownerNode The mesh that will be scaled around once attached
  93804. */
  93805. attach(ownerNode: Mesh): void;
  93806. /**
  93807. * Detaches the behavior from the mesh
  93808. */
  93809. detach(): void;
  93810. }
  93811. }
  93812. declare module BABYLON {
  93813. /**
  93814. * 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
  93815. */
  93816. export class SixDofDragBehavior implements Behavior<Mesh> {
  93817. private static _virtualScene;
  93818. private _ownerNode;
  93819. private _sceneRenderObserver;
  93820. private _scene;
  93821. private _targetPosition;
  93822. private _virtualOriginMesh;
  93823. private _virtualDragMesh;
  93824. private _pointerObserver;
  93825. private _moving;
  93826. private _startingOrientation;
  93827. /**
  93828. * 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)
  93829. */
  93830. private zDragFactor;
  93831. /**
  93832. * If the object should rotate to face the drag origin
  93833. */
  93834. rotateDraggedObject: boolean;
  93835. /**
  93836. * If the behavior is currently in a dragging state
  93837. */
  93838. dragging: boolean;
  93839. /**
  93840. * 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)
  93841. */
  93842. dragDeltaRatio: number;
  93843. /**
  93844. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93845. */
  93846. currentDraggingPointerID: number;
  93847. /**
  93848. * If camera controls should be detached during the drag
  93849. */
  93850. detachCameraControls: boolean;
  93851. /**
  93852. * Fires each time a drag starts
  93853. */
  93854. onDragStartObservable: Observable<{}>;
  93855. /**
  93856. * Fires each time a drag ends (eg. mouse release after drag)
  93857. */
  93858. onDragEndObservable: Observable<{}>;
  93859. /**
  93860. * 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
  93861. */
  93862. constructor();
  93863. /**
  93864. * The name of the behavior
  93865. */
  93866. readonly name: string;
  93867. /**
  93868. * Initializes the behavior
  93869. */
  93870. init(): void;
  93871. /**
  93872. * Attaches the scale behavior the passed in mesh
  93873. * @param ownerNode The mesh that will be scaled around once attached
  93874. */
  93875. attach(ownerNode: Mesh): void;
  93876. /**
  93877. * Detaches the behavior from the mesh
  93878. */
  93879. detach(): void;
  93880. }
  93881. }
  93882. declare module BABYLON {
  93883. /**
  93884. * Class used to apply inverse kinematics to bones
  93885. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  93886. */
  93887. export class BoneIKController {
  93888. private static _tmpVecs;
  93889. private static _tmpQuat;
  93890. private static _tmpMats;
  93891. /**
  93892. * Gets or sets the target mesh
  93893. */
  93894. targetMesh: AbstractMesh;
  93895. /** Gets or sets the mesh used as pole */
  93896. poleTargetMesh: AbstractMesh;
  93897. /**
  93898. * Gets or sets the bone used as pole
  93899. */
  93900. poleTargetBone: Nullable<Bone>;
  93901. /**
  93902. * Gets or sets the target position
  93903. */
  93904. targetPosition: Vector3;
  93905. /**
  93906. * Gets or sets the pole target position
  93907. */
  93908. poleTargetPosition: Vector3;
  93909. /**
  93910. * Gets or sets the pole target local offset
  93911. */
  93912. poleTargetLocalOffset: Vector3;
  93913. /**
  93914. * Gets or sets the pole angle
  93915. */
  93916. poleAngle: number;
  93917. /**
  93918. * Gets or sets the mesh associated with the controller
  93919. */
  93920. mesh: AbstractMesh;
  93921. /**
  93922. * 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)
  93923. */
  93924. slerpAmount: number;
  93925. private _bone1Quat;
  93926. private _bone1Mat;
  93927. private _bone2Ang;
  93928. private _bone1;
  93929. private _bone2;
  93930. private _bone1Length;
  93931. private _bone2Length;
  93932. private _maxAngle;
  93933. private _maxReach;
  93934. private _rightHandedSystem;
  93935. private _bendAxis;
  93936. private _slerping;
  93937. private _adjustRoll;
  93938. /**
  93939. * Gets or sets maximum allowed angle
  93940. */
  93941. maxAngle: number;
  93942. /**
  93943. * Creates a new BoneIKController
  93944. * @param mesh defines the mesh to control
  93945. * @param bone defines the bone to control
  93946. * @param options defines options to set up the controller
  93947. */
  93948. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  93949. targetMesh?: AbstractMesh;
  93950. poleTargetMesh?: AbstractMesh;
  93951. poleTargetBone?: Bone;
  93952. poleTargetLocalOffset?: Vector3;
  93953. poleAngle?: number;
  93954. bendAxis?: Vector3;
  93955. maxAngle?: number;
  93956. slerpAmount?: number;
  93957. });
  93958. private _setMaxAngle;
  93959. /**
  93960. * Force the controller to update the bones
  93961. */
  93962. update(): void;
  93963. }
  93964. }
  93965. declare module BABYLON {
  93966. /**
  93967. * Class used to make a bone look toward a point in space
  93968. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  93969. */
  93970. export class BoneLookController {
  93971. private static _tmpVecs;
  93972. private static _tmpQuat;
  93973. private static _tmpMats;
  93974. /**
  93975. * The target Vector3 that the bone will look at
  93976. */
  93977. target: Vector3;
  93978. /**
  93979. * The mesh that the bone is attached to
  93980. */
  93981. mesh: AbstractMesh;
  93982. /**
  93983. * The bone that will be looking to the target
  93984. */
  93985. bone: Bone;
  93986. /**
  93987. * The up axis of the coordinate system that is used when the bone is rotated
  93988. */
  93989. upAxis: Vector3;
  93990. /**
  93991. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  93992. */
  93993. upAxisSpace: Space;
  93994. /**
  93995. * Used to make an adjustment to the yaw of the bone
  93996. */
  93997. adjustYaw: number;
  93998. /**
  93999. * Used to make an adjustment to the pitch of the bone
  94000. */
  94001. adjustPitch: number;
  94002. /**
  94003. * Used to make an adjustment to the roll of the bone
  94004. */
  94005. adjustRoll: number;
  94006. /**
  94007. * 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)
  94008. */
  94009. slerpAmount: number;
  94010. private _minYaw;
  94011. private _maxYaw;
  94012. private _minPitch;
  94013. private _maxPitch;
  94014. private _minYawSin;
  94015. private _minYawCos;
  94016. private _maxYawSin;
  94017. private _maxYawCos;
  94018. private _midYawConstraint;
  94019. private _minPitchTan;
  94020. private _maxPitchTan;
  94021. private _boneQuat;
  94022. private _slerping;
  94023. private _transformYawPitch;
  94024. private _transformYawPitchInv;
  94025. private _firstFrameSkipped;
  94026. private _yawRange;
  94027. private _fowardAxis;
  94028. /**
  94029. * Gets or sets the minimum yaw angle that the bone can look to
  94030. */
  94031. minYaw: number;
  94032. /**
  94033. * Gets or sets the maximum yaw angle that the bone can look to
  94034. */
  94035. maxYaw: number;
  94036. /**
  94037. * Gets or sets the minimum pitch angle that the bone can look to
  94038. */
  94039. minPitch: number;
  94040. /**
  94041. * Gets or sets the maximum pitch angle that the bone can look to
  94042. */
  94043. maxPitch: number;
  94044. /**
  94045. * Create a BoneLookController
  94046. * @param mesh the mesh that the bone belongs to
  94047. * @param bone the bone that will be looking to the target
  94048. * @param target the target Vector3 to look at
  94049. * @param options optional settings:
  94050. * * maxYaw: the maximum angle the bone will yaw to
  94051. * * minYaw: the minimum angle the bone will yaw to
  94052. * * maxPitch: the maximum angle the bone will pitch to
  94053. * * minPitch: the minimum angle the bone will yaw to
  94054. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  94055. * * upAxis: the up axis of the coordinate system
  94056. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  94057. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  94058. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  94059. * * adjustYaw: used to make an adjustment to the yaw of the bone
  94060. * * adjustPitch: used to make an adjustment to the pitch of the bone
  94061. * * adjustRoll: used to make an adjustment to the roll of the bone
  94062. **/
  94063. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  94064. maxYaw?: number;
  94065. minYaw?: number;
  94066. maxPitch?: number;
  94067. minPitch?: number;
  94068. slerpAmount?: number;
  94069. upAxis?: Vector3;
  94070. upAxisSpace?: Space;
  94071. yawAxis?: Vector3;
  94072. pitchAxis?: Vector3;
  94073. adjustYaw?: number;
  94074. adjustPitch?: number;
  94075. adjustRoll?: number;
  94076. });
  94077. /**
  94078. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  94079. */
  94080. update(): void;
  94081. private _getAngleDiff;
  94082. private _getAngleBetween;
  94083. private _isAngleBetween;
  94084. }
  94085. }
  94086. declare module BABYLON {
  94087. /**
  94088. * Manage the gamepad inputs to control an arc rotate camera.
  94089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94090. */
  94091. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  94092. /**
  94093. * Defines the camera the input is attached to.
  94094. */
  94095. camera: ArcRotateCamera;
  94096. /**
  94097. * Defines the gamepad the input is gathering event from.
  94098. */
  94099. gamepad: Nullable<Gamepad>;
  94100. /**
  94101. * Defines the gamepad rotation sensiblity.
  94102. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94103. */
  94104. gamepadRotationSensibility: number;
  94105. /**
  94106. * Defines the gamepad move sensiblity.
  94107. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94108. */
  94109. gamepadMoveSensibility: number;
  94110. private _onGamepadConnectedObserver;
  94111. private _onGamepadDisconnectedObserver;
  94112. /**
  94113. * Attach the input controls to a specific dom element to get the input from.
  94114. * @param element Defines the element the controls should be listened from
  94115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94116. */
  94117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94118. /**
  94119. * Detach the current controls from the specified dom element.
  94120. * @param element Defines the element to stop listening the inputs from
  94121. */
  94122. detachControl(element: Nullable<HTMLElement>): void;
  94123. /**
  94124. * Update the current camera state depending on the inputs that have been used this frame.
  94125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94126. */
  94127. checkInputs(): void;
  94128. /**
  94129. * Gets the class name of the current intput.
  94130. * @returns the class name
  94131. */
  94132. getClassName(): string;
  94133. /**
  94134. * Get the friendly name associated with the input class.
  94135. * @returns the input friendly name
  94136. */
  94137. getSimpleName(): string;
  94138. }
  94139. }
  94140. declare module BABYLON {
  94141. interface ArcRotateCameraInputsManager {
  94142. /**
  94143. * Add orientation input support to the input manager.
  94144. * @returns the current input manager
  94145. */
  94146. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  94147. }
  94148. /**
  94149. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  94150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94151. */
  94152. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  94153. /**
  94154. * Defines the camera the input is attached to.
  94155. */
  94156. camera: ArcRotateCamera;
  94157. /**
  94158. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  94159. */
  94160. alphaCorrection: number;
  94161. /**
  94162. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  94163. */
  94164. gammaCorrection: number;
  94165. private _alpha;
  94166. private _gamma;
  94167. private _dirty;
  94168. private _deviceOrientationHandler;
  94169. /**
  94170. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  94171. */
  94172. constructor();
  94173. /**
  94174. * Attach the input controls to a specific dom element to get the input from.
  94175. * @param element Defines the element the controls should be listened from
  94176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94177. */
  94178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94179. /** @hidden */
  94180. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  94181. /**
  94182. * Update the current camera state depending on the inputs that have been used this frame.
  94183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94184. */
  94185. checkInputs(): 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. * Gets the class name of the current intput.
  94193. * @returns the class name
  94194. */
  94195. getClassName(): string;
  94196. /**
  94197. * Get the friendly name associated with the input class.
  94198. * @returns the input friendly name
  94199. */
  94200. getSimpleName(): string;
  94201. }
  94202. }
  94203. declare module BABYLON {
  94204. /**
  94205. * Listen to mouse events to control the camera.
  94206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94207. */
  94208. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  94209. /**
  94210. * Defines the camera the input is attached to.
  94211. */
  94212. camera: FlyCamera;
  94213. /**
  94214. * Defines if touch is enabled. (Default is true.)
  94215. */
  94216. touchEnabled: boolean;
  94217. /**
  94218. * Defines the buttons associated with the input to handle camera rotation.
  94219. */
  94220. buttons: number[];
  94221. /**
  94222. * Assign buttons for Yaw control.
  94223. */
  94224. buttonsYaw: number[];
  94225. /**
  94226. * Assign buttons for Pitch control.
  94227. */
  94228. buttonsPitch: number[];
  94229. /**
  94230. * Assign buttons for Roll control.
  94231. */
  94232. buttonsRoll: number[];
  94233. /**
  94234. * Detect if any button is being pressed while mouse is moved.
  94235. * -1 = Mouse locked.
  94236. * 0 = Left button.
  94237. * 1 = Middle Button.
  94238. * 2 = Right Button.
  94239. */
  94240. activeButton: number;
  94241. /**
  94242. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  94243. * Higher values reduce its sensitivity.
  94244. */
  94245. angularSensibility: number;
  94246. private _mousemoveCallback;
  94247. private _observer;
  94248. private _rollObserver;
  94249. private previousPosition;
  94250. private noPreventDefault;
  94251. private element;
  94252. /**
  94253. * Listen to mouse events to control the camera.
  94254. * @param touchEnabled Define if touch is enabled. (Default is true.)
  94255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94256. */
  94257. constructor(touchEnabled?: boolean);
  94258. /**
  94259. * Attach the mouse control to the HTML DOM element.
  94260. * @param element Defines the element that listens to the input events.
  94261. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  94262. */
  94263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94264. /**
  94265. * Detach the current controls from the specified dom element.
  94266. * @param element Defines the element to stop listening the inputs from
  94267. */
  94268. detachControl(element: Nullable<HTMLElement>): void;
  94269. /**
  94270. * Gets the class name of the current input.
  94271. * @returns the class name.
  94272. */
  94273. getClassName(): string;
  94274. /**
  94275. * Get the friendly name associated with the input class.
  94276. * @returns the input's friendly name.
  94277. */
  94278. getSimpleName(): string;
  94279. private _pointerInput;
  94280. private _onMouseMove;
  94281. /**
  94282. * Rotate camera by mouse offset.
  94283. */
  94284. private rotateCamera;
  94285. }
  94286. }
  94287. declare module BABYLON {
  94288. /**
  94289. * Default Inputs manager for the FlyCamera.
  94290. * It groups all the default supported inputs for ease of use.
  94291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94292. */
  94293. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  94294. /**
  94295. * Instantiates a new FlyCameraInputsManager.
  94296. * @param camera Defines the camera the inputs belong to.
  94297. */
  94298. constructor(camera: FlyCamera);
  94299. /**
  94300. * Add keyboard input support to the input manager.
  94301. * @returns the new FlyCameraKeyboardMoveInput().
  94302. */
  94303. addKeyboard(): FlyCameraInputsManager;
  94304. /**
  94305. * Add mouse input support to the input manager.
  94306. * @param touchEnabled Enable touch screen support.
  94307. * @returns the new FlyCameraMouseInput().
  94308. */
  94309. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  94310. }
  94311. }
  94312. declare module BABYLON {
  94313. /**
  94314. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94315. * such as in a 3D Space Shooter or a Flight Simulator.
  94316. */
  94317. export class FlyCamera extends TargetCamera {
  94318. /**
  94319. * Define the collision ellipsoid of the camera.
  94320. * This is helpful for simulating a camera body, like a player's body.
  94321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94322. */
  94323. ellipsoid: Vector3;
  94324. /**
  94325. * Define an offset for the position of the ellipsoid around the camera.
  94326. * This can be helpful if the camera is attached away from the player's body center,
  94327. * such as at its head.
  94328. */
  94329. ellipsoidOffset: Vector3;
  94330. /**
  94331. * Enable or disable collisions of the camera with the rest of the scene objects.
  94332. */
  94333. checkCollisions: boolean;
  94334. /**
  94335. * Enable or disable gravity on the camera.
  94336. */
  94337. applyGravity: boolean;
  94338. /**
  94339. * Define the current direction the camera is moving to.
  94340. */
  94341. cameraDirection: Vector3;
  94342. /**
  94343. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  94344. * This overrides and empties cameraRotation.
  94345. */
  94346. rotationQuaternion: Quaternion;
  94347. /**
  94348. * Track Roll to maintain the wanted Rolling when looking around.
  94349. */
  94350. _trackRoll: number;
  94351. /**
  94352. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  94353. */
  94354. rollCorrect: number;
  94355. /**
  94356. * Mimic a banked turn, Rolling the camera when Yawing.
  94357. * It's recommended to use rollCorrect = 10 for faster banking correction.
  94358. */
  94359. bankedTurn: boolean;
  94360. /**
  94361. * Limit in radians for how much Roll banking will add. (Default: 90°)
  94362. */
  94363. bankedTurnLimit: number;
  94364. /**
  94365. * Value of 0 disables the banked Roll.
  94366. * Value of 1 is equal to the Yaw angle in radians.
  94367. */
  94368. bankedTurnMultiplier: number;
  94369. /**
  94370. * The inputs manager loads all the input sources, such as keyboard and mouse.
  94371. */
  94372. inputs: FlyCameraInputsManager;
  94373. /**
  94374. * Gets the input sensibility for mouse input.
  94375. * Higher values reduce sensitivity.
  94376. */
  94377. /**
  94378. * Sets the input sensibility for a mouse input.
  94379. * Higher values reduce sensitivity.
  94380. */
  94381. angularSensibility: number;
  94382. /**
  94383. * Get the keys for camera movement forward.
  94384. */
  94385. /**
  94386. * Set the keys for camera movement forward.
  94387. */
  94388. keysForward: number[];
  94389. /**
  94390. * Get the keys for camera movement backward.
  94391. */
  94392. keysBackward: number[];
  94393. /**
  94394. * Get the keys for camera movement up.
  94395. */
  94396. /**
  94397. * Set the keys for camera movement up.
  94398. */
  94399. keysUp: number[];
  94400. /**
  94401. * Get the keys for camera movement down.
  94402. */
  94403. /**
  94404. * Set the keys for camera movement down.
  94405. */
  94406. keysDown: number[];
  94407. /**
  94408. * Get the keys for camera movement left.
  94409. */
  94410. /**
  94411. * Set the keys for camera movement left.
  94412. */
  94413. keysLeft: number[];
  94414. /**
  94415. * Set the keys for camera movement right.
  94416. */
  94417. /**
  94418. * Set the keys for camera movement right.
  94419. */
  94420. keysRight: number[];
  94421. /**
  94422. * Event raised when the camera collides with a mesh in the scene.
  94423. */
  94424. onCollide: (collidedMesh: AbstractMesh) => void;
  94425. private _collider;
  94426. private _needMoveForGravity;
  94427. private _oldPosition;
  94428. private _diffPosition;
  94429. private _newPosition;
  94430. /** @hidden */
  94431. _localDirection: Vector3;
  94432. /** @hidden */
  94433. _transformedDirection: Vector3;
  94434. /**
  94435. * Instantiates a FlyCamera.
  94436. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94437. * such as in a 3D Space Shooter or a Flight Simulator.
  94438. * @param name Define the name of the camera in the scene.
  94439. * @param position Define the starting position of the camera in the scene.
  94440. * @param scene Define the scene the camera belongs to.
  94441. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  94442. */
  94443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94444. /**
  94445. * Attach a control to the HTML DOM element.
  94446. * @param element Defines the element that listens to the input events.
  94447. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  94448. */
  94449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94450. /**
  94451. * Detach a control from the HTML DOM element.
  94452. * The camera will stop reacting to that input.
  94453. * @param element Defines the element that listens to the input events.
  94454. */
  94455. detachControl(element: HTMLElement): void;
  94456. private _collisionMask;
  94457. /**
  94458. * Get the mask that the camera ignores in collision events.
  94459. */
  94460. /**
  94461. * Set the mask that the camera ignores in collision events.
  94462. */
  94463. collisionMask: number;
  94464. /** @hidden */
  94465. _collideWithWorld(displacement: Vector3): void;
  94466. /** @hidden */
  94467. private _onCollisionPositionChange;
  94468. /** @hidden */
  94469. _checkInputs(): void;
  94470. /** @hidden */
  94471. _decideIfNeedsToMove(): boolean;
  94472. /** @hidden */
  94473. _updatePosition(): void;
  94474. /**
  94475. * Restore the Roll to its target value at the rate specified.
  94476. * @param rate - Higher means slower restoring.
  94477. * @hidden
  94478. */
  94479. restoreRoll(rate: number): void;
  94480. /**
  94481. * Destroy the camera and release the current resources held by it.
  94482. */
  94483. dispose(): void;
  94484. /**
  94485. * Get the current object class name.
  94486. * @returns the class name.
  94487. */
  94488. getClassName(): string;
  94489. }
  94490. }
  94491. declare module BABYLON {
  94492. /**
  94493. * Listen to keyboard events to control the camera.
  94494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94495. */
  94496. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  94497. /**
  94498. * Defines the camera the input is attached to.
  94499. */
  94500. camera: FlyCamera;
  94501. /**
  94502. * The list of keyboard keys used to control the forward move of the camera.
  94503. */
  94504. keysForward: number[];
  94505. /**
  94506. * The list of keyboard keys used to control the backward move of the camera.
  94507. */
  94508. keysBackward: number[];
  94509. /**
  94510. * The list of keyboard keys used to control the forward move of the camera.
  94511. */
  94512. keysUp: number[];
  94513. /**
  94514. * The list of keyboard keys used to control the backward move of the camera.
  94515. */
  94516. keysDown: number[];
  94517. /**
  94518. * The list of keyboard keys used to control the right strafe move of the camera.
  94519. */
  94520. keysRight: number[];
  94521. /**
  94522. * The list of keyboard keys used to control the left strafe move of the camera.
  94523. */
  94524. keysLeft: number[];
  94525. private _keys;
  94526. private _onCanvasBlurObserver;
  94527. private _onKeyboardObserver;
  94528. private _engine;
  94529. private _scene;
  94530. /**
  94531. * Attach the input controls to a specific dom element to get the input from.
  94532. * @param element Defines the element the controls should be listened from
  94533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94534. */
  94535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94536. /**
  94537. * Detach the current controls from the specified dom element.
  94538. * @param element Defines the element to stop listening the inputs from
  94539. */
  94540. detachControl(element: Nullable<HTMLElement>): void;
  94541. /**
  94542. * Gets the class name of the current intput.
  94543. * @returns the class name
  94544. */
  94545. getClassName(): string;
  94546. /** @hidden */
  94547. _onLostFocus(e: FocusEvent): void;
  94548. /**
  94549. * Get the friendly name associated with the input class.
  94550. * @returns the input friendly name
  94551. */
  94552. getSimpleName(): string;
  94553. /**
  94554. * Update the current camera state depending on the inputs that have been used this frame.
  94555. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94556. */
  94557. checkInputs(): void;
  94558. }
  94559. }
  94560. declare module BABYLON {
  94561. /**
  94562. * Manage the mouse wheel inputs to control a follow camera.
  94563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94564. */
  94565. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  94566. /**
  94567. * Defines the camera the input is attached to.
  94568. */
  94569. camera: FollowCamera;
  94570. /**
  94571. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  94572. */
  94573. axisControlRadius: boolean;
  94574. /**
  94575. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  94576. */
  94577. axisControlHeight: boolean;
  94578. /**
  94579. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  94580. */
  94581. axisControlRotation: boolean;
  94582. /**
  94583. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  94584. * relation to mouseWheel events.
  94585. */
  94586. wheelPrecision: number;
  94587. /**
  94588. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94589. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94590. */
  94591. wheelDeltaPercentage: number;
  94592. private _wheel;
  94593. private _observer;
  94594. /**
  94595. * Attach the input controls to a specific dom element to get the input from.
  94596. * @param element Defines the element the controls should be listened from
  94597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94598. */
  94599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94600. /**
  94601. * Detach the current controls from the specified dom element.
  94602. * @param element Defines the element to stop listening the inputs from
  94603. */
  94604. detachControl(element: Nullable<HTMLElement>): void;
  94605. /**
  94606. * Gets the class name of the current intput.
  94607. * @returns the class name
  94608. */
  94609. getClassName(): string;
  94610. /**
  94611. * Get the friendly name associated with the input class.
  94612. * @returns the input friendly name
  94613. */
  94614. getSimpleName(): string;
  94615. }
  94616. }
  94617. declare module BABYLON {
  94618. /**
  94619. * Manage the pointers inputs to control an follow camera.
  94620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94621. */
  94622. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  94623. /**
  94624. * Defines the camera the input is attached to.
  94625. */
  94626. camera: FollowCamera;
  94627. /**
  94628. * Gets the class name of the current input.
  94629. * @returns the class name
  94630. */
  94631. getClassName(): string;
  94632. /**
  94633. * Defines the pointer angular sensibility along the X axis or how fast is
  94634. * the camera rotating.
  94635. * A negative number will reverse the axis direction.
  94636. */
  94637. angularSensibilityX: number;
  94638. /**
  94639. * Defines the pointer angular sensibility along the Y axis or how fast is
  94640. * the camera rotating.
  94641. * A negative number will reverse the axis direction.
  94642. */
  94643. angularSensibilityY: number;
  94644. /**
  94645. * Defines the pointer pinch precision or how fast is the camera zooming.
  94646. * A negative number will reverse the axis direction.
  94647. */
  94648. pinchPrecision: number;
  94649. /**
  94650. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94651. * from 0.
  94652. * It defines the percentage of current camera.radius to use as delta when
  94653. * pinch zoom is used.
  94654. */
  94655. pinchDeltaPercentage: number;
  94656. /**
  94657. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  94658. */
  94659. axisXControlRadius: boolean;
  94660. /**
  94661. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  94662. */
  94663. axisXControlHeight: boolean;
  94664. /**
  94665. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  94666. */
  94667. axisXControlRotation: boolean;
  94668. /**
  94669. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  94670. */
  94671. axisYControlRadius: boolean;
  94672. /**
  94673. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  94674. */
  94675. axisYControlHeight: boolean;
  94676. /**
  94677. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  94678. */
  94679. axisYControlRotation: boolean;
  94680. /**
  94681. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  94682. */
  94683. axisPinchControlRadius: boolean;
  94684. /**
  94685. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  94686. */
  94687. axisPinchControlHeight: boolean;
  94688. /**
  94689. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  94690. */
  94691. axisPinchControlRotation: boolean;
  94692. /**
  94693. * Log error messages if basic misconfiguration has occurred.
  94694. */
  94695. warningEnable: boolean;
  94696. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94697. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94698. private _warningCounter;
  94699. private _warning;
  94700. }
  94701. }
  94702. declare module BABYLON {
  94703. /**
  94704. * Default Inputs manager for the FollowCamera.
  94705. * It groups all the default supported inputs for ease of use.
  94706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94707. */
  94708. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  94709. /**
  94710. * Instantiates a new FollowCameraInputsManager.
  94711. * @param camera Defines the camera the inputs belong to
  94712. */
  94713. constructor(camera: FollowCamera);
  94714. /**
  94715. * Add keyboard input support to the input manager.
  94716. * @returns the current input manager
  94717. */
  94718. addKeyboard(): FollowCameraInputsManager;
  94719. /**
  94720. * Add mouse wheel input support to the input manager.
  94721. * @returns the current input manager
  94722. */
  94723. addMouseWheel(): FollowCameraInputsManager;
  94724. /**
  94725. * Add pointers input support to the input manager.
  94726. * @returns the current input manager
  94727. */
  94728. addPointers(): FollowCameraInputsManager;
  94729. /**
  94730. * Add orientation input support to the input manager.
  94731. * @returns the current input manager
  94732. */
  94733. addVRDeviceOrientation(): FollowCameraInputsManager;
  94734. }
  94735. }
  94736. declare module BABYLON {
  94737. /**
  94738. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  94739. * an arc rotate version arcFollowCamera are available.
  94740. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94741. */
  94742. export class FollowCamera extends TargetCamera {
  94743. /**
  94744. * Distance the follow camera should follow an object at
  94745. */
  94746. radius: number;
  94747. /**
  94748. * Minimum allowed distance of the camera to the axis of rotation
  94749. * (The camera can not get closer).
  94750. * This can help limiting how the Camera is able to move in the scene.
  94751. */
  94752. lowerRadiusLimit: Nullable<number>;
  94753. /**
  94754. * Maximum allowed distance of the camera to the axis of rotation
  94755. * (The camera can not get further).
  94756. * This can help limiting how the Camera is able to move in the scene.
  94757. */
  94758. upperRadiusLimit: Nullable<number>;
  94759. /**
  94760. * Define a rotation offset between the camera and the object it follows
  94761. */
  94762. rotationOffset: number;
  94763. /**
  94764. * Minimum allowed angle to camera position relative to target object.
  94765. * This can help limiting how the Camera is able to move in the scene.
  94766. */
  94767. lowerRotationOffsetLimit: Nullable<number>;
  94768. /**
  94769. * Maximum allowed angle to camera position relative to target object.
  94770. * This can help limiting how the Camera is able to move in the scene.
  94771. */
  94772. upperRotationOffsetLimit: Nullable<number>;
  94773. /**
  94774. * Define a height offset between the camera and the object it follows.
  94775. * It can help following an object from the top (like a car chaing a plane)
  94776. */
  94777. heightOffset: number;
  94778. /**
  94779. * Minimum allowed height of camera position relative to target object.
  94780. * This can help limiting how the Camera is able to move in the scene.
  94781. */
  94782. lowerHeightOffsetLimit: Nullable<number>;
  94783. /**
  94784. * Maximum allowed height of camera position relative to target object.
  94785. * This can help limiting how the Camera is able to move in the scene.
  94786. */
  94787. upperHeightOffsetLimit: Nullable<number>;
  94788. /**
  94789. * Define how fast the camera can accelerate to follow it s target.
  94790. */
  94791. cameraAcceleration: number;
  94792. /**
  94793. * Define the speed limit of the camera following an object.
  94794. */
  94795. maxCameraSpeed: number;
  94796. /**
  94797. * Define the target of the camera.
  94798. */
  94799. lockedTarget: Nullable<AbstractMesh>;
  94800. /**
  94801. * Defines the input associated with the camera.
  94802. */
  94803. inputs: FollowCameraInputsManager;
  94804. /**
  94805. * Instantiates the follow camera.
  94806. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94807. * @param name Define the name of the camera in the scene
  94808. * @param position Define the position of the camera
  94809. * @param scene Define the scene the camera belong to
  94810. * @param lockedTarget Define the target of the camera
  94811. */
  94812. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  94813. private _follow;
  94814. /**
  94815. * Attached controls to the current camera.
  94816. * @param element Defines the element the controls should be listened from
  94817. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94818. */
  94819. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94820. /**
  94821. * Detach the current controls from the camera.
  94822. * The camera will stop reacting to inputs.
  94823. * @param element Defines the element to stop listening the inputs from
  94824. */
  94825. detachControl(element: HTMLElement): void;
  94826. /** @hidden */
  94827. _checkInputs(): void;
  94828. private _checkLimits;
  94829. /**
  94830. * Gets the camera class name.
  94831. * @returns the class name
  94832. */
  94833. getClassName(): string;
  94834. }
  94835. /**
  94836. * Arc Rotate version of the follow camera.
  94837. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  94838. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94839. */
  94840. export class ArcFollowCamera extends TargetCamera {
  94841. /** The longitudinal angle of the camera */
  94842. alpha: number;
  94843. /** The latitudinal angle of the camera */
  94844. beta: number;
  94845. /** The radius of the camera from its target */
  94846. radius: number;
  94847. /** Define the camera target (the messh it should follow) */
  94848. target: Nullable<AbstractMesh>;
  94849. private _cartesianCoordinates;
  94850. /**
  94851. * Instantiates a new ArcFollowCamera
  94852. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94853. * @param name Define the name of the camera
  94854. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  94855. * @param beta Define the rotation angle of the camera around the elevation axis
  94856. * @param radius Define the radius of the camera from its target point
  94857. * @param target Define the target of the camera
  94858. * @param scene Define the scene the camera belongs to
  94859. */
  94860. constructor(name: string,
  94861. /** The longitudinal angle of the camera */
  94862. alpha: number,
  94863. /** The latitudinal angle of the camera */
  94864. beta: number,
  94865. /** The radius of the camera from its target */
  94866. radius: number,
  94867. /** Define the camera target (the messh it should follow) */
  94868. target: Nullable<AbstractMesh>, scene: Scene);
  94869. private _follow;
  94870. /** @hidden */
  94871. _checkInputs(): void;
  94872. /**
  94873. * Returns the class name of the object.
  94874. * It is mostly used internally for serialization purposes.
  94875. */
  94876. getClassName(): string;
  94877. }
  94878. }
  94879. declare module BABYLON {
  94880. /**
  94881. * Manage the keyboard inputs to control the movement of a follow camera.
  94882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94883. */
  94884. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  94885. /**
  94886. * Defines the camera the input is attached to.
  94887. */
  94888. camera: FollowCamera;
  94889. /**
  94890. * Defines the list of key codes associated with the up action (increase heightOffset)
  94891. */
  94892. keysHeightOffsetIncr: number[];
  94893. /**
  94894. * Defines the list of key codes associated with the down action (decrease heightOffset)
  94895. */
  94896. keysHeightOffsetDecr: number[];
  94897. /**
  94898. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  94899. */
  94900. keysHeightOffsetModifierAlt: boolean;
  94901. /**
  94902. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  94903. */
  94904. keysHeightOffsetModifierCtrl: boolean;
  94905. /**
  94906. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  94907. */
  94908. keysHeightOffsetModifierShift: boolean;
  94909. /**
  94910. * Defines the list of key codes associated with the left action (increase rotationOffset)
  94911. */
  94912. keysRotationOffsetIncr: number[];
  94913. /**
  94914. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  94915. */
  94916. keysRotationOffsetDecr: number[];
  94917. /**
  94918. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  94919. */
  94920. keysRotationOffsetModifierAlt: boolean;
  94921. /**
  94922. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  94923. */
  94924. keysRotationOffsetModifierCtrl: boolean;
  94925. /**
  94926. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  94927. */
  94928. keysRotationOffsetModifierShift: boolean;
  94929. /**
  94930. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  94931. */
  94932. keysRadiusIncr: number[];
  94933. /**
  94934. * Defines the list of key codes associated with the zoom-out action (increase radius)
  94935. */
  94936. keysRadiusDecr: number[];
  94937. /**
  94938. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  94939. */
  94940. keysRadiusModifierAlt: boolean;
  94941. /**
  94942. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  94943. */
  94944. keysRadiusModifierCtrl: boolean;
  94945. /**
  94946. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  94947. */
  94948. keysRadiusModifierShift: boolean;
  94949. /**
  94950. * Defines the rate of change of heightOffset.
  94951. */
  94952. heightSensibility: number;
  94953. /**
  94954. * Defines the rate of change of rotationOffset.
  94955. */
  94956. rotationSensibility: number;
  94957. /**
  94958. * Defines the rate of change of radius.
  94959. */
  94960. radiusSensibility: number;
  94961. private _keys;
  94962. private _ctrlPressed;
  94963. private _altPressed;
  94964. private _shiftPressed;
  94965. private _onCanvasBlurObserver;
  94966. private _onKeyboardObserver;
  94967. private _engine;
  94968. private _scene;
  94969. /**
  94970. * Attach the input controls to a specific dom element to get the input from.
  94971. * @param element Defines the element the controls should be listened from
  94972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94973. */
  94974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94975. /**
  94976. * Detach the current controls from the specified dom element.
  94977. * @param element Defines the element to stop listening the inputs from
  94978. */
  94979. detachControl(element: Nullable<HTMLElement>): void;
  94980. /**
  94981. * Update the current camera state depending on the inputs that have been used this frame.
  94982. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94983. */
  94984. checkInputs(): void;
  94985. /**
  94986. * Gets the class name of the current input.
  94987. * @returns the class name
  94988. */
  94989. getClassName(): string;
  94990. /**
  94991. * Get the friendly name associated with the input class.
  94992. * @returns the input friendly name
  94993. */
  94994. getSimpleName(): string;
  94995. /**
  94996. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94997. * allow modification of the heightOffset value.
  94998. */
  94999. private _modifierHeightOffset;
  95000. /**
  95001. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95002. * allow modification of the rotationOffset value.
  95003. */
  95004. private _modifierRotationOffset;
  95005. /**
  95006. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95007. * allow modification of the radius value.
  95008. */
  95009. private _modifierRadius;
  95010. }
  95011. }
  95012. declare module BABYLON {
  95013. interface FreeCameraInputsManager {
  95014. /**
  95015. * Add orientation input support to the input manager.
  95016. * @returns the current input manager
  95017. */
  95018. addDeviceOrientation(): FreeCameraInputsManager;
  95019. }
  95020. /**
  95021. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  95022. * Screen rotation is taken into account.
  95023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95024. */
  95025. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  95026. private _camera;
  95027. private _screenOrientationAngle;
  95028. private _constantTranform;
  95029. private _screenQuaternion;
  95030. private _alpha;
  95031. private _beta;
  95032. private _gamma;
  95033. /**
  95034. * Instantiates a new input
  95035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95036. */
  95037. constructor();
  95038. /**
  95039. * Define the camera controlled by the input.
  95040. */
  95041. camera: FreeCamera;
  95042. /**
  95043. * Attach the input controls to a specific dom element to get the input from.
  95044. * @param element Defines the element the controls should be listened from
  95045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95046. */
  95047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95048. private _orientationChanged;
  95049. private _deviceOrientation;
  95050. /**
  95051. * Detach the current controls from the specified dom element.
  95052. * @param element Defines the element to stop listening the inputs from
  95053. */
  95054. detachControl(element: Nullable<HTMLElement>): void;
  95055. /**
  95056. * Update the current camera state depending on the inputs that have been used this frame.
  95057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95058. */
  95059. checkInputs(): void;
  95060. /**
  95061. * Gets the class name of the current intput.
  95062. * @returns the class name
  95063. */
  95064. getClassName(): string;
  95065. /**
  95066. * Get the friendly name associated with the input class.
  95067. * @returns the input friendly name
  95068. */
  95069. getSimpleName(): string;
  95070. }
  95071. }
  95072. declare module BABYLON {
  95073. /**
  95074. * Manage the gamepad inputs to control a free camera.
  95075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95076. */
  95077. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  95078. /**
  95079. * Define the camera the input is attached to.
  95080. */
  95081. camera: FreeCamera;
  95082. /**
  95083. * Define the Gamepad controlling the input
  95084. */
  95085. gamepad: Nullable<Gamepad>;
  95086. /**
  95087. * Defines the gamepad rotation sensiblity.
  95088. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95089. */
  95090. gamepadAngularSensibility: number;
  95091. /**
  95092. * Defines the gamepad move sensiblity.
  95093. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95094. */
  95095. gamepadMoveSensibility: number;
  95096. private _onGamepadConnectedObserver;
  95097. private _onGamepadDisconnectedObserver;
  95098. private _cameraTransform;
  95099. private _deltaTransform;
  95100. private _vector3;
  95101. private _vector2;
  95102. /**
  95103. * Attach the input controls to a specific dom element to get the input from.
  95104. * @param element Defines the element the controls should be listened from
  95105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95106. */
  95107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95108. /**
  95109. * Detach the current controls from the specified dom element.
  95110. * @param element Defines the element to stop listening the inputs from
  95111. */
  95112. detachControl(element: Nullable<HTMLElement>): void;
  95113. /**
  95114. * Update the current camera state depending on the inputs that have been used this frame.
  95115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95116. */
  95117. checkInputs(): void;
  95118. /**
  95119. * Gets the class name of the current intput.
  95120. * @returns the class name
  95121. */
  95122. getClassName(): string;
  95123. /**
  95124. * Get the friendly name associated with the input class.
  95125. * @returns the input friendly name
  95126. */
  95127. getSimpleName(): string;
  95128. }
  95129. }
  95130. declare module BABYLON {
  95131. /**
  95132. * Defines the potential axis of a Joystick
  95133. */
  95134. export enum JoystickAxis {
  95135. /** X axis */
  95136. X = 0,
  95137. /** Y axis */
  95138. Y = 1,
  95139. /** Z axis */
  95140. Z = 2
  95141. }
  95142. /**
  95143. * Class used to define virtual joystick (used in touch mode)
  95144. */
  95145. export class VirtualJoystick {
  95146. /**
  95147. * Gets or sets a boolean indicating that left and right values must be inverted
  95148. */
  95149. reverseLeftRight: boolean;
  95150. /**
  95151. * Gets or sets a boolean indicating that up and down values must be inverted
  95152. */
  95153. reverseUpDown: boolean;
  95154. /**
  95155. * Gets the offset value for the position (ie. the change of the position value)
  95156. */
  95157. deltaPosition: Vector3;
  95158. /**
  95159. * Gets a boolean indicating if the virtual joystick was pressed
  95160. */
  95161. pressed: boolean;
  95162. /**
  95163. * Canvas the virtual joystick will render onto, default z-index of this is 5
  95164. */
  95165. static Canvas: Nullable<HTMLCanvasElement>;
  95166. private static _globalJoystickIndex;
  95167. private static vjCanvasContext;
  95168. private static vjCanvasWidth;
  95169. private static vjCanvasHeight;
  95170. private static halfWidth;
  95171. private _action;
  95172. private _axisTargetedByLeftAndRight;
  95173. private _axisTargetedByUpAndDown;
  95174. private _joystickSensibility;
  95175. private _inversedSensibility;
  95176. private _joystickPointerID;
  95177. private _joystickColor;
  95178. private _joystickPointerPos;
  95179. private _joystickPreviousPointerPos;
  95180. private _joystickPointerStartPos;
  95181. private _deltaJoystickVector;
  95182. private _leftJoystick;
  95183. private _touches;
  95184. private _onPointerDownHandlerRef;
  95185. private _onPointerMoveHandlerRef;
  95186. private _onPointerUpHandlerRef;
  95187. private _onResize;
  95188. /**
  95189. * Creates a new virtual joystick
  95190. * @param leftJoystick defines that the joystick is for left hand (false by default)
  95191. */
  95192. constructor(leftJoystick?: boolean);
  95193. /**
  95194. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  95195. * @param newJoystickSensibility defines the new sensibility
  95196. */
  95197. setJoystickSensibility(newJoystickSensibility: number): void;
  95198. private _onPointerDown;
  95199. private _onPointerMove;
  95200. private _onPointerUp;
  95201. /**
  95202. * Change the color of the virtual joystick
  95203. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  95204. */
  95205. setJoystickColor(newColor: string): void;
  95206. /**
  95207. * Defines a callback to call when the joystick is touched
  95208. * @param action defines the callback
  95209. */
  95210. setActionOnTouch(action: () => any): void;
  95211. /**
  95212. * Defines which axis you'd like to control for left & right
  95213. * @param axis defines the axis to use
  95214. */
  95215. setAxisForLeftRight(axis: JoystickAxis): void;
  95216. /**
  95217. * Defines which axis you'd like to control for up & down
  95218. * @param axis defines the axis to use
  95219. */
  95220. setAxisForUpDown(axis: JoystickAxis): void;
  95221. private _drawVirtualJoystick;
  95222. /**
  95223. * Release internal HTML canvas
  95224. */
  95225. releaseCanvas(): void;
  95226. }
  95227. }
  95228. declare module BABYLON {
  95229. interface FreeCameraInputsManager {
  95230. /**
  95231. * Add virtual joystick input support to the input manager.
  95232. * @returns the current input manager
  95233. */
  95234. addVirtualJoystick(): FreeCameraInputsManager;
  95235. }
  95236. /**
  95237. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  95238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95239. */
  95240. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  95241. /**
  95242. * Defines the camera the input is attached to.
  95243. */
  95244. camera: FreeCamera;
  95245. private _leftjoystick;
  95246. private _rightjoystick;
  95247. /**
  95248. * Gets the left stick of the virtual joystick.
  95249. * @returns The virtual Joystick
  95250. */
  95251. getLeftJoystick(): VirtualJoystick;
  95252. /**
  95253. * Gets the right stick of the virtual joystick.
  95254. * @returns The virtual Joystick
  95255. */
  95256. getRightJoystick(): VirtualJoystick;
  95257. /**
  95258. * Update the current camera state depending on the inputs that have been used this frame.
  95259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95260. */
  95261. checkInputs(): void;
  95262. /**
  95263. * Attach the input controls to a specific dom element to get the input from.
  95264. * @param element Defines the element the controls should be listened from
  95265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95266. */
  95267. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95268. /**
  95269. * Detach the current controls from the specified dom element.
  95270. * @param element Defines the element to stop listening the inputs from
  95271. */
  95272. detachControl(element: Nullable<HTMLElement>): void;
  95273. /**
  95274. * Gets the class name of the current intput.
  95275. * @returns the class name
  95276. */
  95277. getClassName(): string;
  95278. /**
  95279. * Get the friendly name associated with the input class.
  95280. * @returns the input friendly name
  95281. */
  95282. getSimpleName(): string;
  95283. }
  95284. }
  95285. declare module BABYLON {
  95286. /**
  95287. * This represents a FPS type of camera controlled by touch.
  95288. * This is like a universal camera minus the Gamepad controls.
  95289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95290. */
  95291. export class TouchCamera extends FreeCamera {
  95292. /**
  95293. * Defines the touch sensibility for rotation.
  95294. * The higher the faster.
  95295. */
  95296. touchAngularSensibility: number;
  95297. /**
  95298. * Defines the touch sensibility for move.
  95299. * The higher the faster.
  95300. */
  95301. touchMoveSensibility: number;
  95302. /**
  95303. * Instantiates a new touch camera.
  95304. * This represents a FPS type of camera controlled by touch.
  95305. * This is like a universal camera minus the Gamepad controls.
  95306. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95307. * @param name Define the name of the camera in the scene
  95308. * @param position Define the start position of the camera in the scene
  95309. * @param scene Define the scene the camera belongs to
  95310. */
  95311. constructor(name: string, position: Vector3, scene: Scene);
  95312. /**
  95313. * Gets the current object class name.
  95314. * @return the class name
  95315. */
  95316. getClassName(): string;
  95317. /** @hidden */
  95318. _setupInputs(): void;
  95319. }
  95320. }
  95321. declare module BABYLON {
  95322. /**
  95323. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  95324. * being tilted forward or back and left or right.
  95325. */
  95326. export class DeviceOrientationCamera extends FreeCamera {
  95327. private _initialQuaternion;
  95328. private _quaternionCache;
  95329. /**
  95330. * Creates a new device orientation camera
  95331. * @param name The name of the camera
  95332. * @param position The start position camera
  95333. * @param scene The scene the camera belongs to
  95334. */
  95335. constructor(name: string, position: Vector3, scene: Scene);
  95336. /**
  95337. * Gets the current instance class name ("DeviceOrientationCamera").
  95338. * This helps avoiding instanceof at run time.
  95339. * @returns the class name
  95340. */
  95341. getClassName(): string;
  95342. /**
  95343. * @hidden
  95344. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  95345. */
  95346. _checkInputs(): void;
  95347. /**
  95348. * Reset the camera to its default orientation on the specified axis only.
  95349. * @param axis The axis to reset
  95350. */
  95351. resetToCurrentRotation(axis?: Axis): void;
  95352. }
  95353. }
  95354. declare module BABYLON {
  95355. /**
  95356. * 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,
  95357. * which still works and will still be found in many Playgrounds.
  95358. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95359. */
  95360. export class UniversalCamera extends TouchCamera {
  95361. /**
  95362. * Defines the gamepad rotation sensiblity.
  95363. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95364. */
  95365. gamepadAngularSensibility: number;
  95366. /**
  95367. * Defines the gamepad move sensiblity.
  95368. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95369. */
  95370. gamepadMoveSensibility: number;
  95371. /**
  95372. * 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,
  95373. * which still works and will still be found in many Playgrounds.
  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. }
  95386. }
  95387. declare module BABYLON {
  95388. /**
  95389. * This represents a FPS type of camera. This is only here for back compat purpose.
  95390. * Please use the UniversalCamera instead as both are identical.
  95391. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95392. */
  95393. export class GamepadCamera extends UniversalCamera {
  95394. /**
  95395. * Instantiates a new Gamepad Camera
  95396. * This represents a FPS type of camera. This is only here for back compat purpose.
  95397. * Please use the UniversalCamera instead as both are identical.
  95398. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95399. * @param name Define the name of the camera in the scene
  95400. * @param position Define the start position of the camera in the scene
  95401. * @param scene Define the scene the camera belongs to
  95402. */
  95403. constructor(name: string, position: Vector3, scene: Scene);
  95404. /**
  95405. * Gets the current object class name.
  95406. * @return the class name
  95407. */
  95408. getClassName(): string;
  95409. }
  95410. }
  95411. declare module BABYLON {
  95412. /** @hidden */
  95413. export var passPixelShader: {
  95414. name: string;
  95415. shader: string;
  95416. };
  95417. }
  95418. declare module BABYLON {
  95419. /** @hidden */
  95420. export var passCubePixelShader: {
  95421. name: string;
  95422. shader: string;
  95423. };
  95424. }
  95425. declare module BABYLON {
  95426. /**
  95427. * PassPostProcess which produces an output the same as it's input
  95428. */
  95429. export class PassPostProcess extends PostProcess {
  95430. /**
  95431. * Creates the PassPostProcess
  95432. * @param name The name of the effect.
  95433. * @param options The required width/height ratio to downsize to before computing the render pass.
  95434. * @param camera The camera to apply the render pass to.
  95435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95436. * @param engine The engine which the post process will be applied. (default: current engine)
  95437. * @param reusable If the post process can be reused on the same frame. (default: false)
  95438. * @param textureType The type of texture to be used when performing the post processing.
  95439. * @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)
  95440. */
  95441. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95442. }
  95443. /**
  95444. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  95445. */
  95446. export class PassCubePostProcess extends PostProcess {
  95447. private _face;
  95448. /**
  95449. * Gets or sets the cube face to display.
  95450. * * 0 is +X
  95451. * * 1 is -X
  95452. * * 2 is +Y
  95453. * * 3 is -Y
  95454. * * 4 is +Z
  95455. * * 5 is -Z
  95456. */
  95457. face: number;
  95458. /**
  95459. * Creates the PassCubePostProcess
  95460. * @param name The name of the effect.
  95461. * @param options The required width/height ratio to downsize to before computing the render pass.
  95462. * @param camera The camera to apply the render pass to.
  95463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95464. * @param engine The engine which the post process will be applied. (default: current engine)
  95465. * @param reusable If the post process can be reused on the same frame. (default: false)
  95466. * @param textureType The type of texture to be used when performing the post processing.
  95467. * @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)
  95468. */
  95469. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95470. }
  95471. }
  95472. declare module BABYLON {
  95473. /** @hidden */
  95474. export var anaglyphPixelShader: {
  95475. name: string;
  95476. shader: string;
  95477. };
  95478. }
  95479. declare module BABYLON {
  95480. /**
  95481. * Postprocess used to generate anaglyphic rendering
  95482. */
  95483. export class AnaglyphPostProcess extends PostProcess {
  95484. private _passedProcess;
  95485. /**
  95486. * Creates a new AnaglyphPostProcess
  95487. * @param name defines postprocess name
  95488. * @param options defines creation options or target ratio scale
  95489. * @param rigCameras defines cameras using this postprocess
  95490. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  95491. * @param engine defines hosting engine
  95492. * @param reusable defines if the postprocess will be reused multiple times per frame
  95493. */
  95494. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  95495. }
  95496. }
  95497. declare module BABYLON {
  95498. /**
  95499. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  95500. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95501. */
  95502. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  95503. /**
  95504. * Creates a new AnaglyphArcRotateCamera
  95505. * @param name defines camera name
  95506. * @param alpha defines alpha angle (in radians)
  95507. * @param beta defines beta angle (in radians)
  95508. * @param radius defines radius
  95509. * @param target defines camera target
  95510. * @param interaxialDistance defines distance between each color axis
  95511. * @param scene defines the hosting scene
  95512. */
  95513. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  95514. /**
  95515. * Gets camera class name
  95516. * @returns AnaglyphArcRotateCamera
  95517. */
  95518. getClassName(): string;
  95519. }
  95520. }
  95521. declare module BABYLON {
  95522. /**
  95523. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  95524. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95525. */
  95526. export class AnaglyphFreeCamera extends FreeCamera {
  95527. /**
  95528. * Creates a new AnaglyphFreeCamera
  95529. * @param name defines camera name
  95530. * @param position defines initial position
  95531. * @param interaxialDistance defines distance between each color axis
  95532. * @param scene defines the hosting scene
  95533. */
  95534. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95535. /**
  95536. * Gets camera class name
  95537. * @returns AnaglyphFreeCamera
  95538. */
  95539. getClassName(): string;
  95540. }
  95541. }
  95542. declare module BABYLON {
  95543. /**
  95544. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  95545. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95546. */
  95547. export class AnaglyphGamepadCamera extends GamepadCamera {
  95548. /**
  95549. * Creates a new AnaglyphGamepadCamera
  95550. * @param name defines camera name
  95551. * @param position defines initial position
  95552. * @param interaxialDistance defines distance between each color axis
  95553. * @param scene defines the hosting scene
  95554. */
  95555. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95556. /**
  95557. * Gets camera class name
  95558. * @returns AnaglyphGamepadCamera
  95559. */
  95560. getClassName(): string;
  95561. }
  95562. }
  95563. declare module BABYLON {
  95564. /**
  95565. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  95566. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95567. */
  95568. export class AnaglyphUniversalCamera extends UniversalCamera {
  95569. /**
  95570. * Creates a new AnaglyphUniversalCamera
  95571. * @param name defines camera name
  95572. * @param position defines initial position
  95573. * @param interaxialDistance defines distance between each color axis
  95574. * @param scene defines the hosting scene
  95575. */
  95576. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95577. /**
  95578. * Gets camera class name
  95579. * @returns AnaglyphUniversalCamera
  95580. */
  95581. getClassName(): string;
  95582. }
  95583. }
  95584. declare module BABYLON {
  95585. /** @hidden */
  95586. export var stereoscopicInterlacePixelShader: {
  95587. name: string;
  95588. shader: string;
  95589. };
  95590. }
  95591. declare module BABYLON {
  95592. /**
  95593. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  95594. */
  95595. export class StereoscopicInterlacePostProcess extends PostProcess {
  95596. private _stepSize;
  95597. private _passedProcess;
  95598. /**
  95599. * Initializes a StereoscopicInterlacePostProcess
  95600. * @param name The name of the effect.
  95601. * @param rigCameras The rig cameras to be appled to the post process
  95602. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  95603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95604. * @param engine The engine which the post process will be applied. (default: current engine)
  95605. * @param reusable If the post process can be reused on the same frame. (default: false)
  95606. */
  95607. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  95608. }
  95609. }
  95610. declare module BABYLON {
  95611. /**
  95612. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  95613. * @see http://doc.babylonjs.com/features/cameras
  95614. */
  95615. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  95616. /**
  95617. * Creates a new StereoscopicArcRotateCamera
  95618. * @param name defines camera name
  95619. * @param alpha defines alpha angle (in radians)
  95620. * @param beta defines beta angle (in radians)
  95621. * @param radius defines radius
  95622. * @param target defines camera target
  95623. * @param interaxialDistance defines distance between each color axis
  95624. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95625. * @param scene defines the hosting scene
  95626. */
  95627. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95628. /**
  95629. * Gets camera class name
  95630. * @returns StereoscopicArcRotateCamera
  95631. */
  95632. getClassName(): string;
  95633. }
  95634. }
  95635. declare module BABYLON {
  95636. /**
  95637. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  95638. * @see http://doc.babylonjs.com/features/cameras
  95639. */
  95640. export class StereoscopicFreeCamera extends FreeCamera {
  95641. /**
  95642. * Creates a new StereoscopicFreeCamera
  95643. * @param name defines camera name
  95644. * @param position defines initial position
  95645. * @param interaxialDistance defines distance between each color axis
  95646. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95647. * @param scene defines the hosting scene
  95648. */
  95649. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95650. /**
  95651. * Gets camera class name
  95652. * @returns StereoscopicFreeCamera
  95653. */
  95654. getClassName(): string;
  95655. }
  95656. }
  95657. declare module BABYLON {
  95658. /**
  95659. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  95660. * @see http://doc.babylonjs.com/features/cameras
  95661. */
  95662. export class StereoscopicGamepadCamera extends GamepadCamera {
  95663. /**
  95664. * Creates a new StereoscopicGamepadCamera
  95665. * @param name defines camera name
  95666. * @param position defines initial position
  95667. * @param interaxialDistance defines distance between each color axis
  95668. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95669. * @param scene defines the hosting scene
  95670. */
  95671. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95672. /**
  95673. * Gets camera class name
  95674. * @returns StereoscopicGamepadCamera
  95675. */
  95676. getClassName(): string;
  95677. }
  95678. }
  95679. declare module BABYLON {
  95680. /**
  95681. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  95682. * @see http://doc.babylonjs.com/features/cameras
  95683. */
  95684. export class StereoscopicUniversalCamera extends UniversalCamera {
  95685. /**
  95686. * Creates a new StereoscopicUniversalCamera
  95687. * @param name defines camera name
  95688. * @param position defines initial position
  95689. * @param interaxialDistance defines distance between each color axis
  95690. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95691. * @param scene defines the hosting scene
  95692. */
  95693. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95694. /**
  95695. * Gets camera class name
  95696. * @returns StereoscopicUniversalCamera
  95697. */
  95698. getClassName(): string;
  95699. }
  95700. }
  95701. declare module BABYLON {
  95702. /**
  95703. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95704. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95705. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95706. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95707. */
  95708. export class VirtualJoysticksCamera extends FreeCamera {
  95709. /**
  95710. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  95711. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95712. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95713. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95714. * @param name Define the name of the camera in the scene
  95715. * @param position Define the start position of the camera in the scene
  95716. * @param scene Define the scene the camera belongs to
  95717. */
  95718. constructor(name: string, position: Vector3, scene: Scene);
  95719. /**
  95720. * Gets the current object class name.
  95721. * @return the class name
  95722. */
  95723. getClassName(): string;
  95724. }
  95725. }
  95726. declare module BABYLON {
  95727. /**
  95728. * This represents all the required metrics to create a VR camera.
  95729. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  95730. */
  95731. export class VRCameraMetrics {
  95732. /**
  95733. * Define the horizontal resolution off the screen.
  95734. */
  95735. hResolution: number;
  95736. /**
  95737. * Define the vertical resolution off the screen.
  95738. */
  95739. vResolution: number;
  95740. /**
  95741. * Define the horizontal screen size.
  95742. */
  95743. hScreenSize: number;
  95744. /**
  95745. * Define the vertical screen size.
  95746. */
  95747. vScreenSize: number;
  95748. /**
  95749. * Define the vertical screen center position.
  95750. */
  95751. vScreenCenter: number;
  95752. /**
  95753. * Define the distance of the eyes to the screen.
  95754. */
  95755. eyeToScreenDistance: number;
  95756. /**
  95757. * Define the distance between both lenses
  95758. */
  95759. lensSeparationDistance: number;
  95760. /**
  95761. * Define the distance between both viewer's eyes.
  95762. */
  95763. interpupillaryDistance: number;
  95764. /**
  95765. * Define the distortion factor of the VR postprocess.
  95766. * Please, touch with care.
  95767. */
  95768. distortionK: number[];
  95769. /**
  95770. * Define the chromatic aberration correction factors for the VR post process.
  95771. */
  95772. chromaAbCorrection: number[];
  95773. /**
  95774. * Define the scale factor of the post process.
  95775. * The smaller the better but the slower.
  95776. */
  95777. postProcessScaleFactor: number;
  95778. /**
  95779. * Define an offset for the lens center.
  95780. */
  95781. lensCenterOffset: number;
  95782. /**
  95783. * Define if the current vr camera should compensate the distortion of the lense or not.
  95784. */
  95785. compensateDistortion: boolean;
  95786. /**
  95787. * Gets the rendering aspect ratio based on the provided resolutions.
  95788. */
  95789. readonly aspectRatio: number;
  95790. /**
  95791. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  95792. */
  95793. readonly aspectRatioFov: number;
  95794. /**
  95795. * @hidden
  95796. */
  95797. readonly leftHMatrix: Matrix;
  95798. /**
  95799. * @hidden
  95800. */
  95801. readonly rightHMatrix: Matrix;
  95802. /**
  95803. * @hidden
  95804. */
  95805. readonly leftPreViewMatrix: Matrix;
  95806. /**
  95807. * @hidden
  95808. */
  95809. readonly rightPreViewMatrix: Matrix;
  95810. /**
  95811. * Get the default VRMetrics based on the most generic setup.
  95812. * @returns the default vr metrics
  95813. */
  95814. static GetDefault(): VRCameraMetrics;
  95815. }
  95816. }
  95817. declare module BABYLON {
  95818. /** @hidden */
  95819. export var vrDistortionCorrectionPixelShader: {
  95820. name: string;
  95821. shader: string;
  95822. };
  95823. }
  95824. declare module BABYLON {
  95825. /**
  95826. * VRDistortionCorrectionPostProcess used for mobile VR
  95827. */
  95828. export class VRDistortionCorrectionPostProcess extends PostProcess {
  95829. private _isRightEye;
  95830. private _distortionFactors;
  95831. private _postProcessScaleFactor;
  95832. private _lensCenterOffset;
  95833. private _scaleIn;
  95834. private _scaleFactor;
  95835. private _lensCenter;
  95836. /**
  95837. * Initializes the VRDistortionCorrectionPostProcess
  95838. * @param name The name of the effect.
  95839. * @param camera The camera to apply the render pass to.
  95840. * @param isRightEye If this is for the right eye distortion
  95841. * @param vrMetrics All the required metrics for the VR camera
  95842. */
  95843. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  95844. }
  95845. }
  95846. declare module BABYLON {
  95847. /**
  95848. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  95849. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95850. */
  95851. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  95852. /**
  95853. * Creates a new VRDeviceOrientationArcRotateCamera
  95854. * @param name defines camera name
  95855. * @param alpha defines the camera rotation along the logitudinal axis
  95856. * @param beta defines the camera rotation along the latitudinal axis
  95857. * @param radius defines the camera distance from its target
  95858. * @param target defines the camera target
  95859. * @param scene defines the scene the camera belongs to
  95860. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95861. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95862. */
  95863. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95864. /**
  95865. * Gets camera class name
  95866. * @returns VRDeviceOrientationArcRotateCamera
  95867. */
  95868. getClassName(): string;
  95869. }
  95870. }
  95871. declare module BABYLON {
  95872. /**
  95873. * Camera used to simulate VR rendering (based on FreeCamera)
  95874. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95875. */
  95876. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  95877. /**
  95878. * Creates a new VRDeviceOrientationFreeCamera
  95879. * @param name defines camera name
  95880. * @param position defines the start position of the camera
  95881. * @param scene defines the scene the camera belongs to
  95882. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95883. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95884. */
  95885. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95886. /**
  95887. * Gets camera class name
  95888. * @returns VRDeviceOrientationFreeCamera
  95889. */
  95890. getClassName(): string;
  95891. }
  95892. }
  95893. declare module BABYLON {
  95894. /**
  95895. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  95896. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95897. */
  95898. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  95899. /**
  95900. * Creates a new VRDeviceOrientationGamepadCamera
  95901. * @param name defines camera name
  95902. * @param position defines the start position of the camera
  95903. * @param scene defines the scene the camera belongs to
  95904. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95905. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95906. */
  95907. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95908. /**
  95909. * Gets camera class name
  95910. * @returns VRDeviceOrientationGamepadCamera
  95911. */
  95912. getClassName(): string;
  95913. }
  95914. }
  95915. declare module BABYLON {
  95916. /**
  95917. * Defines supported buttons for XBox360 compatible gamepads
  95918. */
  95919. export enum Xbox360Button {
  95920. /** A */
  95921. A = 0,
  95922. /** B */
  95923. B = 1,
  95924. /** X */
  95925. X = 2,
  95926. /** Y */
  95927. Y = 3,
  95928. /** Start */
  95929. Start = 4,
  95930. /** Back */
  95931. Back = 5,
  95932. /** Left button */
  95933. LB = 6,
  95934. /** Right button */
  95935. RB = 7,
  95936. /** Left stick */
  95937. LeftStick = 8,
  95938. /** Right stick */
  95939. RightStick = 9
  95940. }
  95941. /** Defines values for XBox360 DPad */
  95942. export enum Xbox360Dpad {
  95943. /** Up */
  95944. Up = 0,
  95945. /** Down */
  95946. Down = 1,
  95947. /** Left */
  95948. Left = 2,
  95949. /** Right */
  95950. Right = 3
  95951. }
  95952. /**
  95953. * Defines a XBox360 gamepad
  95954. */
  95955. export class Xbox360Pad extends Gamepad {
  95956. private _leftTrigger;
  95957. private _rightTrigger;
  95958. private _onlefttriggerchanged;
  95959. private _onrighttriggerchanged;
  95960. private _onbuttondown;
  95961. private _onbuttonup;
  95962. private _ondpaddown;
  95963. private _ondpadup;
  95964. /** Observable raised when a button is pressed */
  95965. onButtonDownObservable: Observable<Xbox360Button>;
  95966. /** Observable raised when a button is released */
  95967. onButtonUpObservable: Observable<Xbox360Button>;
  95968. /** Observable raised when a pad is pressed */
  95969. onPadDownObservable: Observable<Xbox360Dpad>;
  95970. /** Observable raised when a pad is released */
  95971. onPadUpObservable: Observable<Xbox360Dpad>;
  95972. private _buttonA;
  95973. private _buttonB;
  95974. private _buttonX;
  95975. private _buttonY;
  95976. private _buttonBack;
  95977. private _buttonStart;
  95978. private _buttonLB;
  95979. private _buttonRB;
  95980. private _buttonLeftStick;
  95981. private _buttonRightStick;
  95982. private _dPadUp;
  95983. private _dPadDown;
  95984. private _dPadLeft;
  95985. private _dPadRight;
  95986. private _isXboxOnePad;
  95987. /**
  95988. * Creates a new XBox360 gamepad object
  95989. * @param id defines the id of this gamepad
  95990. * @param index defines its index
  95991. * @param gamepad defines the internal HTML gamepad object
  95992. * @param xboxOne defines if it is a XBox One gamepad
  95993. */
  95994. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  95995. /**
  95996. * Defines the callback to call when left trigger is pressed
  95997. * @param callback defines the callback to use
  95998. */
  95999. onlefttriggerchanged(callback: (value: number) => void): void;
  96000. /**
  96001. * Defines the callback to call when right trigger is pressed
  96002. * @param callback defines the callback to use
  96003. */
  96004. onrighttriggerchanged(callback: (value: number) => void): void;
  96005. /**
  96006. * Gets the left trigger value
  96007. */
  96008. /**
  96009. * Sets the left trigger value
  96010. */
  96011. leftTrigger: number;
  96012. /**
  96013. * Gets the right trigger value
  96014. */
  96015. /**
  96016. * Sets the right trigger value
  96017. */
  96018. rightTrigger: number;
  96019. /**
  96020. * Defines the callback to call when a button is pressed
  96021. * @param callback defines the callback to use
  96022. */
  96023. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  96024. /**
  96025. * Defines the callback to call when a button is released
  96026. * @param callback defines the callback to use
  96027. */
  96028. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  96029. /**
  96030. * Defines the callback to call when a pad is pressed
  96031. * @param callback defines the callback to use
  96032. */
  96033. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  96034. /**
  96035. * Defines the callback to call when a pad is released
  96036. * @param callback defines the callback to use
  96037. */
  96038. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  96039. private _setButtonValue;
  96040. private _setDPadValue;
  96041. /**
  96042. * Gets the value of the `A` button
  96043. */
  96044. /**
  96045. * Sets the value of the `A` button
  96046. */
  96047. buttonA: number;
  96048. /**
  96049. * Gets the value of the `B` button
  96050. */
  96051. /**
  96052. * Sets the value of the `B` button
  96053. */
  96054. buttonB: number;
  96055. /**
  96056. * Gets the value of the `X` button
  96057. */
  96058. /**
  96059. * Sets the value of the `X` button
  96060. */
  96061. buttonX: number;
  96062. /**
  96063. * Gets the value of the `Y` button
  96064. */
  96065. /**
  96066. * Sets the value of the `Y` button
  96067. */
  96068. buttonY: number;
  96069. /**
  96070. * Gets the value of the `Start` button
  96071. */
  96072. /**
  96073. * Sets the value of the `Start` button
  96074. */
  96075. buttonStart: number;
  96076. /**
  96077. * Gets the value of the `Back` button
  96078. */
  96079. /**
  96080. * Sets the value of the `Back` button
  96081. */
  96082. buttonBack: number;
  96083. /**
  96084. * Gets the value of the `Left` button
  96085. */
  96086. /**
  96087. * Sets the value of the `Left` button
  96088. */
  96089. buttonLB: number;
  96090. /**
  96091. * Gets the value of the `Right` button
  96092. */
  96093. /**
  96094. * Sets the value of the `Right` button
  96095. */
  96096. buttonRB: number;
  96097. /**
  96098. * Gets the value of the Left joystick
  96099. */
  96100. /**
  96101. * Sets the value of the Left joystick
  96102. */
  96103. buttonLeftStick: number;
  96104. /**
  96105. * Gets the value of the Right joystick
  96106. */
  96107. /**
  96108. * Sets the value of the Right joystick
  96109. */
  96110. buttonRightStick: number;
  96111. /**
  96112. * Gets the value of D-pad up
  96113. */
  96114. /**
  96115. * Sets the value of D-pad up
  96116. */
  96117. dPadUp: number;
  96118. /**
  96119. * Gets the value of D-pad down
  96120. */
  96121. /**
  96122. * Sets the value of D-pad down
  96123. */
  96124. dPadDown: number;
  96125. /**
  96126. * Gets the value of D-pad left
  96127. */
  96128. /**
  96129. * Sets the value of D-pad left
  96130. */
  96131. dPadLeft: number;
  96132. /**
  96133. * Gets the value of D-pad right
  96134. */
  96135. /**
  96136. * Sets the value of D-pad right
  96137. */
  96138. dPadRight: number;
  96139. /**
  96140. * Force the gamepad to synchronize with device values
  96141. */
  96142. update(): void;
  96143. /**
  96144. * Disposes the gamepad
  96145. */
  96146. dispose(): void;
  96147. }
  96148. }
  96149. declare module BABYLON {
  96150. /**
  96151. * Base class of materials working in push mode in babylon JS
  96152. * @hidden
  96153. */
  96154. export class PushMaterial extends Material {
  96155. protected _activeEffect: Effect;
  96156. protected _normalMatrix: Matrix;
  96157. /**
  96158. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96159. * This means that the material can keep using a previous shader while a new one is being compiled.
  96160. * This is mostly used when shader parallel compilation is supported (true by default)
  96161. */
  96162. allowShaderHotSwapping: boolean;
  96163. constructor(name: string, scene: Scene);
  96164. getEffect(): Effect;
  96165. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96166. /**
  96167. * Binds the given world matrix to the active effect
  96168. *
  96169. * @param world the matrix to bind
  96170. */
  96171. bindOnlyWorldMatrix(world: Matrix): void;
  96172. /**
  96173. * Binds the given normal matrix to the active effect
  96174. *
  96175. * @param normalMatrix the matrix to bind
  96176. */
  96177. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96178. bind(world: Matrix, mesh?: Mesh): void;
  96179. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96180. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96181. }
  96182. }
  96183. declare module BABYLON {
  96184. /**
  96185. * This groups all the flags used to control the materials channel.
  96186. */
  96187. export class MaterialFlags {
  96188. private static _DiffuseTextureEnabled;
  96189. /**
  96190. * Are diffuse textures enabled in the application.
  96191. */
  96192. static DiffuseTextureEnabled: boolean;
  96193. private static _AmbientTextureEnabled;
  96194. /**
  96195. * Are ambient textures enabled in the application.
  96196. */
  96197. static AmbientTextureEnabled: boolean;
  96198. private static _OpacityTextureEnabled;
  96199. /**
  96200. * Are opacity textures enabled in the application.
  96201. */
  96202. static OpacityTextureEnabled: boolean;
  96203. private static _ReflectionTextureEnabled;
  96204. /**
  96205. * Are reflection textures enabled in the application.
  96206. */
  96207. static ReflectionTextureEnabled: boolean;
  96208. private static _EmissiveTextureEnabled;
  96209. /**
  96210. * Are emissive textures enabled in the application.
  96211. */
  96212. static EmissiveTextureEnabled: boolean;
  96213. private static _SpecularTextureEnabled;
  96214. /**
  96215. * Are specular textures enabled in the application.
  96216. */
  96217. static SpecularTextureEnabled: boolean;
  96218. private static _BumpTextureEnabled;
  96219. /**
  96220. * Are bump textures enabled in the application.
  96221. */
  96222. static BumpTextureEnabled: boolean;
  96223. private static _LightmapTextureEnabled;
  96224. /**
  96225. * Are lightmap textures enabled in the application.
  96226. */
  96227. static LightmapTextureEnabled: boolean;
  96228. private static _RefractionTextureEnabled;
  96229. /**
  96230. * Are refraction textures enabled in the application.
  96231. */
  96232. static RefractionTextureEnabled: boolean;
  96233. private static _ColorGradingTextureEnabled;
  96234. /**
  96235. * Are color grading textures enabled in the application.
  96236. */
  96237. static ColorGradingTextureEnabled: boolean;
  96238. private static _FresnelEnabled;
  96239. /**
  96240. * Are fresnels enabled in the application.
  96241. */
  96242. static FresnelEnabled: boolean;
  96243. private static _ClearCoatTextureEnabled;
  96244. /**
  96245. * Are clear coat textures enabled in the application.
  96246. */
  96247. static ClearCoatTextureEnabled: boolean;
  96248. private static _ClearCoatBumpTextureEnabled;
  96249. /**
  96250. * Are clear coat bump textures enabled in the application.
  96251. */
  96252. static ClearCoatBumpTextureEnabled: boolean;
  96253. private static _ClearCoatTintTextureEnabled;
  96254. /**
  96255. * Are clear coat tint textures enabled in the application.
  96256. */
  96257. static ClearCoatTintTextureEnabled: boolean;
  96258. private static _SheenTextureEnabled;
  96259. /**
  96260. * Are sheen textures enabled in the application.
  96261. */
  96262. static SheenTextureEnabled: boolean;
  96263. private static _AnisotropicTextureEnabled;
  96264. /**
  96265. * Are anisotropic textures enabled in the application.
  96266. */
  96267. static AnisotropicTextureEnabled: boolean;
  96268. }
  96269. }
  96270. declare module BABYLON {
  96271. /** @hidden */
  96272. export var defaultFragmentDeclaration: {
  96273. name: string;
  96274. shader: string;
  96275. };
  96276. }
  96277. declare module BABYLON {
  96278. /** @hidden */
  96279. export var defaultUboDeclaration: {
  96280. name: string;
  96281. shader: string;
  96282. };
  96283. }
  96284. declare module BABYLON {
  96285. /** @hidden */
  96286. export var lightFragmentDeclaration: {
  96287. name: string;
  96288. shader: string;
  96289. };
  96290. }
  96291. declare module BABYLON {
  96292. /** @hidden */
  96293. export var lightUboDeclaration: {
  96294. name: string;
  96295. shader: string;
  96296. };
  96297. }
  96298. declare module BABYLON {
  96299. /** @hidden */
  96300. export var lightsFragmentFunctions: {
  96301. name: string;
  96302. shader: string;
  96303. };
  96304. }
  96305. declare module BABYLON {
  96306. /** @hidden */
  96307. export var shadowsFragmentFunctions: {
  96308. name: string;
  96309. shader: string;
  96310. };
  96311. }
  96312. declare module BABYLON {
  96313. /** @hidden */
  96314. export var fresnelFunction: {
  96315. name: string;
  96316. shader: string;
  96317. };
  96318. }
  96319. declare module BABYLON {
  96320. /** @hidden */
  96321. export var reflectionFunction: {
  96322. name: string;
  96323. shader: string;
  96324. };
  96325. }
  96326. declare module BABYLON {
  96327. /** @hidden */
  96328. export var bumpFragmentFunctions: {
  96329. name: string;
  96330. shader: string;
  96331. };
  96332. }
  96333. declare module BABYLON {
  96334. /** @hidden */
  96335. export var logDepthDeclaration: {
  96336. name: string;
  96337. shader: string;
  96338. };
  96339. }
  96340. declare module BABYLON {
  96341. /** @hidden */
  96342. export var bumpFragment: {
  96343. name: string;
  96344. shader: string;
  96345. };
  96346. }
  96347. declare module BABYLON {
  96348. /** @hidden */
  96349. export var depthPrePass: {
  96350. name: string;
  96351. shader: string;
  96352. };
  96353. }
  96354. declare module BABYLON {
  96355. /** @hidden */
  96356. export var lightFragment: {
  96357. name: string;
  96358. shader: string;
  96359. };
  96360. }
  96361. declare module BABYLON {
  96362. /** @hidden */
  96363. export var logDepthFragment: {
  96364. name: string;
  96365. shader: string;
  96366. };
  96367. }
  96368. declare module BABYLON {
  96369. /** @hidden */
  96370. export var defaultPixelShader: {
  96371. name: string;
  96372. shader: string;
  96373. };
  96374. }
  96375. declare module BABYLON {
  96376. /** @hidden */
  96377. export var defaultVertexDeclaration: {
  96378. name: string;
  96379. shader: string;
  96380. };
  96381. }
  96382. declare module BABYLON {
  96383. /** @hidden */
  96384. export var bumpVertexDeclaration: {
  96385. name: string;
  96386. shader: string;
  96387. };
  96388. }
  96389. declare module BABYLON {
  96390. /** @hidden */
  96391. export var bumpVertex: {
  96392. name: string;
  96393. shader: string;
  96394. };
  96395. }
  96396. declare module BABYLON {
  96397. /** @hidden */
  96398. export var fogVertex: {
  96399. name: string;
  96400. shader: string;
  96401. };
  96402. }
  96403. declare module BABYLON {
  96404. /** @hidden */
  96405. export var shadowsVertex: {
  96406. name: string;
  96407. shader: string;
  96408. };
  96409. }
  96410. declare module BABYLON {
  96411. /** @hidden */
  96412. export var pointCloudVertex: {
  96413. name: string;
  96414. shader: string;
  96415. };
  96416. }
  96417. declare module BABYLON {
  96418. /** @hidden */
  96419. export var logDepthVertex: {
  96420. name: string;
  96421. shader: string;
  96422. };
  96423. }
  96424. declare module BABYLON {
  96425. /** @hidden */
  96426. export var defaultVertexShader: {
  96427. name: string;
  96428. shader: string;
  96429. };
  96430. }
  96431. declare module BABYLON {
  96432. /** @hidden */
  96433. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96434. MAINUV1: boolean;
  96435. MAINUV2: boolean;
  96436. DIFFUSE: boolean;
  96437. DIFFUSEDIRECTUV: number;
  96438. AMBIENT: boolean;
  96439. AMBIENTDIRECTUV: number;
  96440. OPACITY: boolean;
  96441. OPACITYDIRECTUV: number;
  96442. OPACITYRGB: boolean;
  96443. REFLECTION: boolean;
  96444. EMISSIVE: boolean;
  96445. EMISSIVEDIRECTUV: number;
  96446. SPECULAR: boolean;
  96447. SPECULARDIRECTUV: number;
  96448. BUMP: boolean;
  96449. BUMPDIRECTUV: number;
  96450. PARALLAX: boolean;
  96451. PARALLAXOCCLUSION: boolean;
  96452. SPECULAROVERALPHA: boolean;
  96453. CLIPPLANE: boolean;
  96454. CLIPPLANE2: boolean;
  96455. CLIPPLANE3: boolean;
  96456. CLIPPLANE4: boolean;
  96457. ALPHATEST: boolean;
  96458. DEPTHPREPASS: boolean;
  96459. ALPHAFROMDIFFUSE: boolean;
  96460. POINTSIZE: boolean;
  96461. FOG: boolean;
  96462. SPECULARTERM: boolean;
  96463. DIFFUSEFRESNEL: boolean;
  96464. OPACITYFRESNEL: boolean;
  96465. REFLECTIONFRESNEL: boolean;
  96466. REFRACTIONFRESNEL: boolean;
  96467. EMISSIVEFRESNEL: boolean;
  96468. FRESNEL: boolean;
  96469. NORMAL: boolean;
  96470. UV1: boolean;
  96471. UV2: boolean;
  96472. VERTEXCOLOR: boolean;
  96473. VERTEXALPHA: boolean;
  96474. NUM_BONE_INFLUENCERS: number;
  96475. BonesPerMesh: number;
  96476. BONETEXTURE: boolean;
  96477. INSTANCES: boolean;
  96478. GLOSSINESS: boolean;
  96479. ROUGHNESS: boolean;
  96480. EMISSIVEASILLUMINATION: boolean;
  96481. LINKEMISSIVEWITHDIFFUSE: boolean;
  96482. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96483. LIGHTMAP: boolean;
  96484. LIGHTMAPDIRECTUV: number;
  96485. OBJECTSPACE_NORMALMAP: boolean;
  96486. USELIGHTMAPASSHADOWMAP: boolean;
  96487. REFLECTIONMAP_3D: boolean;
  96488. REFLECTIONMAP_SPHERICAL: boolean;
  96489. REFLECTIONMAP_PLANAR: boolean;
  96490. REFLECTIONMAP_CUBIC: boolean;
  96491. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96492. REFLECTIONMAP_PROJECTION: boolean;
  96493. REFLECTIONMAP_SKYBOX: boolean;
  96494. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96495. REFLECTIONMAP_EXPLICIT: boolean;
  96496. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96497. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96498. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96499. INVERTCUBICMAP: boolean;
  96500. LOGARITHMICDEPTH: boolean;
  96501. REFRACTION: boolean;
  96502. REFRACTIONMAP_3D: boolean;
  96503. REFLECTIONOVERALPHA: boolean;
  96504. TWOSIDEDLIGHTING: boolean;
  96505. SHADOWFLOAT: boolean;
  96506. MORPHTARGETS: boolean;
  96507. MORPHTARGETS_NORMAL: boolean;
  96508. MORPHTARGETS_TANGENT: boolean;
  96509. NUM_MORPH_INFLUENCERS: number;
  96510. NONUNIFORMSCALING: boolean;
  96511. PREMULTIPLYALPHA: boolean;
  96512. IMAGEPROCESSING: boolean;
  96513. VIGNETTE: boolean;
  96514. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96515. VIGNETTEBLENDMODEOPAQUE: boolean;
  96516. TONEMAPPING: boolean;
  96517. TONEMAPPING_ACES: boolean;
  96518. CONTRAST: boolean;
  96519. COLORCURVES: boolean;
  96520. COLORGRADING: boolean;
  96521. COLORGRADING3D: boolean;
  96522. SAMPLER3DGREENDEPTH: boolean;
  96523. SAMPLER3DBGRMAP: boolean;
  96524. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96525. /**
  96526. * If the reflection texture on this material is in linear color space
  96527. * @hidden
  96528. */
  96529. IS_REFLECTION_LINEAR: boolean;
  96530. /**
  96531. * If the refraction texture on this material is in linear color space
  96532. * @hidden
  96533. */
  96534. IS_REFRACTION_LINEAR: boolean;
  96535. EXPOSURE: boolean;
  96536. constructor();
  96537. setReflectionMode(modeToEnable: string): void;
  96538. }
  96539. /**
  96540. * This is the default material used in Babylon. It is the best trade off between quality
  96541. * and performances.
  96542. * @see http://doc.babylonjs.com/babylon101/materials
  96543. */
  96544. export class StandardMaterial extends PushMaterial {
  96545. private _diffuseTexture;
  96546. /**
  96547. * The basic texture of the material as viewed under a light.
  96548. */
  96549. diffuseTexture: Nullable<BaseTexture>;
  96550. private _ambientTexture;
  96551. /**
  96552. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96553. */
  96554. ambientTexture: Nullable<BaseTexture>;
  96555. private _opacityTexture;
  96556. /**
  96557. * Define the transparency of the material from a texture.
  96558. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96559. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96560. */
  96561. opacityTexture: Nullable<BaseTexture>;
  96562. private _reflectionTexture;
  96563. /**
  96564. * Define the texture used to display the reflection.
  96565. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96566. */
  96567. reflectionTexture: Nullable<BaseTexture>;
  96568. private _emissiveTexture;
  96569. /**
  96570. * Define texture of the material as if self lit.
  96571. * This will be mixed in the final result even in the absence of light.
  96572. */
  96573. emissiveTexture: Nullable<BaseTexture>;
  96574. private _specularTexture;
  96575. /**
  96576. * Define how the color and intensity of the highlight given by the light in the material.
  96577. */
  96578. specularTexture: Nullable<BaseTexture>;
  96579. private _bumpTexture;
  96580. /**
  96581. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96582. * 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.
  96583. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96584. */
  96585. bumpTexture: Nullable<BaseTexture>;
  96586. private _lightmapTexture;
  96587. /**
  96588. * Complex lighting can be computationally expensive to compute at runtime.
  96589. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96590. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96591. */
  96592. lightmapTexture: Nullable<BaseTexture>;
  96593. private _refractionTexture;
  96594. /**
  96595. * Define the texture used to display the refraction.
  96596. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96597. */
  96598. refractionTexture: Nullable<BaseTexture>;
  96599. /**
  96600. * The color of the material lit by the environmental background lighting.
  96601. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96602. */
  96603. ambientColor: Color3;
  96604. /**
  96605. * The basic color of the material as viewed under a light.
  96606. */
  96607. diffuseColor: Color3;
  96608. /**
  96609. * Define how the color and intensity of the highlight given by the light in the material.
  96610. */
  96611. specularColor: Color3;
  96612. /**
  96613. * Define the color of the material as if self lit.
  96614. * This will be mixed in the final result even in the absence of light.
  96615. */
  96616. emissiveColor: Color3;
  96617. /**
  96618. * Defines how sharp are the highlights in the material.
  96619. * The bigger the value the sharper giving a more glossy feeling to the result.
  96620. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96621. */
  96622. specularPower: number;
  96623. private _useAlphaFromDiffuseTexture;
  96624. /**
  96625. * Does the transparency come from the diffuse texture alpha channel.
  96626. */
  96627. useAlphaFromDiffuseTexture: boolean;
  96628. private _useEmissiveAsIllumination;
  96629. /**
  96630. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96631. */
  96632. useEmissiveAsIllumination: boolean;
  96633. private _linkEmissiveWithDiffuse;
  96634. /**
  96635. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96636. * the emissive level when the final color is close to one.
  96637. */
  96638. linkEmissiveWithDiffuse: boolean;
  96639. private _useSpecularOverAlpha;
  96640. /**
  96641. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96643. */
  96644. useSpecularOverAlpha: boolean;
  96645. private _useReflectionOverAlpha;
  96646. /**
  96647. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96648. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96649. */
  96650. useReflectionOverAlpha: boolean;
  96651. private _disableLighting;
  96652. /**
  96653. * Does lights from the scene impacts this material.
  96654. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96655. */
  96656. disableLighting: boolean;
  96657. private _useObjectSpaceNormalMap;
  96658. /**
  96659. * Allows using an object space normal map (instead of tangent space).
  96660. */
  96661. useObjectSpaceNormalMap: boolean;
  96662. private _useParallax;
  96663. /**
  96664. * Is parallax enabled or not.
  96665. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96666. */
  96667. useParallax: boolean;
  96668. private _useParallaxOcclusion;
  96669. /**
  96670. * Is parallax occlusion enabled or not.
  96671. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96672. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96673. */
  96674. useParallaxOcclusion: boolean;
  96675. /**
  96676. * 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.
  96677. */
  96678. parallaxScaleBias: number;
  96679. private _roughness;
  96680. /**
  96681. * Helps to define how blurry the reflections should appears in the material.
  96682. */
  96683. roughness: number;
  96684. /**
  96685. * In case of refraction, define the value of the indice of refraction.
  96686. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96687. */
  96688. indexOfRefraction: number;
  96689. /**
  96690. * Invert the refraction texture alongside the y axis.
  96691. * It can be useful with procedural textures or probe for instance.
  96692. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96693. */
  96694. invertRefractionY: boolean;
  96695. /**
  96696. * Defines the alpha limits in alpha test mode.
  96697. */
  96698. alphaCutOff: number;
  96699. private _useLightmapAsShadowmap;
  96700. /**
  96701. * In case of light mapping, define whether the map contains light or shadow informations.
  96702. */
  96703. useLightmapAsShadowmap: boolean;
  96704. private _diffuseFresnelParameters;
  96705. /**
  96706. * Define the diffuse fresnel parameters of the material.
  96707. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96708. */
  96709. diffuseFresnelParameters: FresnelParameters;
  96710. private _opacityFresnelParameters;
  96711. /**
  96712. * Define the opacity fresnel parameters of the material.
  96713. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96714. */
  96715. opacityFresnelParameters: FresnelParameters;
  96716. private _reflectionFresnelParameters;
  96717. /**
  96718. * Define the reflection fresnel parameters of the material.
  96719. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96720. */
  96721. reflectionFresnelParameters: FresnelParameters;
  96722. private _refractionFresnelParameters;
  96723. /**
  96724. * Define the refraction fresnel parameters of the material.
  96725. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96726. */
  96727. refractionFresnelParameters: FresnelParameters;
  96728. private _emissiveFresnelParameters;
  96729. /**
  96730. * Define the emissive fresnel parameters of the material.
  96731. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96732. */
  96733. emissiveFresnelParameters: FresnelParameters;
  96734. private _useReflectionFresnelFromSpecular;
  96735. /**
  96736. * If true automatically deducts the fresnels values from the material specularity.
  96737. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96738. */
  96739. useReflectionFresnelFromSpecular: boolean;
  96740. private _useGlossinessFromSpecularMapAlpha;
  96741. /**
  96742. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96743. */
  96744. useGlossinessFromSpecularMapAlpha: boolean;
  96745. private _maxSimultaneousLights;
  96746. /**
  96747. * Defines the maximum number of lights that can be used in the material
  96748. */
  96749. maxSimultaneousLights: number;
  96750. private _invertNormalMapX;
  96751. /**
  96752. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96753. */
  96754. invertNormalMapX: boolean;
  96755. private _invertNormalMapY;
  96756. /**
  96757. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96758. */
  96759. invertNormalMapY: boolean;
  96760. private _twoSidedLighting;
  96761. /**
  96762. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96763. */
  96764. twoSidedLighting: boolean;
  96765. /**
  96766. * Default configuration related to image processing available in the standard Material.
  96767. */
  96768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96769. /**
  96770. * Gets the image processing configuration used either in this material.
  96771. */
  96772. /**
  96773. * Sets the Default image processing configuration used either in the this material.
  96774. *
  96775. * If sets to null, the scene one is in use.
  96776. */
  96777. imageProcessingConfiguration: ImageProcessingConfiguration;
  96778. /**
  96779. * Keep track of the image processing observer to allow dispose and replace.
  96780. */
  96781. private _imageProcessingObserver;
  96782. /**
  96783. * Attaches a new image processing configuration to the Standard Material.
  96784. * @param configuration
  96785. */
  96786. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96787. /**
  96788. * Gets wether the color curves effect is enabled.
  96789. */
  96790. /**
  96791. * Sets wether the color curves effect is enabled.
  96792. */
  96793. cameraColorCurvesEnabled: boolean;
  96794. /**
  96795. * Gets wether the color grading effect is enabled.
  96796. */
  96797. /**
  96798. * Gets wether the color grading effect is enabled.
  96799. */
  96800. cameraColorGradingEnabled: boolean;
  96801. /**
  96802. * Gets wether tonemapping is enabled or not.
  96803. */
  96804. /**
  96805. * Sets wether tonemapping is enabled or not
  96806. */
  96807. cameraToneMappingEnabled: boolean;
  96808. /**
  96809. * The camera exposure used on this material.
  96810. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96811. * This corresponds to a photographic exposure.
  96812. */
  96813. /**
  96814. * The camera exposure used on this material.
  96815. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96816. * This corresponds to a photographic exposure.
  96817. */
  96818. cameraExposure: number;
  96819. /**
  96820. * Gets The camera contrast used on this material.
  96821. */
  96822. /**
  96823. * Sets The camera contrast used on this material.
  96824. */
  96825. cameraContrast: number;
  96826. /**
  96827. * Gets the Color Grading 2D Lookup Texture.
  96828. */
  96829. /**
  96830. * Sets the Color Grading 2D Lookup Texture.
  96831. */
  96832. cameraColorGradingTexture: Nullable<BaseTexture>;
  96833. /**
  96834. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96835. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96836. * 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;
  96837. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96838. */
  96839. /**
  96840. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96841. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96842. * 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;
  96843. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96844. */
  96845. cameraColorCurves: Nullable<ColorCurves>;
  96846. /**
  96847. * Custom callback helping to override the default shader used in the material.
  96848. */
  96849. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  96850. protected _renderTargets: SmartArray<RenderTargetTexture>;
  96851. protected _worldViewProjectionMatrix: Matrix;
  96852. protected _globalAmbientColor: Color3;
  96853. protected _useLogarithmicDepth: boolean;
  96854. /**
  96855. * Instantiates a new standard material.
  96856. * This is the default material used in Babylon. It is the best trade off between quality
  96857. * and performances.
  96858. * @see http://doc.babylonjs.com/babylon101/materials
  96859. * @param name Define the name of the material in the scene
  96860. * @param scene Define the scene the material belong to
  96861. */
  96862. constructor(name: string, scene: Scene);
  96863. /**
  96864. * Gets a boolean indicating that current material needs to register RTT
  96865. */
  96866. readonly hasRenderTargetTextures: boolean;
  96867. /**
  96868. * Gets the current class name of the material e.g. "StandardMaterial"
  96869. * Mainly use in serialization.
  96870. * @returns the class name
  96871. */
  96872. getClassName(): string;
  96873. /**
  96874. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  96875. * You can try switching to logarithmic depth.
  96876. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  96877. */
  96878. useLogarithmicDepth: boolean;
  96879. /**
  96880. * Specifies if the material will require alpha blending
  96881. * @returns a boolean specifying if alpha blending is needed
  96882. */
  96883. needAlphaBlending(): boolean;
  96884. /**
  96885. * Specifies if this material should be rendered in alpha test mode
  96886. * @returns a boolean specifying if an alpha test is needed.
  96887. */
  96888. needAlphaTesting(): boolean;
  96889. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  96890. /**
  96891. * Get the texture used for alpha test purpose.
  96892. * @returns the diffuse texture in case of the standard material.
  96893. */
  96894. getAlphaTestTexture(): Nullable<BaseTexture>;
  96895. /**
  96896. * Get if the submesh is ready to be used and all its information available.
  96897. * Child classes can use it to update shaders
  96898. * @param mesh defines the mesh to check
  96899. * @param subMesh defines which submesh to check
  96900. * @param useInstances specifies that instances should be used
  96901. * @returns a boolean indicating that the submesh is ready or not
  96902. */
  96903. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96904. /**
  96905. * Builds the material UBO layouts.
  96906. * Used internally during the effect preparation.
  96907. */
  96908. buildUniformLayout(): void;
  96909. /**
  96910. * Unbinds the material from the mesh
  96911. */
  96912. unbind(): void;
  96913. /**
  96914. * Binds the submesh to this material by preparing the effect and shader to draw
  96915. * @param world defines the world transformation matrix
  96916. * @param mesh defines the mesh containing the submesh
  96917. * @param subMesh defines the submesh to bind the material to
  96918. */
  96919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96920. /**
  96921. * Get the list of animatables in the material.
  96922. * @returns the list of animatables object used in the material
  96923. */
  96924. getAnimatables(): IAnimatable[];
  96925. /**
  96926. * Gets the active textures from the material
  96927. * @returns an array of textures
  96928. */
  96929. getActiveTextures(): BaseTexture[];
  96930. /**
  96931. * Specifies if the material uses a texture
  96932. * @param texture defines the texture to check against the material
  96933. * @returns a boolean specifying if the material uses the texture
  96934. */
  96935. hasTexture(texture: BaseTexture): boolean;
  96936. /**
  96937. * Disposes the material
  96938. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96939. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96940. */
  96941. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  96942. /**
  96943. * Makes a duplicate of the material, and gives it a new name
  96944. * @param name defines the new name for the duplicated material
  96945. * @returns the cloned material
  96946. */
  96947. clone(name: string): StandardMaterial;
  96948. /**
  96949. * Serializes this material in a JSON representation
  96950. * @returns the serialized material object
  96951. */
  96952. serialize(): any;
  96953. /**
  96954. * Creates a standard material from parsed material data
  96955. * @param source defines the JSON representation of the material
  96956. * @param scene defines the hosting scene
  96957. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96958. * @returns a new standard material
  96959. */
  96960. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  96961. /**
  96962. * Are diffuse textures enabled in the application.
  96963. */
  96964. static DiffuseTextureEnabled: boolean;
  96965. /**
  96966. * Are ambient textures enabled in the application.
  96967. */
  96968. static AmbientTextureEnabled: boolean;
  96969. /**
  96970. * Are opacity textures enabled in the application.
  96971. */
  96972. static OpacityTextureEnabled: boolean;
  96973. /**
  96974. * Are reflection textures enabled in the application.
  96975. */
  96976. static ReflectionTextureEnabled: boolean;
  96977. /**
  96978. * Are emissive textures enabled in the application.
  96979. */
  96980. static EmissiveTextureEnabled: boolean;
  96981. /**
  96982. * Are specular textures enabled in the application.
  96983. */
  96984. static SpecularTextureEnabled: boolean;
  96985. /**
  96986. * Are bump textures enabled in the application.
  96987. */
  96988. static BumpTextureEnabled: boolean;
  96989. /**
  96990. * Are lightmap textures enabled in the application.
  96991. */
  96992. static LightmapTextureEnabled: boolean;
  96993. /**
  96994. * Are refraction textures enabled in the application.
  96995. */
  96996. static RefractionTextureEnabled: boolean;
  96997. /**
  96998. * Are color grading textures enabled in the application.
  96999. */
  97000. static ColorGradingTextureEnabled: boolean;
  97001. /**
  97002. * Are fresnels enabled in the application.
  97003. */
  97004. static FresnelEnabled: boolean;
  97005. }
  97006. }
  97007. declare module BABYLON {
  97008. /**
  97009. * A class extending Texture allowing drawing on a texture
  97010. * @see http://doc.babylonjs.com/how_to/dynamictexture
  97011. */
  97012. export class DynamicTexture extends Texture {
  97013. private _generateMipMaps;
  97014. private _canvas;
  97015. private _context;
  97016. private _engine;
  97017. /**
  97018. * Creates a DynamicTexture
  97019. * @param name defines the name of the texture
  97020. * @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
  97021. * @param scene defines the scene where you want the texture
  97022. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  97023. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  97024. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  97025. */
  97026. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  97027. /**
  97028. * Get the current class name of the texture useful for serialization or dynamic coding.
  97029. * @returns "DynamicTexture"
  97030. */
  97031. getClassName(): string;
  97032. /**
  97033. * Gets the current state of canRescale
  97034. */
  97035. readonly canRescale: boolean;
  97036. private _recreate;
  97037. /**
  97038. * Scales the texture
  97039. * @param ratio the scale factor to apply to both width and height
  97040. */
  97041. scale(ratio: number): void;
  97042. /**
  97043. * Resizes the texture
  97044. * @param width the new width
  97045. * @param height the new height
  97046. */
  97047. scaleTo(width: number, height: number): void;
  97048. /**
  97049. * Gets the context of the canvas used by the texture
  97050. * @returns the canvas context of the dynamic texture
  97051. */
  97052. getContext(): CanvasRenderingContext2D;
  97053. /**
  97054. * Clears the texture
  97055. */
  97056. clear(): void;
  97057. /**
  97058. * Updates the texture
  97059. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97060. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  97061. */
  97062. update(invertY?: boolean, premulAlpha?: boolean): void;
  97063. /**
  97064. * Draws text onto the texture
  97065. * @param text defines the text to be drawn
  97066. * @param x defines the placement of the text from the left
  97067. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  97068. * @param font defines the font to be used with font-style, font-size, font-name
  97069. * @param color defines the color used for the text
  97070. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  97071. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97072. * @param update defines whether texture is immediately update (default is true)
  97073. */
  97074. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  97075. /**
  97076. * Clones the texture
  97077. * @returns the clone of the texture.
  97078. */
  97079. clone(): DynamicTexture;
  97080. /**
  97081. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  97082. * @returns a serialized dynamic texture object
  97083. */
  97084. serialize(): any;
  97085. /** @hidden */
  97086. _rebuild(): void;
  97087. }
  97088. }
  97089. declare module BABYLON {
  97090. /** @hidden */
  97091. export var imageProcessingPixelShader: {
  97092. name: string;
  97093. shader: string;
  97094. };
  97095. }
  97096. declare module BABYLON {
  97097. /**
  97098. * ImageProcessingPostProcess
  97099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  97100. */
  97101. export class ImageProcessingPostProcess extends PostProcess {
  97102. /**
  97103. * Default configuration related to image processing available in the PBR Material.
  97104. */
  97105. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97106. /**
  97107. * Gets the image processing configuration used either in this material.
  97108. */
  97109. /**
  97110. * Sets the Default image processing configuration used either in the this material.
  97111. *
  97112. * If sets to null, the scene one is in use.
  97113. */
  97114. imageProcessingConfiguration: ImageProcessingConfiguration;
  97115. /**
  97116. * Keep track of the image processing observer to allow dispose and replace.
  97117. */
  97118. private _imageProcessingObserver;
  97119. /**
  97120. * Attaches a new image processing configuration to the PBR Material.
  97121. * @param configuration
  97122. */
  97123. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  97124. /**
  97125. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97126. */
  97127. /**
  97128. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97129. */
  97130. colorCurves: Nullable<ColorCurves>;
  97131. /**
  97132. * Gets wether the color curves effect is enabled.
  97133. */
  97134. /**
  97135. * Sets wether the color curves effect is enabled.
  97136. */
  97137. colorCurvesEnabled: boolean;
  97138. /**
  97139. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97140. */
  97141. /**
  97142. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97143. */
  97144. colorGradingTexture: Nullable<BaseTexture>;
  97145. /**
  97146. * Gets wether the color grading effect is enabled.
  97147. */
  97148. /**
  97149. * Gets wether the color grading effect is enabled.
  97150. */
  97151. colorGradingEnabled: boolean;
  97152. /**
  97153. * Gets exposure used in the effect.
  97154. */
  97155. /**
  97156. * Sets exposure used in the effect.
  97157. */
  97158. exposure: number;
  97159. /**
  97160. * Gets wether tonemapping is enabled or not.
  97161. */
  97162. /**
  97163. * Sets wether tonemapping is enabled or not
  97164. */
  97165. toneMappingEnabled: boolean;
  97166. /**
  97167. * Gets the type of tone mapping effect.
  97168. */
  97169. /**
  97170. * Sets the type of tone mapping effect.
  97171. */
  97172. toneMappingType: number;
  97173. /**
  97174. * Gets contrast used in the effect.
  97175. */
  97176. /**
  97177. * Sets contrast used in the effect.
  97178. */
  97179. contrast: number;
  97180. /**
  97181. * Gets Vignette stretch size.
  97182. */
  97183. /**
  97184. * Sets Vignette stretch size.
  97185. */
  97186. vignetteStretch: number;
  97187. /**
  97188. * Gets Vignette centre X Offset.
  97189. */
  97190. /**
  97191. * Sets Vignette centre X Offset.
  97192. */
  97193. vignetteCentreX: number;
  97194. /**
  97195. * Gets Vignette centre Y Offset.
  97196. */
  97197. /**
  97198. * Sets Vignette centre Y Offset.
  97199. */
  97200. vignetteCentreY: number;
  97201. /**
  97202. * Gets Vignette weight or intensity of the vignette effect.
  97203. */
  97204. /**
  97205. * Sets Vignette weight or intensity of the vignette effect.
  97206. */
  97207. vignetteWeight: number;
  97208. /**
  97209. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97210. * if vignetteEnabled is set to true.
  97211. */
  97212. /**
  97213. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97214. * if vignetteEnabled is set to true.
  97215. */
  97216. vignetteColor: Color4;
  97217. /**
  97218. * Gets Camera field of view used by the Vignette effect.
  97219. */
  97220. /**
  97221. * Sets Camera field of view used by the Vignette effect.
  97222. */
  97223. vignetteCameraFov: number;
  97224. /**
  97225. * Gets the vignette blend mode allowing different kind of effect.
  97226. */
  97227. /**
  97228. * Sets the vignette blend mode allowing different kind of effect.
  97229. */
  97230. vignetteBlendMode: number;
  97231. /**
  97232. * Gets wether the vignette effect is enabled.
  97233. */
  97234. /**
  97235. * Sets wether the vignette effect is enabled.
  97236. */
  97237. vignetteEnabled: boolean;
  97238. private _fromLinearSpace;
  97239. /**
  97240. * Gets wether the input of the processing is in Gamma or Linear Space.
  97241. */
  97242. /**
  97243. * Sets wether the input of the processing is in Gamma or Linear Space.
  97244. */
  97245. fromLinearSpace: boolean;
  97246. /**
  97247. * Defines cache preventing GC.
  97248. */
  97249. private _defines;
  97250. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  97251. /**
  97252. * "ImageProcessingPostProcess"
  97253. * @returns "ImageProcessingPostProcess"
  97254. */
  97255. getClassName(): string;
  97256. protected _updateParameters(): void;
  97257. dispose(camera?: Camera): void;
  97258. }
  97259. }
  97260. declare module BABYLON {
  97261. /**
  97262. * Class containing static functions to help procedurally build meshes
  97263. */
  97264. export class GroundBuilder {
  97265. /**
  97266. * Creates a ground mesh
  97267. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  97268. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  97269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97270. * @param name defines the name of the mesh
  97271. * @param options defines the options used to create the mesh
  97272. * @param scene defines the hosting scene
  97273. * @returns the ground mesh
  97274. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  97275. */
  97276. static CreateGround(name: string, options: {
  97277. width?: number;
  97278. height?: number;
  97279. subdivisions?: number;
  97280. subdivisionsX?: number;
  97281. subdivisionsY?: number;
  97282. updatable?: boolean;
  97283. }, scene: any): Mesh;
  97284. /**
  97285. * Creates a tiled ground mesh
  97286. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  97287. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  97288. * * 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
  97289. * * 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
  97290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97291. * @param name defines the name of the mesh
  97292. * @param options defines the options used to create the mesh
  97293. * @param scene defines the hosting scene
  97294. * @returns the tiled ground mesh
  97295. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  97296. */
  97297. static CreateTiledGround(name: string, options: {
  97298. xmin: number;
  97299. zmin: number;
  97300. xmax: number;
  97301. zmax: number;
  97302. subdivisions?: {
  97303. w: number;
  97304. h: number;
  97305. };
  97306. precision?: {
  97307. w: number;
  97308. h: number;
  97309. };
  97310. updatable?: boolean;
  97311. }, scene: Scene): Mesh;
  97312. /**
  97313. * Creates a ground mesh from a height map
  97314. * * The parameter `url` sets the URL of the height map image resource.
  97315. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  97316. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  97317. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  97318. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  97319. * * 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.
  97320. * * 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).
  97321. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97323. * @param name defines the name of the mesh
  97324. * @param url defines the url to the height map
  97325. * @param options defines the options used to create the mesh
  97326. * @param scene defines the hosting scene
  97327. * @returns the ground mesh
  97328. * @see https://doc.babylonjs.com/babylon101/height_map
  97329. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  97330. */
  97331. static CreateGroundFromHeightMap(name: string, url: string, options: {
  97332. width?: number;
  97333. height?: number;
  97334. subdivisions?: number;
  97335. minHeight?: number;
  97336. maxHeight?: number;
  97337. colorFilter?: Color3;
  97338. alphaFilter?: number;
  97339. updatable?: boolean;
  97340. onReady?: (mesh: GroundMesh) => void;
  97341. }, scene: Scene): GroundMesh;
  97342. }
  97343. }
  97344. declare module BABYLON {
  97345. /**
  97346. * Class containing static functions to help procedurally build meshes
  97347. */
  97348. export class TorusBuilder {
  97349. /**
  97350. * Creates a torus mesh
  97351. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  97352. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  97353. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  97354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97357. * @param name defines the name of the mesh
  97358. * @param options defines the options used to create the mesh
  97359. * @param scene defines the hosting scene
  97360. * @returns the torus mesh
  97361. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  97362. */
  97363. static CreateTorus(name: string, options: {
  97364. diameter?: number;
  97365. thickness?: number;
  97366. tessellation?: number;
  97367. updatable?: boolean;
  97368. sideOrientation?: number;
  97369. frontUVs?: Vector4;
  97370. backUVs?: Vector4;
  97371. }, scene: any): Mesh;
  97372. }
  97373. }
  97374. declare module BABYLON {
  97375. /**
  97376. * Class containing static functions to help procedurally build meshes
  97377. */
  97378. export class CylinderBuilder {
  97379. /**
  97380. * Creates a cylinder or a cone mesh
  97381. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  97382. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  97383. * * 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.
  97384. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  97385. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  97386. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  97387. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  97388. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  97389. * * 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).
  97390. * * 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
  97391. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  97392. * * 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
  97393. * * 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.
  97394. * * If `enclose` is false, a ring surface is one element.
  97395. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  97396. * * 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
  97397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97400. * @param name defines the name of the mesh
  97401. * @param options defines the options used to create the mesh
  97402. * @param scene defines the hosting scene
  97403. * @returns the cylinder mesh
  97404. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  97405. */
  97406. static CreateCylinder(name: string, options: {
  97407. height?: number;
  97408. diameterTop?: number;
  97409. diameterBottom?: number;
  97410. diameter?: number;
  97411. tessellation?: number;
  97412. subdivisions?: number;
  97413. arc?: number;
  97414. faceColors?: Color4[];
  97415. faceUV?: Vector4[];
  97416. updatable?: boolean;
  97417. hasRings?: boolean;
  97418. enclose?: boolean;
  97419. sideOrientation?: number;
  97420. frontUVs?: Vector4;
  97421. backUVs?: Vector4;
  97422. }, scene: any): Mesh;
  97423. }
  97424. }
  97425. declare module BABYLON {
  97426. /**
  97427. * Manager for handling gamepads
  97428. */
  97429. export class GamepadManager {
  97430. private _scene?;
  97431. private _babylonGamepads;
  97432. private _oneGamepadConnected;
  97433. /** @hidden */
  97434. _isMonitoring: boolean;
  97435. private _gamepadEventSupported;
  97436. private _gamepadSupport;
  97437. /**
  97438. * observable to be triggered when the gamepad controller has been connected
  97439. */
  97440. onGamepadConnectedObservable: Observable<Gamepad>;
  97441. /**
  97442. * observable to be triggered when the gamepad controller has been disconnected
  97443. */
  97444. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97445. private _onGamepadConnectedEvent;
  97446. private _onGamepadDisconnectedEvent;
  97447. /**
  97448. * Initializes the gamepad manager
  97449. * @param _scene BabylonJS scene
  97450. */
  97451. constructor(_scene?: Scene | undefined);
  97452. /**
  97453. * The gamepads in the game pad manager
  97454. */
  97455. readonly gamepads: Gamepad[];
  97456. /**
  97457. * Get the gamepad controllers based on type
  97458. * @param type The type of gamepad controller
  97459. * @returns Nullable gamepad
  97460. */
  97461. getGamepadByType(type?: number): Nullable<Gamepad>;
  97462. /**
  97463. * Disposes the gamepad manager
  97464. */
  97465. dispose(): void;
  97466. private _addNewGamepad;
  97467. private _startMonitoringGamepads;
  97468. private _stopMonitoringGamepads;
  97469. /** @hidden */
  97470. _checkGamepadsStatus(): void;
  97471. private _updateGamepadObjects;
  97472. }
  97473. }
  97474. declare module BABYLON {
  97475. interface Scene {
  97476. /** @hidden */
  97477. _gamepadManager: Nullable<GamepadManager>;
  97478. /**
  97479. * Gets the gamepad manager associated with the scene
  97480. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97481. */
  97482. gamepadManager: GamepadManager;
  97483. }
  97484. /**
  97485. * Interface representing a free camera inputs manager
  97486. */
  97487. interface FreeCameraInputsManager {
  97488. /**
  97489. * Adds gamepad input support to the FreeCameraInputsManager.
  97490. * @returns the FreeCameraInputsManager
  97491. */
  97492. addGamepad(): FreeCameraInputsManager;
  97493. }
  97494. /**
  97495. * Interface representing an arc rotate camera inputs manager
  97496. */
  97497. interface ArcRotateCameraInputsManager {
  97498. /**
  97499. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97500. * @returns the camera inputs manager
  97501. */
  97502. addGamepad(): ArcRotateCameraInputsManager;
  97503. }
  97504. /**
  97505. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97506. */
  97507. export class GamepadSystemSceneComponent implements ISceneComponent {
  97508. /**
  97509. * The component name helpfull to identify the component in the list of scene components.
  97510. */
  97511. readonly name: string;
  97512. /**
  97513. * The scene the component belongs to.
  97514. */
  97515. scene: Scene;
  97516. /**
  97517. * Creates a new instance of the component for the given scene
  97518. * @param scene Defines the scene to register the component in
  97519. */
  97520. constructor(scene: Scene);
  97521. /**
  97522. * Registers the component in a given scene
  97523. */
  97524. register(): void;
  97525. /**
  97526. * Rebuilds the elements related to this component in case of
  97527. * context lost for instance.
  97528. */
  97529. rebuild(): void;
  97530. /**
  97531. * Disposes the component and the associated ressources
  97532. */
  97533. dispose(): void;
  97534. private _beforeCameraUpdate;
  97535. }
  97536. }
  97537. declare module BABYLON {
  97538. /**
  97539. * Options to modify the vr teleportation behavior.
  97540. */
  97541. export interface VRTeleportationOptions {
  97542. /**
  97543. * The name of the mesh which should be used as the teleportation floor. (default: null)
  97544. */
  97545. floorMeshName?: string;
  97546. /**
  97547. * A list of meshes to be used as the teleportation floor. (default: empty)
  97548. */
  97549. floorMeshes?: Mesh[];
  97550. }
  97551. /**
  97552. * Options to modify the vr experience helper's behavior.
  97553. */
  97554. export interface VRExperienceHelperOptions extends WebVROptions {
  97555. /**
  97556. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  97557. */
  97558. createDeviceOrientationCamera?: boolean;
  97559. /**
  97560. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  97561. */
  97562. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  97563. /**
  97564. * Uses the main button on the controller to toggle the laser casted. (default: true)
  97565. */
  97566. laserToggle?: boolean;
  97567. /**
  97568. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  97569. */
  97570. floorMeshes?: Mesh[];
  97571. /**
  97572. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  97573. */
  97574. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  97575. }
  97576. /**
  97577. * Event containing information after VR has been entered
  97578. */
  97579. export class OnAfterEnteringVRObservableEvent {
  97580. /**
  97581. * If entering vr was successful
  97582. */
  97583. success: boolean;
  97584. }
  97585. /**
  97586. * Helps to quickly add VR support to an existing scene.
  97587. * See http://doc.babylonjs.com/how_to/webvr_helper
  97588. */
  97589. export class VRExperienceHelper {
  97590. /** Options to modify the vr experience helper's behavior. */
  97591. webVROptions: VRExperienceHelperOptions;
  97592. private _scene;
  97593. private _position;
  97594. private _btnVR;
  97595. private _btnVRDisplayed;
  97596. private _webVRsupported;
  97597. private _webVRready;
  97598. private _webVRrequesting;
  97599. private _webVRpresenting;
  97600. private _hasEnteredVR;
  97601. private _fullscreenVRpresenting;
  97602. private _canvas;
  97603. private _webVRCamera;
  97604. private _vrDeviceOrientationCamera;
  97605. private _deviceOrientationCamera;
  97606. private _existingCamera;
  97607. private _onKeyDown;
  97608. private _onVrDisplayPresentChange;
  97609. private _onVRDisplayChanged;
  97610. private _onVRRequestPresentStart;
  97611. private _onVRRequestPresentComplete;
  97612. /**
  97613. * Observable raised right before entering VR.
  97614. */
  97615. onEnteringVRObservable: Observable<VRExperienceHelper>;
  97616. /**
  97617. * Observable raised when entering VR has completed.
  97618. */
  97619. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  97620. /**
  97621. * Observable raised when exiting VR.
  97622. */
  97623. onExitingVRObservable: Observable<VRExperienceHelper>;
  97624. /**
  97625. * Observable raised when controller mesh is loaded.
  97626. */
  97627. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97628. /** Return this.onEnteringVRObservable
  97629. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  97630. */
  97631. readonly onEnteringVR: Observable<VRExperienceHelper>;
  97632. /** Return this.onExitingVRObservable
  97633. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  97634. */
  97635. readonly onExitingVR: Observable<VRExperienceHelper>;
  97636. /** Return this.onControllerMeshLoadedObservable
  97637. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  97638. */
  97639. readonly onControllerMeshLoaded: Observable<WebVRController>;
  97640. private _rayLength;
  97641. private _useCustomVRButton;
  97642. private _teleportationRequested;
  97643. private _teleportActive;
  97644. private _floorMeshName;
  97645. private _floorMeshesCollection;
  97646. private _rotationAllowed;
  97647. private _teleportBackwardsVector;
  97648. private _teleportationTarget;
  97649. private _isDefaultTeleportationTarget;
  97650. private _postProcessMove;
  97651. private _teleportationFillColor;
  97652. private _teleportationBorderColor;
  97653. private _rotationAngle;
  97654. private _haloCenter;
  97655. private _cameraGazer;
  97656. private _padSensibilityUp;
  97657. private _padSensibilityDown;
  97658. private _leftController;
  97659. private _rightController;
  97660. /**
  97661. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  97662. */
  97663. onNewMeshSelected: Observable<AbstractMesh>;
  97664. /**
  97665. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  97666. */
  97667. onNewMeshPicked: Observable<PickingInfo>;
  97668. private _circleEase;
  97669. /**
  97670. * Observable raised before camera teleportation
  97671. */
  97672. onBeforeCameraTeleport: Observable<Vector3>;
  97673. /**
  97674. * Observable raised after camera teleportation
  97675. */
  97676. onAfterCameraTeleport: Observable<Vector3>;
  97677. /**
  97678. * Observable raised when current selected mesh gets unselected
  97679. */
  97680. onSelectedMeshUnselected: Observable<AbstractMesh>;
  97681. private _raySelectionPredicate;
  97682. /**
  97683. * To be optionaly changed by user to define custom ray selection
  97684. */
  97685. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  97686. /**
  97687. * To be optionaly changed by user to define custom selection logic (after ray selection)
  97688. */
  97689. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  97690. /**
  97691. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  97692. */
  97693. teleportationEnabled: boolean;
  97694. private _defaultHeight;
  97695. private _teleportationInitialized;
  97696. private _interactionsEnabled;
  97697. private _interactionsRequested;
  97698. private _displayGaze;
  97699. private _displayLaserPointer;
  97700. /**
  97701. * The mesh used to display where the user is going to teleport.
  97702. */
  97703. /**
  97704. * Sets the mesh to be used to display where the user is going to teleport.
  97705. */
  97706. teleportationTarget: Mesh;
  97707. /**
  97708. * 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
  97709. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  97710. * See http://doc.babylonjs.com/resources/baking_transformations
  97711. */
  97712. gazeTrackerMesh: Mesh;
  97713. /**
  97714. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  97715. */
  97716. updateGazeTrackerScale: boolean;
  97717. /**
  97718. * If the gaze trackers color should be updated when selecting meshes
  97719. */
  97720. updateGazeTrackerColor: boolean;
  97721. /**
  97722. * The gaze tracking mesh corresponding to the left controller
  97723. */
  97724. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  97725. /**
  97726. * The gaze tracking mesh corresponding to the right controller
  97727. */
  97728. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  97729. /**
  97730. * If the ray of the gaze should be displayed.
  97731. */
  97732. /**
  97733. * Sets if the ray of the gaze should be displayed.
  97734. */
  97735. displayGaze: boolean;
  97736. /**
  97737. * If the ray of the LaserPointer should be displayed.
  97738. */
  97739. /**
  97740. * Sets if the ray of the LaserPointer should be displayed.
  97741. */
  97742. displayLaserPointer: boolean;
  97743. /**
  97744. * The deviceOrientationCamera used as the camera when not in VR.
  97745. */
  97746. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  97747. /**
  97748. * Based on the current WebVR support, returns the current VR camera used.
  97749. */
  97750. readonly currentVRCamera: Nullable<Camera>;
  97751. /**
  97752. * The webVRCamera which is used when in VR.
  97753. */
  97754. readonly webVRCamera: WebVRFreeCamera;
  97755. /**
  97756. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  97757. */
  97758. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  97759. private readonly _teleportationRequestInitiated;
  97760. /**
  97761. * Defines wether or not Pointer lock should be requested when switching to
  97762. * full screen.
  97763. */
  97764. requestPointerLockOnFullScreen: boolean;
  97765. /**
  97766. * Instantiates a VRExperienceHelper.
  97767. * Helps to quickly add VR support to an existing scene.
  97768. * @param scene The scene the VRExperienceHelper belongs to.
  97769. * @param webVROptions Options to modify the vr experience helper's behavior.
  97770. */
  97771. constructor(scene: Scene,
  97772. /** Options to modify the vr experience helper's behavior. */
  97773. webVROptions?: VRExperienceHelperOptions);
  97774. private _onDefaultMeshLoaded;
  97775. private _onResize;
  97776. private _onFullscreenChange;
  97777. /**
  97778. * Gets a value indicating if we are currently in VR mode.
  97779. */
  97780. readonly isInVRMode: boolean;
  97781. private onVrDisplayPresentChange;
  97782. private onVRDisplayChanged;
  97783. private moveButtonToBottomRight;
  97784. private displayVRButton;
  97785. private updateButtonVisibility;
  97786. private _cachedAngularSensibility;
  97787. /**
  97788. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  97789. * Otherwise, will use the fullscreen API.
  97790. */
  97791. enterVR(): void;
  97792. /**
  97793. * Attempt to exit VR, or fullscreen.
  97794. */
  97795. exitVR(): void;
  97796. /**
  97797. * The position of the vr experience helper.
  97798. */
  97799. /**
  97800. * Sets the position of the vr experience helper.
  97801. */
  97802. position: Vector3;
  97803. /**
  97804. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  97805. */
  97806. enableInteractions(): void;
  97807. private readonly _noControllerIsActive;
  97808. private beforeRender;
  97809. private _isTeleportationFloor;
  97810. /**
  97811. * Adds a floor mesh to be used for teleportation.
  97812. * @param floorMesh the mesh to be used for teleportation.
  97813. */
  97814. addFloorMesh(floorMesh: Mesh): void;
  97815. /**
  97816. * Removes a floor mesh from being used for teleportation.
  97817. * @param floorMesh the mesh to be removed.
  97818. */
  97819. removeFloorMesh(floorMesh: Mesh): void;
  97820. /**
  97821. * Enables interactions and teleportation using the VR controllers and gaze.
  97822. * @param vrTeleportationOptions options to modify teleportation behavior.
  97823. */
  97824. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  97825. private _onNewGamepadConnected;
  97826. private _tryEnableInteractionOnController;
  97827. private _onNewGamepadDisconnected;
  97828. private _enableInteractionOnController;
  97829. private _checkTeleportWithRay;
  97830. private _checkRotate;
  97831. private _checkTeleportBackwards;
  97832. private _enableTeleportationOnController;
  97833. private _createTeleportationCircles;
  97834. private _displayTeleportationTarget;
  97835. private _hideTeleportationTarget;
  97836. private _rotateCamera;
  97837. private _moveTeleportationSelectorTo;
  97838. private _workingVector;
  97839. private _workingQuaternion;
  97840. private _workingMatrix;
  97841. /**
  97842. * Teleports the users feet to the desired location
  97843. * @param location The location where the user's feet should be placed
  97844. */
  97845. teleportCamera(location: Vector3): void;
  97846. private _convertNormalToDirectionOfRay;
  97847. private _castRayAndSelectObject;
  97848. private _notifySelectedMeshUnselected;
  97849. /**
  97850. * Sets the color of the laser ray from the vr controllers.
  97851. * @param color new color for the ray.
  97852. */
  97853. changeLaserColor(color: Color3): void;
  97854. /**
  97855. * Sets the color of the ray from the vr headsets gaze.
  97856. * @param color new color for the ray.
  97857. */
  97858. changeGazeColor(color: Color3): void;
  97859. /**
  97860. * Exits VR and disposes of the vr experience helper
  97861. */
  97862. dispose(): void;
  97863. /**
  97864. * Gets the name of the VRExperienceHelper class
  97865. * @returns "VRExperienceHelper"
  97866. */
  97867. getClassName(): string;
  97868. }
  97869. }
  97870. declare module BABYLON {
  97871. /**
  97872. * Manages an XRSession
  97873. * @see https://doc.babylonjs.com/how_to/webxr
  97874. */
  97875. export class WebXRSessionManager implements IDisposable {
  97876. private scene;
  97877. /**
  97878. * Fires every time a new xrFrame arrives which can be used to update the camera
  97879. */
  97880. onXRFrameObservable: Observable<any>;
  97881. /**
  97882. * Fires when the xr session is ended either by the device or manually done
  97883. */
  97884. onXRSessionEnded: Observable<any>;
  97885. /** @hidden */
  97886. _xrSession: XRSession;
  97887. /** @hidden */
  97888. _frameOfReference: XRFrameOfReference;
  97889. /** @hidden */
  97890. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  97891. /** @hidden */
  97892. _currentXRFrame: Nullable<XRFrame>;
  97893. private _xrNavigator;
  97894. private _xrDevice;
  97895. private _tmpMatrix;
  97896. /**
  97897. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  97898. * @param scene The scene which the session should be created for
  97899. */
  97900. constructor(scene: Scene);
  97901. /**
  97902. * Initializes the manager
  97903. * After initialization enterXR can be called to start an XR session
  97904. * @returns Promise which resolves after it is initialized
  97905. */
  97906. initializeAsync(): Promise<void>;
  97907. /**
  97908. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  97909. * @param sessionCreationOptions xr options to create the session with
  97910. * @param frameOfReferenceType option to configure how the xr pose is expressed
  97911. * @returns Promise which resolves after it enters XR
  97912. */
  97913. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  97914. /**
  97915. * Stops the xrSession and restores the renderloop
  97916. * @returns Promise which resolves after it exits XR
  97917. */
  97918. exitXRAsync(): Promise<void>;
  97919. /**
  97920. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97921. * @param ray ray to cast into the environment
  97922. * @returns Promise which resolves with a collision point in the environment if it exists
  97923. */
  97924. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97925. /**
  97926. * Checks if a session would be supported for the creation options specified
  97927. * @param options creation options to check if they are supported
  97928. * @returns true if supported
  97929. */
  97930. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97931. /**
  97932. * @hidden
  97933. * Converts the render layer of xrSession to a render target
  97934. * @param session session to create render target for
  97935. * @param scene scene the new render target should be created for
  97936. */
  97937. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  97938. /**
  97939. * Disposes of the session manager
  97940. */
  97941. dispose(): void;
  97942. }
  97943. }
  97944. declare module BABYLON {
  97945. /**
  97946. * WebXR Camera which holds the views for the xrSession
  97947. * @see https://doc.babylonjs.com/how_to/webxr
  97948. */
  97949. export class WebXRCamera extends FreeCamera {
  97950. private static _TmpMatrix;
  97951. /**
  97952. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  97953. * @param name the name of the camera
  97954. * @param scene the scene to add the camera to
  97955. */
  97956. constructor(name: string, scene: Scene);
  97957. private _updateNumberOfRigCameras;
  97958. /** @hidden */
  97959. _updateForDualEyeDebugging(pupilDistance?: number): void;
  97960. /**
  97961. * Updates the cameras position from the current pose information of the XR session
  97962. * @param xrSessionManager the session containing pose information
  97963. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  97964. */
  97965. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  97966. }
  97967. }
  97968. declare module BABYLON {
  97969. /**
  97970. * States of the webXR experience
  97971. */
  97972. export enum WebXRState {
  97973. /**
  97974. * Transitioning to being in XR mode
  97975. */
  97976. ENTERING_XR = 0,
  97977. /**
  97978. * Transitioning to non XR mode
  97979. */
  97980. EXITING_XR = 1,
  97981. /**
  97982. * In XR mode and presenting
  97983. */
  97984. IN_XR = 2,
  97985. /**
  97986. * Not entered XR mode
  97987. */
  97988. NOT_IN_XR = 3
  97989. }
  97990. /**
  97991. * Helper class used to enable XR
  97992. * @see https://doc.babylonjs.com/how_to/webxr
  97993. */
  97994. export class WebXRExperienceHelper implements IDisposable {
  97995. private scene;
  97996. /**
  97997. * 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
  97998. */
  97999. container: AbstractMesh;
  98000. /**
  98001. * Camera used to render xr content
  98002. */
  98003. camera: WebXRCamera;
  98004. /**
  98005. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  98006. */
  98007. state: WebXRState;
  98008. private _setState;
  98009. private static _TmpVector;
  98010. /**
  98011. * Fires when the state of the experience helper has changed
  98012. */
  98013. onStateChangedObservable: Observable<WebXRState>;
  98014. /** @hidden */
  98015. _sessionManager: WebXRSessionManager;
  98016. private _nonVRCamera;
  98017. private _originalSceneAutoClear;
  98018. private _supported;
  98019. /**
  98020. * Creates the experience helper
  98021. * @param scene the scene to attach the experience helper to
  98022. * @returns a promise for the experience helper
  98023. */
  98024. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  98025. /**
  98026. * Creates a WebXRExperienceHelper
  98027. * @param scene The scene the helper should be created in
  98028. */
  98029. private constructor();
  98030. /**
  98031. * Exits XR mode and returns the scene to its original state
  98032. * @returns promise that resolves after xr mode has exited
  98033. */
  98034. exitXRAsync(): Promise<void>;
  98035. /**
  98036. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  98037. * @param sessionCreationOptions options for the XR session
  98038. * @param frameOfReference frame of reference of the XR session
  98039. * @returns promise that resolves after xr mode has entered
  98040. */
  98041. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  98042. /**
  98043. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98044. * @param ray ray to cast into the environment
  98045. * @returns Promise which resolves with a collision point in the environment if it exists
  98046. */
  98047. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98048. /**
  98049. * Updates the global position of the camera by moving the camera's container
  98050. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  98051. * @param position The desired global position of the camera
  98052. */
  98053. setPositionOfCameraUsingContainer(position: Vector3): void;
  98054. /**
  98055. * Rotates the xr camera by rotating the camera's container around the camera's position
  98056. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  98057. * @param rotation the desired quaternion rotation to apply to the camera
  98058. */
  98059. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  98060. /**
  98061. * Checks if the creation options are supported by the xr session
  98062. * @param options creation options
  98063. * @returns true if supported
  98064. */
  98065. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98066. /**
  98067. * Disposes of the experience helper
  98068. */
  98069. dispose(): void;
  98070. }
  98071. }
  98072. declare module BABYLON {
  98073. /**
  98074. * Button which can be used to enter a different mode of XR
  98075. */
  98076. export class WebXREnterExitUIButton {
  98077. /** button element */
  98078. element: HTMLElement;
  98079. /** XR initialization options for the button */
  98080. initializationOptions: XRSessionCreationOptions;
  98081. /**
  98082. * Creates a WebXREnterExitUIButton
  98083. * @param element button element
  98084. * @param initializationOptions XR initialization options for the button
  98085. */
  98086. constructor(
  98087. /** button element */
  98088. element: HTMLElement,
  98089. /** XR initialization options for the button */
  98090. initializationOptions: XRSessionCreationOptions);
  98091. /**
  98092. * Overwritable function which can be used to update the button's visuals when the state changes
  98093. * @param activeButton the current active button in the UI
  98094. */
  98095. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  98096. }
  98097. /**
  98098. * Options to create the webXR UI
  98099. */
  98100. export class WebXREnterExitUIOptions {
  98101. /**
  98102. * Context to enter xr with
  98103. */
  98104. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  98105. /**
  98106. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  98107. */
  98108. customButtons?: Array<WebXREnterExitUIButton>;
  98109. }
  98110. /**
  98111. * UI to allow the user to enter/exit XR mode
  98112. */
  98113. export class WebXREnterExitUI implements IDisposable {
  98114. private scene;
  98115. private _overlay;
  98116. private _buttons;
  98117. private _activeButton;
  98118. /**
  98119. * Fired every time the active button is changed.
  98120. *
  98121. * When xr is entered via a button that launches xr that button will be the callback parameter
  98122. *
  98123. * When exiting xr the callback parameter will be null)
  98124. */
  98125. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  98126. /**
  98127. * Creates UI to allow the user to enter/exit XR mode
  98128. * @param scene the scene to add the ui to
  98129. * @param helper the xr experience helper to enter/exit xr with
  98130. * @param options options to configure the UI
  98131. * @returns the created ui
  98132. */
  98133. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  98134. private constructor();
  98135. private _updateButtons;
  98136. /**
  98137. * Disposes of the object
  98138. */
  98139. dispose(): void;
  98140. }
  98141. }
  98142. declare module BABYLON {
  98143. /**
  98144. * Represents an XR input
  98145. */
  98146. export class WebXRController {
  98147. /**
  98148. * 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
  98149. */
  98150. grip?: AbstractMesh;
  98151. /**
  98152. * Pointer which can be used to select objects or attach a visible laser to
  98153. */
  98154. pointer: AbstractMesh;
  98155. /**
  98156. * Creates the controller
  98157. * @see https://doc.babylonjs.com/how_to/webxr
  98158. * @param scene the scene which the controller should be associated to
  98159. */
  98160. constructor(scene: Scene);
  98161. /**
  98162. * Disposes of the object
  98163. */
  98164. dispose(): void;
  98165. }
  98166. /**
  98167. * XR input used to track XR inputs such as controllers/rays
  98168. */
  98169. export class WebXRInput implements IDisposable {
  98170. private helper;
  98171. /**
  98172. * XR controllers being tracked
  98173. */
  98174. controllers: Array<WebXRController>;
  98175. private _tmpMatrix;
  98176. private _frameObserver;
  98177. /**
  98178. * Initializes the WebXRInput
  98179. * @param helper experience helper which the input should be created for
  98180. */
  98181. constructor(helper: WebXRExperienceHelper);
  98182. /**
  98183. * Disposes of the object
  98184. */
  98185. dispose(): void;
  98186. }
  98187. }
  98188. declare module BABYLON {
  98189. /**
  98190. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  98191. */
  98192. export class WebXRManagedOutputCanvas implements IDisposable {
  98193. private _canvas;
  98194. /**
  98195. * xrpresent context of the canvas which can be used to display/mirror xr content
  98196. */
  98197. canvasContext: Nullable<WebGLRenderingContext>;
  98198. /**
  98199. * Initializes the canvas to be added/removed upon entering/exiting xr
  98200. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  98201. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  98202. */
  98203. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  98204. /**
  98205. * Disposes of the object
  98206. */
  98207. dispose(): void;
  98208. private _setManagedOutputCanvas;
  98209. private _addCanvas;
  98210. private _removeCanvas;
  98211. }
  98212. }
  98213. declare module BABYLON {
  98214. /**
  98215. * Contains an array of blocks representing the octree
  98216. */
  98217. export interface IOctreeContainer<T> {
  98218. /**
  98219. * Blocks within the octree
  98220. */
  98221. blocks: Array<OctreeBlock<T>>;
  98222. }
  98223. /**
  98224. * Class used to store a cell in an octree
  98225. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98226. */
  98227. export class OctreeBlock<T> {
  98228. /**
  98229. * Gets the content of the current block
  98230. */
  98231. entries: T[];
  98232. /**
  98233. * Gets the list of block children
  98234. */
  98235. blocks: Array<OctreeBlock<T>>;
  98236. private _depth;
  98237. private _maxDepth;
  98238. private _capacity;
  98239. private _minPoint;
  98240. private _maxPoint;
  98241. private _boundingVectors;
  98242. private _creationFunc;
  98243. /**
  98244. * Creates a new block
  98245. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  98246. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  98247. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98248. * @param depth defines the current depth of this block in the octree
  98249. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  98250. * @param creationFunc defines a callback to call when an element is added to the block
  98251. */
  98252. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  98253. /**
  98254. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98255. */
  98256. readonly capacity: number;
  98257. /**
  98258. * Gets the minimum vector (in world space) of the block's bounding box
  98259. */
  98260. readonly minPoint: Vector3;
  98261. /**
  98262. * Gets the maximum vector (in world space) of the block's bounding box
  98263. */
  98264. readonly maxPoint: Vector3;
  98265. /**
  98266. * Add a new element to this block
  98267. * @param entry defines the element to add
  98268. */
  98269. addEntry(entry: T): void;
  98270. /**
  98271. * Remove an element from this block
  98272. * @param entry defines the element to remove
  98273. */
  98274. removeEntry(entry: T): void;
  98275. /**
  98276. * Add an array of elements to this block
  98277. * @param entries defines the array of elements to add
  98278. */
  98279. addEntries(entries: T[]): void;
  98280. /**
  98281. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  98282. * @param frustumPlanes defines the frustum planes to test
  98283. * @param selection defines the array to store current content if selection is positive
  98284. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98285. */
  98286. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98287. /**
  98288. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  98289. * @param sphereCenter defines the bounding sphere center
  98290. * @param sphereRadius defines the bounding sphere radius
  98291. * @param selection defines the array to store current content if selection is positive
  98292. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98293. */
  98294. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98295. /**
  98296. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  98297. * @param ray defines the ray to test with
  98298. * @param selection defines the array to store current content if selection is positive
  98299. */
  98300. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  98301. /**
  98302. * Subdivide the content into child blocks (this block will then be empty)
  98303. */
  98304. createInnerBlocks(): void;
  98305. /**
  98306. * @hidden
  98307. */
  98308. 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;
  98309. }
  98310. }
  98311. declare module BABYLON {
  98312. /**
  98313. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  98314. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98315. */
  98316. export class Octree<T> {
  98317. /** 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.) */
  98318. maxDepth: number;
  98319. /**
  98320. * Blocks within the octree containing objects
  98321. */
  98322. blocks: Array<OctreeBlock<T>>;
  98323. /**
  98324. * Content stored in the octree
  98325. */
  98326. dynamicContent: T[];
  98327. private _maxBlockCapacity;
  98328. private _selectionContent;
  98329. private _creationFunc;
  98330. /**
  98331. * Creates a octree
  98332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98333. * @param creationFunc function to be used to instatiate the octree
  98334. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  98335. * @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.)
  98336. */
  98337. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  98338. /** 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.) */
  98339. maxDepth?: number);
  98340. /**
  98341. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  98342. * @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);
  98343. * @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);
  98344. * @param entries meshes to be added to the octree blocks
  98345. */
  98346. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  98347. /**
  98348. * Adds a mesh to the octree
  98349. * @param entry Mesh to add to the octree
  98350. */
  98351. addMesh(entry: T): void;
  98352. /**
  98353. * Remove an element from the octree
  98354. * @param entry defines the element to remove
  98355. */
  98356. removeMesh(entry: T): void;
  98357. /**
  98358. * Selects an array of meshes within the frustum
  98359. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  98360. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  98361. * @returns array of meshes within the frustum
  98362. */
  98363. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  98364. /**
  98365. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  98366. * @param sphereCenter defines the bounding sphere center
  98367. * @param sphereRadius defines the bounding sphere radius
  98368. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98369. * @returns an array of objects that intersect the sphere
  98370. */
  98371. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  98372. /**
  98373. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  98374. * @param ray defines the ray to test with
  98375. * @returns array of intersected objects
  98376. */
  98377. intersectsRay(ray: Ray): SmartArray<T>;
  98378. /**
  98379. * Adds a mesh into the octree block if it intersects the block
  98380. */
  98381. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  98382. /**
  98383. * Adds a submesh into the octree block if it intersects the block
  98384. */
  98385. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  98386. }
  98387. }
  98388. declare module BABYLON {
  98389. interface Scene {
  98390. /**
  98391. * @hidden
  98392. * Backing Filed
  98393. */
  98394. _selectionOctree: Octree<AbstractMesh>;
  98395. /**
  98396. * Gets the octree used to boost mesh selection (picking)
  98397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98398. */
  98399. selectionOctree: Octree<AbstractMesh>;
  98400. /**
  98401. * Creates or updates the octree used to boost selection (picking)
  98402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98403. * @param maxCapacity defines the maximum capacity per leaf
  98404. * @param maxDepth defines the maximum depth of the octree
  98405. * @returns an octree of AbstractMesh
  98406. */
  98407. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  98408. }
  98409. interface AbstractMesh {
  98410. /**
  98411. * @hidden
  98412. * Backing Field
  98413. */
  98414. _submeshesOctree: Octree<SubMesh>;
  98415. /**
  98416. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  98417. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  98418. * @param maxCapacity defines the maximum size of each block (64 by default)
  98419. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  98420. * @returns the new octree
  98421. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  98422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98423. */
  98424. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  98425. }
  98426. /**
  98427. * Defines the octree scene component responsible to manage any octrees
  98428. * in a given scene.
  98429. */
  98430. export class OctreeSceneComponent {
  98431. /**
  98432. * The component name helpfull to identify the component in the list of scene components.
  98433. */
  98434. readonly name: string;
  98435. /**
  98436. * The scene the component belongs to.
  98437. */
  98438. scene: Scene;
  98439. /**
  98440. * Indicates if the meshes have been checked to make sure they are isEnabled()
  98441. */
  98442. readonly checksIsEnabled: boolean;
  98443. /**
  98444. * Creates a new instance of the component for the given scene
  98445. * @param scene Defines the scene to register the component in
  98446. */
  98447. constructor(scene: Scene);
  98448. /**
  98449. * Registers the component in a given scene
  98450. */
  98451. register(): void;
  98452. /**
  98453. * Return the list of active meshes
  98454. * @returns the list of active meshes
  98455. */
  98456. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98457. /**
  98458. * Return the list of active sub meshes
  98459. * @param mesh The mesh to get the candidates sub meshes from
  98460. * @returns the list of active sub meshes
  98461. */
  98462. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98463. private _tempRay;
  98464. /**
  98465. * Return the list of sub meshes intersecting with a given local ray
  98466. * @param mesh defines the mesh to find the submesh for
  98467. * @param localRay defines the ray in local space
  98468. * @returns the list of intersecting sub meshes
  98469. */
  98470. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  98471. /**
  98472. * Return the list of sub meshes colliding with a collider
  98473. * @param mesh defines the mesh to find the submesh for
  98474. * @param collider defines the collider to evaluate the collision against
  98475. * @returns the list of colliding sub meshes
  98476. */
  98477. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  98478. /**
  98479. * Rebuilds the elements related to this component in case of
  98480. * context lost for instance.
  98481. */
  98482. rebuild(): void;
  98483. /**
  98484. * Disposes the component and the associated ressources.
  98485. */
  98486. dispose(): void;
  98487. }
  98488. }
  98489. declare module BABYLON {
  98490. /**
  98491. * Class containing static functions to help procedurally build meshes
  98492. */
  98493. export class LinesBuilder {
  98494. /**
  98495. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  98496. * * 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
  98497. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  98498. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  98499. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  98500. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  98501. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  98502. * * 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
  98503. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  98504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  98506. * @param name defines the name of the new line system
  98507. * @param options defines the options used to create the line system
  98508. * @param scene defines the hosting scene
  98509. * @returns a new line system mesh
  98510. */
  98511. static CreateLineSystem(name: string, options: {
  98512. lines: Vector3[][];
  98513. updatable?: boolean;
  98514. instance?: Nullable<LinesMesh>;
  98515. colors?: Nullable<Color4[][]>;
  98516. useVertexAlpha?: boolean;
  98517. }, scene: Nullable<Scene>): LinesMesh;
  98518. /**
  98519. * Creates a line mesh
  98520. * 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
  98521. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98522. * * The parameter `points` is an array successive Vector3
  98523. * * 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
  98524. * * The optional parameter `colors` is an array of successive Color4, one per line point
  98525. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  98526. * * When updating an instance, remember that only point positions can change, not the number of points
  98527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  98529. * @param name defines the name of the new line system
  98530. * @param options defines the options used to create the line system
  98531. * @param scene defines the hosting scene
  98532. * @returns a new line mesh
  98533. */
  98534. static CreateLines(name: string, options: {
  98535. points: Vector3[];
  98536. updatable?: boolean;
  98537. instance?: Nullable<LinesMesh>;
  98538. colors?: Color4[];
  98539. useVertexAlpha?: boolean;
  98540. }, scene?: Nullable<Scene>): LinesMesh;
  98541. /**
  98542. * Creates a dashed line mesh
  98543. * * 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
  98544. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98545. * * The parameter `points` is an array successive Vector3
  98546. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  98547. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  98548. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98549. * * 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
  98550. * * When updating an instance, remember that only point positions can change, not the number of points
  98551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98552. * @param name defines the name of the mesh
  98553. * @param options defines the options used to create the mesh
  98554. * @param scene defines the hosting scene
  98555. * @returns the dashed line mesh
  98556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  98557. */
  98558. static CreateDashedLines(name: string, options: {
  98559. points: Vector3[];
  98560. dashSize?: number;
  98561. gapSize?: number;
  98562. dashNb?: number;
  98563. updatable?: boolean;
  98564. instance?: LinesMesh;
  98565. }, scene?: Nullable<Scene>): LinesMesh;
  98566. }
  98567. }
  98568. declare module BABYLON {
  98569. /**
  98570. * Renders a layer on top of an existing scene
  98571. */
  98572. export class UtilityLayerRenderer implements IDisposable {
  98573. /** the original scene that will be rendered on top of */
  98574. originalScene: Scene;
  98575. private _pointerCaptures;
  98576. private _lastPointerEvents;
  98577. private static _DefaultUtilityLayer;
  98578. private static _DefaultKeepDepthUtilityLayer;
  98579. /**
  98580. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  98581. */
  98582. pickUtilitySceneFirst: boolean;
  98583. /**
  98584. * 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)
  98585. */
  98586. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  98587. /**
  98588. * 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)
  98589. */
  98590. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  98591. /**
  98592. * The scene that is rendered on top of the original scene
  98593. */
  98594. utilityLayerScene: Scene;
  98595. /**
  98596. * If the utility layer should automatically be rendered on top of existing scene
  98597. */
  98598. shouldRender: boolean;
  98599. /**
  98600. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  98601. */
  98602. onlyCheckPointerDownEvents: boolean;
  98603. /**
  98604. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  98605. */
  98606. processAllEvents: boolean;
  98607. /**
  98608. * Observable raised when the pointer move from the utility layer scene to the main scene
  98609. */
  98610. onPointerOutObservable: Observable<number>;
  98611. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  98612. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  98613. private _afterRenderObserver;
  98614. private _sceneDisposeObserver;
  98615. private _originalPointerObserver;
  98616. /**
  98617. * Instantiates a UtilityLayerRenderer
  98618. * @param originalScene the original scene that will be rendered on top of
  98619. * @param handleEvents boolean indicating if the utility layer should handle events
  98620. */
  98621. constructor(
  98622. /** the original scene that will be rendered on top of */
  98623. originalScene: Scene, handleEvents?: boolean);
  98624. private _notifyObservers;
  98625. /**
  98626. * Renders the utility layers scene on top of the original scene
  98627. */
  98628. render(): void;
  98629. /**
  98630. * Disposes of the renderer
  98631. */
  98632. dispose(): void;
  98633. private _updateCamera;
  98634. }
  98635. }
  98636. declare module BABYLON {
  98637. /**
  98638. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  98639. */
  98640. export class Gizmo implements IDisposable {
  98641. /** The utility layer the gizmo will be added to */
  98642. gizmoLayer: UtilityLayerRenderer;
  98643. /**
  98644. * The root mesh of the gizmo
  98645. */
  98646. _rootMesh: Mesh;
  98647. private _attachedMesh;
  98648. /**
  98649. * Ratio for the scale of the gizmo (Default: 1)
  98650. */
  98651. scaleRatio: number;
  98652. private _tmpMatrix;
  98653. /**
  98654. * If a custom mesh has been set (Default: false)
  98655. */
  98656. protected _customMeshSet: boolean;
  98657. /**
  98658. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  98659. * * When set, interactions will be enabled
  98660. */
  98661. attachedMesh: Nullable<AbstractMesh>;
  98662. /**
  98663. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98664. * @param mesh The mesh to replace the default mesh of the gizmo
  98665. */
  98666. setCustomMesh(mesh: Mesh): void;
  98667. /**
  98668. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  98669. */
  98670. updateGizmoRotationToMatchAttachedMesh: boolean;
  98671. /**
  98672. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  98673. */
  98674. updateGizmoPositionToMatchAttachedMesh: boolean;
  98675. /**
  98676. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  98677. */
  98678. protected _updateScale: boolean;
  98679. protected _interactionsEnabled: boolean;
  98680. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98681. private _beforeRenderObserver;
  98682. /**
  98683. * Creates a gizmo
  98684. * @param gizmoLayer The utility layer the gizmo will be added to
  98685. */
  98686. constructor(
  98687. /** The utility layer the gizmo will be added to */
  98688. gizmoLayer?: UtilityLayerRenderer);
  98689. private _tempVector;
  98690. /**
  98691. * @hidden
  98692. * Updates the gizmo to match the attached mesh's position/rotation
  98693. */
  98694. protected _update(): void;
  98695. /**
  98696. * Disposes of the gizmo
  98697. */
  98698. dispose(): void;
  98699. }
  98700. }
  98701. declare module BABYLON {
  98702. /**
  98703. * Single axis drag gizmo
  98704. */
  98705. export class AxisDragGizmo extends Gizmo {
  98706. /**
  98707. * Drag behavior responsible for the gizmos dragging interactions
  98708. */
  98709. dragBehavior: PointerDragBehavior;
  98710. private _pointerObserver;
  98711. /**
  98712. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98713. */
  98714. snapDistance: number;
  98715. /**
  98716. * Event that fires each time the gizmo snaps to a new location.
  98717. * * snapDistance is the the change in distance
  98718. */
  98719. onSnapObservable: Observable<{
  98720. snapDistance: number;
  98721. }>;
  98722. /** @hidden */
  98723. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  98724. /** @hidden */
  98725. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  98726. /**
  98727. * Creates an AxisDragGizmo
  98728. * @param gizmoLayer The utility layer the gizmo will be added to
  98729. * @param dragAxis The axis which the gizmo will be able to drag on
  98730. * @param color The color of the gizmo
  98731. */
  98732. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98733. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98734. /**
  98735. * Disposes of the gizmo
  98736. */
  98737. dispose(): void;
  98738. }
  98739. }
  98740. declare module BABYLON.Debug {
  98741. /**
  98742. * The Axes viewer will show 3 axes in a specific point in space
  98743. */
  98744. export class AxesViewer {
  98745. private _xAxis;
  98746. private _yAxis;
  98747. private _zAxis;
  98748. private _scaleLinesFactor;
  98749. private _instanced;
  98750. /**
  98751. * Gets the hosting scene
  98752. */
  98753. scene: Scene;
  98754. /**
  98755. * Gets or sets a number used to scale line length
  98756. */
  98757. scaleLines: number;
  98758. /** Gets the node hierarchy used to render x-axis */
  98759. readonly xAxis: TransformNode;
  98760. /** Gets the node hierarchy used to render y-axis */
  98761. readonly yAxis: TransformNode;
  98762. /** Gets the node hierarchy used to render z-axis */
  98763. readonly zAxis: TransformNode;
  98764. /**
  98765. * Creates a new AxesViewer
  98766. * @param scene defines the hosting scene
  98767. * @param scaleLines defines a number used to scale line length (1 by default)
  98768. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  98769. * @param xAxis defines the node hierarchy used to render the x-axis
  98770. * @param yAxis defines the node hierarchy used to render the y-axis
  98771. * @param zAxis defines the node hierarchy used to render the z-axis
  98772. */
  98773. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  98774. /**
  98775. * Force the viewer to update
  98776. * @param position defines the position of the viewer
  98777. * @param xaxis defines the x axis of the viewer
  98778. * @param yaxis defines the y axis of the viewer
  98779. * @param zaxis defines the z axis of the viewer
  98780. */
  98781. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  98782. /**
  98783. * Creates an instance of this axes viewer.
  98784. * @returns a new axes viewer with instanced meshes
  98785. */
  98786. createInstance(): AxesViewer;
  98787. /** Releases resources */
  98788. dispose(): void;
  98789. private static _SetRenderingGroupId;
  98790. }
  98791. }
  98792. declare module BABYLON.Debug {
  98793. /**
  98794. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  98795. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  98796. */
  98797. export class BoneAxesViewer extends AxesViewer {
  98798. /**
  98799. * Gets or sets the target mesh where to display the axes viewer
  98800. */
  98801. mesh: Nullable<Mesh>;
  98802. /**
  98803. * Gets or sets the target bone where to display the axes viewer
  98804. */
  98805. bone: Nullable<Bone>;
  98806. /** Gets current position */
  98807. pos: Vector3;
  98808. /** Gets direction of X axis */
  98809. xaxis: Vector3;
  98810. /** Gets direction of Y axis */
  98811. yaxis: Vector3;
  98812. /** Gets direction of Z axis */
  98813. zaxis: Vector3;
  98814. /**
  98815. * Creates a new BoneAxesViewer
  98816. * @param scene defines the hosting scene
  98817. * @param bone defines the target bone
  98818. * @param mesh defines the target mesh
  98819. * @param scaleLines defines a scaling factor for line length (1 by default)
  98820. */
  98821. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  98822. /**
  98823. * Force the viewer to update
  98824. */
  98825. update(): void;
  98826. /** Releases resources */
  98827. dispose(): void;
  98828. }
  98829. }
  98830. declare module BABYLON {
  98831. /**
  98832. * Interface used to define scene explorer extensibility option
  98833. */
  98834. export interface IExplorerExtensibilityOption {
  98835. /**
  98836. * Define the option label
  98837. */
  98838. label: string;
  98839. /**
  98840. * Defines the action to execute on click
  98841. */
  98842. action: (entity: any) => void;
  98843. }
  98844. /**
  98845. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  98846. */
  98847. export interface IExplorerExtensibilityGroup {
  98848. /**
  98849. * Defines a predicate to test if a given type mut be extended
  98850. */
  98851. predicate: (entity: any) => boolean;
  98852. /**
  98853. * Gets the list of options added to a type
  98854. */
  98855. entries: IExplorerExtensibilityOption[];
  98856. }
  98857. /**
  98858. * Interface used to define the options to use to create the Inspector
  98859. */
  98860. export interface IInspectorOptions {
  98861. /**
  98862. * Display in overlay mode (default: false)
  98863. */
  98864. overlay?: boolean;
  98865. /**
  98866. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  98867. */
  98868. globalRoot?: HTMLElement;
  98869. /**
  98870. * Display the Scene explorer
  98871. */
  98872. showExplorer?: boolean;
  98873. /**
  98874. * Display the property inspector
  98875. */
  98876. showInspector?: boolean;
  98877. /**
  98878. * Display in embed mode (both panes on the right)
  98879. */
  98880. embedMode?: boolean;
  98881. /**
  98882. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  98883. */
  98884. handleResize?: boolean;
  98885. /**
  98886. * Allow the panes to popup (default: true)
  98887. */
  98888. enablePopup?: boolean;
  98889. /**
  98890. * Allow the panes to be closed by users (default: true)
  98891. */
  98892. enableClose?: boolean;
  98893. /**
  98894. * Optional list of extensibility entries
  98895. */
  98896. explorerExtensibility?: IExplorerExtensibilityGroup[];
  98897. /**
  98898. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  98899. */
  98900. inspectorURL?: string;
  98901. }
  98902. interface Scene {
  98903. /**
  98904. * @hidden
  98905. * Backing field
  98906. */
  98907. _debugLayer: DebugLayer;
  98908. /**
  98909. * Gets the debug layer (aka Inspector) associated with the scene
  98910. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98911. */
  98912. debugLayer: DebugLayer;
  98913. }
  98914. /**
  98915. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98916. * what is happening in your scene
  98917. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98918. */
  98919. export class DebugLayer {
  98920. /**
  98921. * Define the url to get the inspector script from.
  98922. * By default it uses the babylonjs CDN.
  98923. * @ignoreNaming
  98924. */
  98925. static InspectorURL: string;
  98926. private _scene;
  98927. private BJSINSPECTOR;
  98928. /**
  98929. * Observable triggered when a property is changed through the inspector.
  98930. */
  98931. onPropertyChangedObservable: Observable<{
  98932. object: any;
  98933. property: string;
  98934. value: any;
  98935. initialValue: any;
  98936. }>;
  98937. /**
  98938. * Instantiates a new debug layer.
  98939. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98940. * what is happening in your scene
  98941. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98942. * @param scene Defines the scene to inspect
  98943. */
  98944. constructor(scene: Scene);
  98945. /** Creates the inspector window. */
  98946. private _createInspector;
  98947. /**
  98948. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  98949. * @param entity defines the entity to select
  98950. * @param lineContainerTitle defines the specific block to highlight
  98951. */
  98952. select(entity: any, lineContainerTitle?: string): void;
  98953. /** Get the inspector from bundle or global */
  98954. private _getGlobalInspector;
  98955. /**
  98956. * Get if the inspector is visible or not.
  98957. * @returns true if visible otherwise, false
  98958. */
  98959. isVisible(): boolean;
  98960. /**
  98961. * Hide the inspector and close its window.
  98962. */
  98963. hide(): void;
  98964. /**
  98965. * Launch the debugLayer.
  98966. * @param config Define the configuration of the inspector
  98967. * @return a promise fulfilled when the debug layer is visible
  98968. */
  98969. show(config?: IInspectorOptions): Promise<DebugLayer>;
  98970. }
  98971. }
  98972. declare module BABYLON {
  98973. /**
  98974. * Class containing static functions to help procedurally build meshes
  98975. */
  98976. export class BoxBuilder {
  98977. /**
  98978. * Creates a box mesh
  98979. * * The parameter `size` sets the size (float) of each box side (default 1)
  98980. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  98981. * * 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)
  98982. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  98983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98986. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  98987. * @param name defines the name of the mesh
  98988. * @param options defines the options used to create the mesh
  98989. * @param scene defines the hosting scene
  98990. * @returns the box mesh
  98991. */
  98992. static CreateBox(name: string, options: {
  98993. size?: number;
  98994. width?: number;
  98995. height?: number;
  98996. depth?: number;
  98997. faceUV?: Vector4[];
  98998. faceColors?: Color4[];
  98999. sideOrientation?: number;
  99000. frontUVs?: Vector4;
  99001. backUVs?: Vector4;
  99002. updatable?: boolean;
  99003. }, scene?: Nullable<Scene>): Mesh;
  99004. }
  99005. }
  99006. declare module BABYLON {
  99007. /**
  99008. * Class containing static functions to help procedurally build meshes
  99009. */
  99010. export class SphereBuilder {
  99011. /**
  99012. * Creates a sphere mesh
  99013. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  99014. * * 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`)
  99015. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  99016. * * 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
  99017. * * 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)
  99018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99021. * @param name defines the name of the mesh
  99022. * @param options defines the options used to create the mesh
  99023. * @param scene defines the hosting scene
  99024. * @returns the sphere mesh
  99025. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  99026. */
  99027. static CreateSphere(name: string, options: {
  99028. segments?: number;
  99029. diameter?: number;
  99030. diameterX?: number;
  99031. diameterY?: number;
  99032. diameterZ?: number;
  99033. arc?: number;
  99034. slice?: number;
  99035. sideOrientation?: number;
  99036. frontUVs?: Vector4;
  99037. backUVs?: Vector4;
  99038. updatable?: boolean;
  99039. }, scene: any): Mesh;
  99040. }
  99041. }
  99042. declare module BABYLON.Debug {
  99043. /**
  99044. * Used to show the physics impostor around the specific mesh
  99045. */
  99046. export class PhysicsViewer {
  99047. /** @hidden */
  99048. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  99049. /** @hidden */
  99050. protected _meshes: Array<Nullable<AbstractMesh>>;
  99051. /** @hidden */
  99052. protected _scene: Nullable<Scene>;
  99053. /** @hidden */
  99054. protected _numMeshes: number;
  99055. /** @hidden */
  99056. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  99057. private _renderFunction;
  99058. private _utilityLayer;
  99059. private _debugBoxMesh;
  99060. private _debugSphereMesh;
  99061. private _debugMaterial;
  99062. /**
  99063. * Creates a new PhysicsViewer
  99064. * @param scene defines the hosting scene
  99065. */
  99066. constructor(scene: Scene);
  99067. /** @hidden */
  99068. protected _updateDebugMeshes(): void;
  99069. /**
  99070. * Renders a specified physic impostor
  99071. * @param impostor defines the impostor to render
  99072. * @returns the new debug mesh used to render the impostor
  99073. */
  99074. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  99075. /**
  99076. * Hides a specified physic impostor
  99077. * @param impostor defines the impostor to hide
  99078. */
  99079. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  99080. private _getDebugMaterial;
  99081. private _getDebugBoxMesh;
  99082. private _getDebugSphereMesh;
  99083. private _getDebugMesh;
  99084. /** Releases all resources */
  99085. dispose(): void;
  99086. }
  99087. }
  99088. declare module BABYLON {
  99089. /**
  99090. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99091. * in order to better appreciate the issue one might have.
  99092. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99093. */
  99094. export class RayHelper {
  99095. /**
  99096. * Defines the ray we are currently tryin to visualize.
  99097. */
  99098. ray: Nullable<Ray>;
  99099. private _renderPoints;
  99100. private _renderLine;
  99101. private _renderFunction;
  99102. private _scene;
  99103. private _updateToMeshFunction;
  99104. private _attachedToMesh;
  99105. private _meshSpaceDirection;
  99106. private _meshSpaceOrigin;
  99107. /**
  99108. * Helper function to create a colored helper in a scene in one line.
  99109. * @param ray Defines the ray we are currently tryin to visualize
  99110. * @param scene Defines the scene the ray is used in
  99111. * @param color Defines the color we want to see the ray in
  99112. * @returns The newly created ray helper.
  99113. */
  99114. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  99115. /**
  99116. * Instantiate a new ray helper.
  99117. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99118. * in order to better appreciate the issue one might have.
  99119. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99120. * @param ray Defines the ray we are currently tryin to visualize
  99121. */
  99122. constructor(ray: Ray);
  99123. /**
  99124. * Shows the ray we are willing to debug.
  99125. * @param scene Defines the scene the ray needs to be rendered in
  99126. * @param color Defines the color the ray needs to be rendered in
  99127. */
  99128. show(scene: Scene, color?: Color3): void;
  99129. /**
  99130. * Hides the ray we are debugging.
  99131. */
  99132. hide(): void;
  99133. private _render;
  99134. /**
  99135. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  99136. * @param mesh Defines the mesh we want the helper attached to
  99137. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  99138. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  99139. * @param length Defines the length of the ray
  99140. */
  99141. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  99142. /**
  99143. * Detach the ray helper from the mesh it has previously been attached to.
  99144. */
  99145. detachFromMesh(): void;
  99146. private _updateToMesh;
  99147. /**
  99148. * Dispose the helper and release its associated resources.
  99149. */
  99150. dispose(): void;
  99151. }
  99152. }
  99153. declare module BABYLON.Debug {
  99154. /**
  99155. * Class used to render a debug view of a given skeleton
  99156. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  99157. */
  99158. export class SkeletonViewer {
  99159. /** defines the skeleton to render */
  99160. skeleton: Skeleton;
  99161. /** defines the mesh attached to the skeleton */
  99162. mesh: AbstractMesh;
  99163. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99164. autoUpdateBonesMatrices: boolean;
  99165. /** defines the rendering group id to use with the viewer */
  99166. renderingGroupId: number;
  99167. /** Gets or sets the color used to render the skeleton */
  99168. color: Color3;
  99169. private _scene;
  99170. private _debugLines;
  99171. private _debugMesh;
  99172. private _isEnabled;
  99173. private _renderFunction;
  99174. private _utilityLayer;
  99175. /**
  99176. * Returns the mesh used to render the bones
  99177. */
  99178. readonly debugMesh: Nullable<LinesMesh>;
  99179. /**
  99180. * Creates a new SkeletonViewer
  99181. * @param skeleton defines the skeleton to render
  99182. * @param mesh defines the mesh attached to the skeleton
  99183. * @param scene defines the hosting scene
  99184. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  99185. * @param renderingGroupId defines the rendering group id to use with the viewer
  99186. */
  99187. constructor(
  99188. /** defines the skeleton to render */
  99189. skeleton: Skeleton,
  99190. /** defines the mesh attached to the skeleton */
  99191. mesh: AbstractMesh, scene: Scene,
  99192. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99193. autoUpdateBonesMatrices?: boolean,
  99194. /** defines the rendering group id to use with the viewer */
  99195. renderingGroupId?: number);
  99196. /** Gets or sets a boolean indicating if the viewer is enabled */
  99197. isEnabled: boolean;
  99198. private _getBonePosition;
  99199. private _getLinesForBonesWithLength;
  99200. private _getLinesForBonesNoLength;
  99201. /** Update the viewer to sync with current skeleton state */
  99202. update(): void;
  99203. /** Release associated resources */
  99204. dispose(): void;
  99205. }
  99206. }
  99207. declare module BABYLON {
  99208. /**
  99209. * Options to create the null engine
  99210. */
  99211. export class NullEngineOptions {
  99212. /**
  99213. * Render width (Default: 512)
  99214. */
  99215. renderWidth: number;
  99216. /**
  99217. * Render height (Default: 256)
  99218. */
  99219. renderHeight: number;
  99220. /**
  99221. * Texture size (Default: 512)
  99222. */
  99223. textureSize: number;
  99224. /**
  99225. * If delta time between frames should be constant
  99226. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99227. */
  99228. deterministicLockstep: boolean;
  99229. /**
  99230. * Maximum about of steps between frames (Default: 4)
  99231. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99232. */
  99233. lockstepMaxSteps: number;
  99234. }
  99235. /**
  99236. * The null engine class provides support for headless version of babylon.js.
  99237. * This can be used in server side scenario or for testing purposes
  99238. */
  99239. export class NullEngine extends Engine {
  99240. private _options;
  99241. /**
  99242. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99243. */
  99244. isDeterministicLockStep(): boolean;
  99245. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  99246. getLockstepMaxSteps(): number;
  99247. /**
  99248. * Sets hardware scaling, used to save performance if needed
  99249. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99250. */
  99251. getHardwareScalingLevel(): number;
  99252. constructor(options?: NullEngineOptions);
  99253. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99254. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  99255. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99256. getRenderWidth(useScreen?: boolean): number;
  99257. getRenderHeight(useScreen?: boolean): number;
  99258. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  99259. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  99260. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  99261. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  99262. bindSamplers(effect: Effect): void;
  99263. enableEffect(effect: Effect): void;
  99264. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99265. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  99266. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  99267. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  99268. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  99269. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  99270. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  99271. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  99272. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  99273. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  99274. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  99275. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  99276. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  99277. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  99278. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  99279. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99280. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99281. setFloat(uniform: WebGLUniformLocation, value: number): void;
  99282. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  99283. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  99284. setBool(uniform: WebGLUniformLocation, bool: number): void;
  99285. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  99286. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  99287. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  99288. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99289. bindBuffers(vertexBuffers: {
  99290. [key: string]: VertexBuffer;
  99291. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  99292. wipeCaches(bruteForce?: boolean): void;
  99293. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99294. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99295. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99296. /** @hidden */
  99297. _createTexture(): WebGLTexture;
  99298. /** @hidden */
  99299. _releaseTexture(texture: InternalTexture): void;
  99300. 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;
  99301. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  99302. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  99303. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  99304. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99305. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99306. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  99307. areAllEffectsReady(): boolean;
  99308. /**
  99309. * @hidden
  99310. * Get the current error code of the webGL context
  99311. * @returns the error code
  99312. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  99313. */
  99314. getError(): number;
  99315. /** @hidden */
  99316. _getUnpackAlignement(): number;
  99317. /** @hidden */
  99318. _unpackFlipY(value: boolean): void;
  99319. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  99320. /**
  99321. * Updates a dynamic vertex buffer.
  99322. * @param vertexBuffer the vertex buffer to update
  99323. * @param data the data used to update the vertex buffer
  99324. * @param byteOffset the byte offset of the data (optional)
  99325. * @param byteLength the byte length of the data (optional)
  99326. */
  99327. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  99328. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  99329. /** @hidden */
  99330. _bindTexture(channel: number, texture: InternalTexture): void;
  99331. /** @hidden */
  99332. _releaseBuffer(buffer: WebGLBuffer): boolean;
  99333. releaseEffects(): void;
  99334. displayLoadingUI(): void;
  99335. hideLoadingUI(): void;
  99336. /** @hidden */
  99337. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99338. /** @hidden */
  99339. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99340. /** @hidden */
  99341. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99342. /** @hidden */
  99343. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  99344. }
  99345. }
  99346. declare module BABYLON {
  99347. /** @hidden */
  99348. export class _OcclusionDataStorage {
  99349. /** @hidden */
  99350. occlusionInternalRetryCounter: number;
  99351. /** @hidden */
  99352. isOcclusionQueryInProgress: boolean;
  99353. /** @hidden */
  99354. isOccluded: boolean;
  99355. /** @hidden */
  99356. occlusionRetryCount: number;
  99357. /** @hidden */
  99358. occlusionType: number;
  99359. /** @hidden */
  99360. occlusionQueryAlgorithmType: number;
  99361. }
  99362. interface Engine {
  99363. /**
  99364. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  99365. * @return the new query
  99366. */
  99367. createQuery(): WebGLQuery;
  99368. /**
  99369. * Delete and release a webGL query
  99370. * @param query defines the query to delete
  99371. * @return the current engine
  99372. */
  99373. deleteQuery(query: WebGLQuery): Engine;
  99374. /**
  99375. * Check if a given query has resolved and got its value
  99376. * @param query defines the query to check
  99377. * @returns true if the query got its value
  99378. */
  99379. isQueryResultAvailable(query: WebGLQuery): boolean;
  99380. /**
  99381. * Gets the value of a given query
  99382. * @param query defines the query to check
  99383. * @returns the value of the query
  99384. */
  99385. getQueryResult(query: WebGLQuery): number;
  99386. /**
  99387. * Initiates an occlusion query
  99388. * @param algorithmType defines the algorithm to use
  99389. * @param query defines the query to use
  99390. * @returns the current engine
  99391. * @see http://doc.babylonjs.com/features/occlusionquery
  99392. */
  99393. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  99394. /**
  99395. * Ends an occlusion query
  99396. * @see http://doc.babylonjs.com/features/occlusionquery
  99397. * @param algorithmType defines the algorithm to use
  99398. * @returns the current engine
  99399. */
  99400. endOcclusionQuery(algorithmType: number): Engine;
  99401. /**
  99402. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  99403. * Please note that only one query can be issued at a time
  99404. * @returns a time token used to track the time span
  99405. */
  99406. startTimeQuery(): Nullable<_TimeToken>;
  99407. /**
  99408. * Ends a time query
  99409. * @param token defines the token used to measure the time span
  99410. * @returns the time spent (in ns)
  99411. */
  99412. endTimeQuery(token: _TimeToken): int;
  99413. /** @hidden */
  99414. _currentNonTimestampToken: Nullable<_TimeToken>;
  99415. /** @hidden */
  99416. _createTimeQuery(): WebGLQuery;
  99417. /** @hidden */
  99418. _deleteTimeQuery(query: WebGLQuery): void;
  99419. /** @hidden */
  99420. _getGlAlgorithmType(algorithmType: number): number;
  99421. /** @hidden */
  99422. _getTimeQueryResult(query: WebGLQuery): any;
  99423. /** @hidden */
  99424. _getTimeQueryAvailability(query: WebGLQuery): any;
  99425. }
  99426. interface AbstractMesh {
  99427. /**
  99428. * Backing filed
  99429. * @hidden
  99430. */
  99431. __occlusionDataStorage: _OcclusionDataStorage;
  99432. /**
  99433. * Access property
  99434. * @hidden
  99435. */
  99436. _occlusionDataStorage: _OcclusionDataStorage;
  99437. /**
  99438. * 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.
  99439. * The default value is -1 which means don't break the query and wait till the result
  99440. * @see http://doc.babylonjs.com/features/occlusionquery
  99441. */
  99442. occlusionRetryCount: number;
  99443. /**
  99444. * 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:
  99445. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  99446. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  99447. * * 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.
  99448. * @see http://doc.babylonjs.com/features/occlusionquery
  99449. */
  99450. occlusionType: number;
  99451. /**
  99452. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  99453. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  99454. * * 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.
  99455. * @see http://doc.babylonjs.com/features/occlusionquery
  99456. */
  99457. occlusionQueryAlgorithmType: number;
  99458. /**
  99459. * 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
  99460. * @see http://doc.babylonjs.com/features/occlusionquery
  99461. */
  99462. isOccluded: boolean;
  99463. /**
  99464. * Flag to check the progress status of the query
  99465. * @see http://doc.babylonjs.com/features/occlusionquery
  99466. */
  99467. isOcclusionQueryInProgress: boolean;
  99468. }
  99469. }
  99470. declare module BABYLON {
  99471. /** @hidden */
  99472. export var _forceTransformFeedbackToBundle: boolean;
  99473. interface Engine {
  99474. /**
  99475. * Creates a webGL transform feedback object
  99476. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  99477. * @returns the webGL transform feedback object
  99478. */
  99479. createTransformFeedback(): WebGLTransformFeedback;
  99480. /**
  99481. * Delete a webGL transform feedback object
  99482. * @param value defines the webGL transform feedback object to delete
  99483. */
  99484. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  99485. /**
  99486. * Bind a webGL transform feedback object to the webgl context
  99487. * @param value defines the webGL transform feedback object to bind
  99488. */
  99489. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  99490. /**
  99491. * Begins a transform feedback operation
  99492. * @param usePoints defines if points or triangles must be used
  99493. */
  99494. beginTransformFeedback(usePoints: boolean): void;
  99495. /**
  99496. * Ends a transform feedback operation
  99497. */
  99498. endTransformFeedback(): void;
  99499. /**
  99500. * Specify the varyings to use with transform feedback
  99501. * @param program defines the associated webGL program
  99502. * @param value defines the list of strings representing the varying names
  99503. */
  99504. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  99505. /**
  99506. * Bind a webGL buffer for a transform feedback operation
  99507. * @param value defines the webGL buffer to bind
  99508. */
  99509. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  99510. }
  99511. }
  99512. declare module BABYLON {
  99513. /**
  99514. * Gather the list of clipboard event types as constants.
  99515. */
  99516. export class ClipboardEventTypes {
  99517. /**
  99518. * The clipboard event is fired when a copy command is active (pressed).
  99519. */
  99520. static readonly COPY: number;
  99521. /**
  99522. * The clipboard event is fired when a cut command is active (pressed).
  99523. */
  99524. static readonly CUT: number;
  99525. /**
  99526. * The clipboard event is fired when a paste command is active (pressed).
  99527. */
  99528. static readonly PASTE: number;
  99529. }
  99530. /**
  99531. * This class is used to store clipboard related info for the onClipboardObservable event.
  99532. */
  99533. export class ClipboardInfo {
  99534. /**
  99535. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99536. */
  99537. type: number;
  99538. /**
  99539. * Defines the related dom event
  99540. */
  99541. event: ClipboardEvent;
  99542. /**
  99543. *Creates an instance of ClipboardInfo.
  99544. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  99545. * @param event Defines the related dom event
  99546. */
  99547. constructor(
  99548. /**
  99549. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99550. */
  99551. type: number,
  99552. /**
  99553. * Defines the related dom event
  99554. */
  99555. event: ClipboardEvent);
  99556. /**
  99557. * Get the clipboard event's type from the keycode.
  99558. * @param keyCode Defines the keyCode for the current keyboard event.
  99559. * @return {number}
  99560. */
  99561. static GetTypeFromCharacter(keyCode: number): number;
  99562. }
  99563. }
  99564. declare module BABYLON {
  99565. /**
  99566. * Class used to represent data loading progression
  99567. */
  99568. export class SceneLoaderProgressEvent {
  99569. /** defines if data length to load can be evaluated */
  99570. readonly lengthComputable: boolean;
  99571. /** defines the loaded data length */
  99572. readonly loaded: number;
  99573. /** defines the data length to load */
  99574. readonly total: number;
  99575. /**
  99576. * Create a new progress event
  99577. * @param lengthComputable defines if data length to load can be evaluated
  99578. * @param loaded defines the loaded data length
  99579. * @param total defines the data length to load
  99580. */
  99581. constructor(
  99582. /** defines if data length to load can be evaluated */
  99583. lengthComputable: boolean,
  99584. /** defines the loaded data length */
  99585. loaded: number,
  99586. /** defines the data length to load */
  99587. total: number);
  99588. /**
  99589. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  99590. * @param event defines the source event
  99591. * @returns a new SceneLoaderProgressEvent
  99592. */
  99593. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  99594. }
  99595. /**
  99596. * Interface used by SceneLoader plugins to define supported file extensions
  99597. */
  99598. export interface ISceneLoaderPluginExtensions {
  99599. /**
  99600. * Defines the list of supported extensions
  99601. */
  99602. [extension: string]: {
  99603. isBinary: boolean;
  99604. };
  99605. }
  99606. /**
  99607. * Interface used by SceneLoader plugin factory
  99608. */
  99609. export interface ISceneLoaderPluginFactory {
  99610. /**
  99611. * Defines the name of the factory
  99612. */
  99613. name: string;
  99614. /**
  99615. * Function called to create a new plugin
  99616. * @return the new plugin
  99617. */
  99618. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  99619. /**
  99620. * Boolean indicating if the plugin can direct load specific data
  99621. */
  99622. canDirectLoad?: (data: string) => boolean;
  99623. }
  99624. /**
  99625. * Interface used to define a SceneLoader plugin
  99626. */
  99627. export interface ISceneLoaderPlugin {
  99628. /**
  99629. * The friendly name of this plugin.
  99630. */
  99631. name: string;
  99632. /**
  99633. * The file extensions supported by this plugin.
  99634. */
  99635. extensions: string | ISceneLoaderPluginExtensions;
  99636. /**
  99637. * Import meshes into a scene.
  99638. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99639. * @param scene The scene to import into
  99640. * @param data The data to import
  99641. * @param rootUrl The root url for scene and resources
  99642. * @param meshes The meshes array to import into
  99643. * @param particleSystems The particle systems array to import into
  99644. * @param skeletons The skeletons array to import into
  99645. * @param onError The callback when import fails
  99646. * @returns True if successful or false otherwise
  99647. */
  99648. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  99649. /**
  99650. * Load into a scene.
  99651. * @param scene The scene to load into
  99652. * @param data The data to import
  99653. * @param rootUrl The root url for scene and resources
  99654. * @param onError The callback when import fails
  99655. * @returns true if successful or false otherwise
  99656. */
  99657. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  99658. /**
  99659. * The callback that returns true if the data can be directly loaded.
  99660. */
  99661. canDirectLoad?: (data: string) => boolean;
  99662. /**
  99663. * The callback that allows custom handling of the root url based on the response url.
  99664. */
  99665. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99666. /**
  99667. * Load into an asset container.
  99668. * @param scene The scene to load into
  99669. * @param data The data to import
  99670. * @param rootUrl The root url for scene and resources
  99671. * @param onError The callback when import fails
  99672. * @returns The loaded asset container
  99673. */
  99674. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  99675. }
  99676. /**
  99677. * Interface used to define an async SceneLoader plugin
  99678. */
  99679. export interface ISceneLoaderPluginAsync {
  99680. /**
  99681. * The friendly name of this plugin.
  99682. */
  99683. name: string;
  99684. /**
  99685. * The file extensions supported by this plugin.
  99686. */
  99687. extensions: string | ISceneLoaderPluginExtensions;
  99688. /**
  99689. * Import meshes into a scene.
  99690. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99691. * @param scene The scene to import into
  99692. * @param data The data to import
  99693. * @param rootUrl The root url for scene and resources
  99694. * @param onProgress The callback when the load progresses
  99695. * @param fileName Defines the name of the file to load
  99696. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  99697. */
  99698. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  99699. meshes: AbstractMesh[];
  99700. particleSystems: IParticleSystem[];
  99701. skeletons: Skeleton[];
  99702. animationGroups: AnimationGroup[];
  99703. }>;
  99704. /**
  99705. * Load into a scene.
  99706. * @param scene The scene to load into
  99707. * @param data The data to import
  99708. * @param rootUrl The root url for scene and resources
  99709. * @param onProgress The callback when the load progresses
  99710. * @param fileName Defines the name of the file to load
  99711. * @returns Nothing
  99712. */
  99713. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  99714. /**
  99715. * The callback that returns true if the data can be directly loaded.
  99716. */
  99717. canDirectLoad?: (data: string) => boolean;
  99718. /**
  99719. * The callback that allows custom handling of the root url based on the response url.
  99720. */
  99721. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99722. /**
  99723. * Load into an asset container.
  99724. * @param scene The scene to load into
  99725. * @param data The data to import
  99726. * @param rootUrl The root url for scene and resources
  99727. * @param onProgress The callback when the load progresses
  99728. * @param fileName Defines the name of the file to load
  99729. * @returns The loaded asset container
  99730. */
  99731. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  99732. }
  99733. /**
  99734. * Class used to load scene from various file formats using registered plugins
  99735. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  99736. */
  99737. export class SceneLoader {
  99738. /**
  99739. * No logging while loading
  99740. */
  99741. static readonly NO_LOGGING: number;
  99742. /**
  99743. * Minimal logging while loading
  99744. */
  99745. static readonly MINIMAL_LOGGING: number;
  99746. /**
  99747. * Summary logging while loading
  99748. */
  99749. static readonly SUMMARY_LOGGING: number;
  99750. /**
  99751. * Detailled logging while loading
  99752. */
  99753. static readonly DETAILED_LOGGING: number;
  99754. /**
  99755. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  99756. */
  99757. static ForceFullSceneLoadingForIncremental: boolean;
  99758. /**
  99759. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  99760. */
  99761. static ShowLoadingScreen: boolean;
  99762. /**
  99763. * Defines the current logging level (while loading the scene)
  99764. * @ignorenaming
  99765. */
  99766. static loggingLevel: number;
  99767. /**
  99768. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  99769. */
  99770. static CleanBoneMatrixWeights: boolean;
  99771. /**
  99772. * Event raised when a plugin is used to load a scene
  99773. */
  99774. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  99775. private static _registeredPlugins;
  99776. private static _getDefaultPlugin;
  99777. private static _getPluginForExtension;
  99778. private static _getPluginForDirectLoad;
  99779. private static _getPluginForFilename;
  99780. private static _getDirectLoad;
  99781. private static _loadData;
  99782. private static _getFileInfo;
  99783. /**
  99784. * Gets a plugin that can load the given extension
  99785. * @param extension defines the extension to load
  99786. * @returns a plugin or null if none works
  99787. */
  99788. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  99789. /**
  99790. * Gets a boolean indicating that the given extension can be loaded
  99791. * @param extension defines the extension to load
  99792. * @returns true if the extension is supported
  99793. */
  99794. static IsPluginForExtensionAvailable(extension: string): boolean;
  99795. /**
  99796. * Adds a new plugin to the list of registered plugins
  99797. * @param plugin defines the plugin to add
  99798. */
  99799. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  99800. /**
  99801. * Import meshes into a scene
  99802. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99803. * @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)
  99804. * @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)
  99805. * @param scene the instance of BABYLON.Scene to append to
  99806. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  99807. * @param onProgress a callback with a progress event for each file being loaded
  99808. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99809. * @param pluginExtension the extension used to determine the plugin
  99810. * @returns The loaded plugin
  99811. */
  99812. 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>;
  99813. /**
  99814. * Import meshes into a scene
  99815. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99816. * @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)
  99817. * @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)
  99818. * @param scene the instance of BABYLON.Scene to append to
  99819. * @param onProgress a callback with a progress event for each file being loaded
  99820. * @param pluginExtension the extension used to determine the plugin
  99821. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  99822. */
  99823. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  99824. meshes: AbstractMesh[];
  99825. particleSystems: IParticleSystem[];
  99826. skeletons: Skeleton[];
  99827. animationGroups: AnimationGroup[];
  99828. }>;
  99829. /**
  99830. * Load a scene
  99831. * @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)
  99832. * @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)
  99833. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99834. * @param onSuccess a callback with the scene when import succeeds
  99835. * @param onProgress a callback with a progress event for each file being loaded
  99836. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99837. * @param pluginExtension the extension used to determine the plugin
  99838. * @returns The loaded plugin
  99839. */
  99840. 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>;
  99841. /**
  99842. * Load a scene
  99843. * @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)
  99844. * @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)
  99845. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99846. * @param onProgress a callback with a progress event for each file being loaded
  99847. * @param pluginExtension the extension used to determine the plugin
  99848. * @returns The loaded scene
  99849. */
  99850. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99851. /**
  99852. * Append a scene
  99853. * @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)
  99854. * @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)
  99855. * @param scene is the instance of BABYLON.Scene to append to
  99856. * @param onSuccess a callback with the scene when import succeeds
  99857. * @param onProgress a callback with a progress event for each file being loaded
  99858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99859. * @param pluginExtension the extension used to determine the plugin
  99860. * @returns The loaded plugin
  99861. */
  99862. 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>;
  99863. /**
  99864. * Append a scene
  99865. * @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)
  99866. * @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)
  99867. * @param scene is the instance of BABYLON.Scene to append to
  99868. * @param onProgress a callback with a progress event for each file being loaded
  99869. * @param pluginExtension the extension used to determine the plugin
  99870. * @returns The given scene
  99871. */
  99872. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99873. /**
  99874. * Load a scene into an asset container
  99875. * @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)
  99876. * @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)
  99877. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  99878. * @param onSuccess a callback with the scene when import succeeds
  99879. * @param onProgress a callback with a progress event for each file being loaded
  99880. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99881. * @param pluginExtension the extension used to determine the plugin
  99882. * @returns The loaded plugin
  99883. */
  99884. 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>;
  99885. /**
  99886. * Load a scene into an asset container
  99887. * @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)
  99888. * @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)
  99889. * @param scene is the instance of Scene to append to
  99890. * @param onProgress a callback with a progress event for each file being loaded
  99891. * @param pluginExtension the extension used to determine the plugin
  99892. * @returns The loaded asset container
  99893. */
  99894. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  99895. }
  99896. }
  99897. declare module BABYLON {
  99898. /**
  99899. * Google Daydream controller
  99900. */
  99901. export class DaydreamController extends WebVRController {
  99902. /**
  99903. * Base Url for the controller model.
  99904. */
  99905. static MODEL_BASE_URL: string;
  99906. /**
  99907. * File name for the controller model.
  99908. */
  99909. static MODEL_FILENAME: string;
  99910. /**
  99911. * Gamepad Id prefix used to identify Daydream Controller.
  99912. */
  99913. static readonly GAMEPAD_ID_PREFIX: string;
  99914. /**
  99915. * Creates a new DaydreamController from a gamepad
  99916. * @param vrGamepad the gamepad that the controller should be created from
  99917. */
  99918. constructor(vrGamepad: any);
  99919. /**
  99920. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99921. * @param scene scene in which to add meshes
  99922. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99923. */
  99924. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99925. /**
  99926. * Called once for each button that changed state since the last frame
  99927. * @param buttonIdx Which button index changed
  99928. * @param state New state of the button
  99929. * @param changes Which properties on the state changed since last frame
  99930. */
  99931. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99932. }
  99933. }
  99934. declare module BABYLON {
  99935. /**
  99936. * Gear VR Controller
  99937. */
  99938. export class GearVRController extends WebVRController {
  99939. /**
  99940. * Base Url for the controller model.
  99941. */
  99942. static MODEL_BASE_URL: string;
  99943. /**
  99944. * File name for the controller model.
  99945. */
  99946. static MODEL_FILENAME: string;
  99947. /**
  99948. * Gamepad Id prefix used to identify this controller.
  99949. */
  99950. static readonly GAMEPAD_ID_PREFIX: string;
  99951. private readonly _buttonIndexToObservableNameMap;
  99952. /**
  99953. * Creates a new GearVRController from a gamepad
  99954. * @param vrGamepad the gamepad that the controller should be created from
  99955. */
  99956. constructor(vrGamepad: any);
  99957. /**
  99958. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99959. * @param scene scene in which to add meshes
  99960. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99961. */
  99962. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99963. /**
  99964. * Called once for each button that changed state since the last frame
  99965. * @param buttonIdx Which button index changed
  99966. * @param state New state of the button
  99967. * @param changes Which properties on the state changed since last frame
  99968. */
  99969. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99970. }
  99971. }
  99972. declare module BABYLON {
  99973. /**
  99974. * Generic Controller
  99975. */
  99976. export class GenericController extends WebVRController {
  99977. /**
  99978. * Base Url for the controller model.
  99979. */
  99980. static readonly MODEL_BASE_URL: string;
  99981. /**
  99982. * File name for the controller model.
  99983. */
  99984. static readonly MODEL_FILENAME: string;
  99985. /**
  99986. * Creates a new GenericController from a gamepad
  99987. * @param vrGamepad the gamepad that the controller should be created from
  99988. */
  99989. constructor(vrGamepad: any);
  99990. /**
  99991. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99992. * @param scene scene in which to add meshes
  99993. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99994. */
  99995. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99996. /**
  99997. * Called once for each button that changed state since the last frame
  99998. * @param buttonIdx Which button index changed
  99999. * @param state New state of the button
  100000. * @param changes Which properties on the state changed since last frame
  100001. */
  100002. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100003. }
  100004. }
  100005. declare module BABYLON {
  100006. /**
  100007. * Oculus Touch Controller
  100008. */
  100009. export class OculusTouchController extends WebVRController {
  100010. /**
  100011. * Base Url for the controller model.
  100012. */
  100013. static MODEL_BASE_URL: string;
  100014. /**
  100015. * File name for the left controller model.
  100016. */
  100017. static MODEL_LEFT_FILENAME: string;
  100018. /**
  100019. * File name for the right controller model.
  100020. */
  100021. static MODEL_RIGHT_FILENAME: string;
  100022. /**
  100023. * Fired when the secondary trigger on this controller is modified
  100024. */
  100025. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100026. /**
  100027. * Fired when the thumb rest on this controller is modified
  100028. */
  100029. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  100030. /**
  100031. * Creates a new OculusTouchController from a gamepad
  100032. * @param vrGamepad the gamepad that the controller should be created from
  100033. */
  100034. constructor(vrGamepad: any);
  100035. /**
  100036. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100037. * @param scene scene in which to add meshes
  100038. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100039. */
  100040. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100041. /**
  100042. * Fired when the A button on this controller is modified
  100043. */
  100044. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100045. /**
  100046. * Fired when the B button on this controller is modified
  100047. */
  100048. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100049. /**
  100050. * Fired when the X button on this controller is modified
  100051. */
  100052. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100053. /**
  100054. * Fired when the Y button on this controller is modified
  100055. */
  100056. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100057. /**
  100058. * Called once for each button that changed state since the last frame
  100059. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  100060. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  100061. * 2) secondary trigger (same)
  100062. * 3) A (right) X (left), touch, pressed = value
  100063. * 4) B / Y
  100064. * 5) thumb rest
  100065. * @param buttonIdx Which button index changed
  100066. * @param state New state of the button
  100067. * @param changes Which properties on the state changed since last frame
  100068. */
  100069. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100070. }
  100071. }
  100072. declare module BABYLON {
  100073. /**
  100074. * Vive Controller
  100075. */
  100076. export class ViveController extends WebVRController {
  100077. /**
  100078. * Base Url for the controller model.
  100079. */
  100080. static MODEL_BASE_URL: string;
  100081. /**
  100082. * File name for the controller model.
  100083. */
  100084. static MODEL_FILENAME: string;
  100085. /**
  100086. * Creates a new ViveController from a gamepad
  100087. * @param vrGamepad the gamepad that the controller should be created from
  100088. */
  100089. constructor(vrGamepad: any);
  100090. /**
  100091. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100092. * @param scene scene in which to add meshes
  100093. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100094. */
  100095. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100096. /**
  100097. * Fired when the left button on this controller is modified
  100098. */
  100099. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100100. /**
  100101. * Fired when the right button on this controller is modified
  100102. */
  100103. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100104. /**
  100105. * Fired when the menu button on this controller is modified
  100106. */
  100107. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100108. /**
  100109. * Called once for each button that changed state since the last frame
  100110. * Vive mapping:
  100111. * 0: touchpad
  100112. * 1: trigger
  100113. * 2: left AND right buttons
  100114. * 3: menu button
  100115. * @param buttonIdx Which button index changed
  100116. * @param state New state of the button
  100117. * @param changes Which properties on the state changed since last frame
  100118. */
  100119. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100120. }
  100121. }
  100122. declare module BABYLON {
  100123. /**
  100124. * Defines the WindowsMotionController object that the state of the windows motion controller
  100125. */
  100126. export class WindowsMotionController extends WebVRController {
  100127. /**
  100128. * The base url used to load the left and right controller models
  100129. */
  100130. static MODEL_BASE_URL: string;
  100131. /**
  100132. * The name of the left controller model file
  100133. */
  100134. static MODEL_LEFT_FILENAME: string;
  100135. /**
  100136. * The name of the right controller model file
  100137. */
  100138. static MODEL_RIGHT_FILENAME: string;
  100139. /**
  100140. * The controller name prefix for this controller type
  100141. */
  100142. static readonly GAMEPAD_ID_PREFIX: string;
  100143. /**
  100144. * The controller id pattern for this controller type
  100145. */
  100146. private static readonly GAMEPAD_ID_PATTERN;
  100147. private _loadedMeshInfo;
  100148. private readonly _mapping;
  100149. /**
  100150. * Fired when the trackpad on this controller is clicked
  100151. */
  100152. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  100153. /**
  100154. * Fired when the trackpad on this controller is modified
  100155. */
  100156. onTrackpadValuesChangedObservable: Observable<StickValues>;
  100157. /**
  100158. * The current x and y values of this controller's trackpad
  100159. */
  100160. trackpad: StickValues;
  100161. /**
  100162. * Creates a new WindowsMotionController from a gamepad
  100163. * @param vrGamepad the gamepad that the controller should be created from
  100164. */
  100165. constructor(vrGamepad: any);
  100166. /**
  100167. * Fired when the trigger on this controller is modified
  100168. */
  100169. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100170. /**
  100171. * Fired when the menu button on this controller is modified
  100172. */
  100173. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100174. /**
  100175. * Fired when the grip button on this controller is modified
  100176. */
  100177. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100178. /**
  100179. * Fired when the thumbstick button on this controller is modified
  100180. */
  100181. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100182. /**
  100183. * Fired when the touchpad button on this controller is modified
  100184. */
  100185. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100186. /**
  100187. * Fired when the touchpad values on this controller are modified
  100188. */
  100189. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  100190. private _updateTrackpad;
  100191. /**
  100192. * Called once per frame by the engine.
  100193. */
  100194. update(): void;
  100195. /**
  100196. * Called once for each button that changed state since the last frame
  100197. * @param buttonIdx Which button index changed
  100198. * @param state New state of the button
  100199. * @param changes Which properties on the state changed since last frame
  100200. */
  100201. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100202. /**
  100203. * Moves the buttons on the controller mesh based on their current state
  100204. * @param buttonName the name of the button to move
  100205. * @param buttonValue the value of the button which determines the buttons new position
  100206. */
  100207. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  100208. /**
  100209. * Moves the axis on the controller mesh based on its current state
  100210. * @param axis the index of the axis
  100211. * @param axisValue the value of the axis which determines the meshes new position
  100212. * @hidden
  100213. */
  100214. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  100215. /**
  100216. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100217. * @param scene scene in which to add meshes
  100218. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100219. */
  100220. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  100221. /**
  100222. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  100223. * can be transformed by button presses and axes values, based on this._mapping.
  100224. *
  100225. * @param scene scene in which the meshes exist
  100226. * @param meshes list of meshes that make up the controller model to process
  100227. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  100228. */
  100229. private processModel;
  100230. private createMeshInfo;
  100231. /**
  100232. * Gets the ray of the controller in the direction the controller is pointing
  100233. * @param length the length the resulting ray should be
  100234. * @returns a ray in the direction the controller is pointing
  100235. */
  100236. getForwardRay(length?: number): Ray;
  100237. /**
  100238. * Disposes of the controller
  100239. */
  100240. dispose(): void;
  100241. }
  100242. }
  100243. declare module BABYLON {
  100244. /**
  100245. * Single axis scale gizmo
  100246. */
  100247. export class AxisScaleGizmo extends Gizmo {
  100248. private _coloredMaterial;
  100249. /**
  100250. * Drag behavior responsible for the gizmos dragging interactions
  100251. */
  100252. dragBehavior: PointerDragBehavior;
  100253. private _pointerObserver;
  100254. /**
  100255. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100256. */
  100257. snapDistance: number;
  100258. /**
  100259. * Event that fires each time the gizmo snaps to a new location.
  100260. * * snapDistance is the the change in distance
  100261. */
  100262. onSnapObservable: Observable<{
  100263. snapDistance: number;
  100264. }>;
  100265. /**
  100266. * If the scaling operation should be done on all axis (default: false)
  100267. */
  100268. uniformScaling: boolean;
  100269. /**
  100270. * Creates an AxisScaleGizmo
  100271. * @param gizmoLayer The utility layer the gizmo will be added to
  100272. * @param dragAxis The axis which the gizmo will be able to scale on
  100273. * @param color The color of the gizmo
  100274. */
  100275. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100276. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100277. /**
  100278. * Disposes of the gizmo
  100279. */
  100280. dispose(): void;
  100281. /**
  100282. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100283. * @param mesh The mesh to replace the default mesh of the gizmo
  100284. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  100285. */
  100286. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  100287. }
  100288. }
  100289. declare module BABYLON {
  100290. /**
  100291. * Bounding box gizmo
  100292. */
  100293. export class BoundingBoxGizmo extends Gizmo {
  100294. private _lineBoundingBox;
  100295. private _rotateSpheresParent;
  100296. private _scaleBoxesParent;
  100297. private _boundingDimensions;
  100298. private _renderObserver;
  100299. private _pointerObserver;
  100300. private _scaleDragSpeed;
  100301. private _tmpQuaternion;
  100302. private _tmpVector;
  100303. private _tmpRotationMatrix;
  100304. /**
  100305. * 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)
  100306. */
  100307. ignoreChildren: boolean;
  100308. /**
  100309. * 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)
  100310. */
  100311. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  100312. /**
  100313. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  100314. */
  100315. rotationSphereSize: number;
  100316. /**
  100317. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  100318. */
  100319. scaleBoxSize: number;
  100320. /**
  100321. * 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)
  100322. */
  100323. fixedDragMeshScreenSize: boolean;
  100324. /**
  100325. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  100326. */
  100327. fixedDragMeshScreenSizeDistanceFactor: number;
  100328. /**
  100329. * Fired when a rotation sphere or scale box is dragged
  100330. */
  100331. onDragStartObservable: Observable<{}>;
  100332. /**
  100333. * Fired when a scale box is dragged
  100334. */
  100335. onScaleBoxDragObservable: Observable<{}>;
  100336. /**
  100337. * Fired when a scale box drag is ended
  100338. */
  100339. onScaleBoxDragEndObservable: Observable<{}>;
  100340. /**
  100341. * Fired when a rotation sphere is dragged
  100342. */
  100343. onRotationSphereDragObservable: Observable<{}>;
  100344. /**
  100345. * Fired when a rotation sphere drag is ended
  100346. */
  100347. onRotationSphereDragEndObservable: Observable<{}>;
  100348. /**
  100349. * 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)
  100350. */
  100351. scalePivot: Nullable<Vector3>;
  100352. private _anchorMesh;
  100353. private _existingMeshScale;
  100354. private _dragMesh;
  100355. private pointerDragBehavior;
  100356. private coloredMaterial;
  100357. private hoverColoredMaterial;
  100358. /**
  100359. * Sets the color of the bounding box gizmo
  100360. * @param color the color to set
  100361. */
  100362. setColor(color: Color3): void;
  100363. /**
  100364. * Creates an BoundingBoxGizmo
  100365. * @param gizmoLayer The utility layer the gizmo will be added to
  100366. * @param color The color of the gizmo
  100367. */
  100368. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100369. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100370. private _selectNode;
  100371. /**
  100372. * Updates the bounding box information for the Gizmo
  100373. */
  100374. updateBoundingBox(): void;
  100375. private _updateRotationSpheres;
  100376. private _updateScaleBoxes;
  100377. /**
  100378. * Enables rotation on the specified axis and disables rotation on the others
  100379. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  100380. */
  100381. setEnabledRotationAxis(axis: string): void;
  100382. /**
  100383. * Enables/disables scaling
  100384. * @param enable if scaling should be enabled
  100385. */
  100386. setEnabledScaling(enable: boolean): void;
  100387. private _updateDummy;
  100388. /**
  100389. * Enables a pointer drag behavior on the bounding box of the gizmo
  100390. */
  100391. enableDragBehavior(): void;
  100392. /**
  100393. * Disposes of the gizmo
  100394. */
  100395. dispose(): void;
  100396. /**
  100397. * 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)
  100398. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  100399. * @returns the bounding box mesh with the passed in mesh as a child
  100400. */
  100401. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  100402. /**
  100403. * CustomMeshes are not supported by this gizmo
  100404. * @param mesh The mesh to replace the default mesh of the gizmo
  100405. */
  100406. setCustomMesh(mesh: Mesh): void;
  100407. }
  100408. }
  100409. declare module BABYLON {
  100410. /**
  100411. * Single plane rotation gizmo
  100412. */
  100413. export class PlaneRotationGizmo extends Gizmo {
  100414. /**
  100415. * Drag behavior responsible for the gizmos dragging interactions
  100416. */
  100417. dragBehavior: PointerDragBehavior;
  100418. private _pointerObserver;
  100419. /**
  100420. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  100421. */
  100422. snapDistance: number;
  100423. /**
  100424. * Event that fires each time the gizmo snaps to a new location.
  100425. * * snapDistance is the the change in distance
  100426. */
  100427. onSnapObservable: Observable<{
  100428. snapDistance: number;
  100429. }>;
  100430. /**
  100431. * Creates a PlaneRotationGizmo
  100432. * @param gizmoLayer The utility layer the gizmo will be added to
  100433. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  100434. * @param color The color of the gizmo
  100435. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100436. */
  100437. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100438. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100439. /**
  100440. * Disposes of the gizmo
  100441. */
  100442. dispose(): void;
  100443. }
  100444. }
  100445. declare module BABYLON {
  100446. /**
  100447. * Gizmo that enables rotating a mesh along 3 axis
  100448. */
  100449. export class RotationGizmo extends Gizmo {
  100450. /**
  100451. * Internal gizmo used for interactions on the x axis
  100452. */
  100453. xGizmo: PlaneRotationGizmo;
  100454. /**
  100455. * Internal gizmo used for interactions on the y axis
  100456. */
  100457. yGizmo: PlaneRotationGizmo;
  100458. /**
  100459. * Internal gizmo used for interactions on the z axis
  100460. */
  100461. zGizmo: PlaneRotationGizmo;
  100462. /** Fires an event when any of it's sub gizmos are dragged */
  100463. onDragStartObservable: Observable<{}>;
  100464. /** Fires an event when any of it's sub gizmos are released from dragging */
  100465. onDragEndObservable: Observable<{}>;
  100466. attachedMesh: Nullable<AbstractMesh>;
  100467. /**
  100468. * Creates a RotationGizmo
  100469. * @param gizmoLayer The utility layer the gizmo will be added to
  100470. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100471. */
  100472. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100473. updateGizmoRotationToMatchAttachedMesh: boolean;
  100474. /**
  100475. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100476. */
  100477. snapDistance: number;
  100478. /**
  100479. * Ratio for the scale of the gizmo (Default: 1)
  100480. */
  100481. scaleRatio: number;
  100482. /**
  100483. * Disposes of the gizmo
  100484. */
  100485. dispose(): void;
  100486. /**
  100487. * CustomMeshes are not supported by this gizmo
  100488. * @param mesh The mesh to replace the default mesh of the gizmo
  100489. */
  100490. setCustomMesh(mesh: Mesh): void;
  100491. }
  100492. }
  100493. declare module BABYLON {
  100494. /**
  100495. * Gizmo that enables dragging a mesh along 3 axis
  100496. */
  100497. export class PositionGizmo extends Gizmo {
  100498. /**
  100499. * Internal gizmo used for interactions on the x axis
  100500. */
  100501. xGizmo: AxisDragGizmo;
  100502. /**
  100503. * Internal gizmo used for interactions on the y axis
  100504. */
  100505. yGizmo: AxisDragGizmo;
  100506. /**
  100507. * Internal gizmo used for interactions on the z axis
  100508. */
  100509. zGizmo: AxisDragGizmo;
  100510. /** Fires an event when any of it's sub gizmos are dragged */
  100511. onDragStartObservable: Observable<{}>;
  100512. /** Fires an event when any of it's sub gizmos are released from dragging */
  100513. onDragEndObservable: Observable<{}>;
  100514. attachedMesh: Nullable<AbstractMesh>;
  100515. /**
  100516. * Creates a PositionGizmo
  100517. * @param gizmoLayer The utility layer the gizmo will be added to
  100518. */
  100519. constructor(gizmoLayer?: UtilityLayerRenderer);
  100520. updateGizmoRotationToMatchAttachedMesh: boolean;
  100521. /**
  100522. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100523. */
  100524. snapDistance: number;
  100525. /**
  100526. * Ratio for the scale of the gizmo (Default: 1)
  100527. */
  100528. scaleRatio: number;
  100529. /**
  100530. * Disposes of the gizmo
  100531. */
  100532. dispose(): void;
  100533. /**
  100534. * CustomMeshes are not supported by this gizmo
  100535. * @param mesh The mesh to replace the default mesh of the gizmo
  100536. */
  100537. setCustomMesh(mesh: Mesh): void;
  100538. }
  100539. }
  100540. declare module BABYLON {
  100541. /**
  100542. * Class containing static functions to help procedurally build meshes
  100543. */
  100544. export class PolyhedronBuilder {
  100545. /**
  100546. * Creates a polyhedron mesh
  100547. * * 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
  100548. * * The parameter `size` (positive float, default 1) sets the polygon size
  100549. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  100550. * * 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`
  100551. * * 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
  100552. * * 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)`)
  100553. * * 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
  100554. * * 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
  100555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100558. * @param name defines the name of the mesh
  100559. * @param options defines the options used to create the mesh
  100560. * @param scene defines the hosting scene
  100561. * @returns the polyhedron mesh
  100562. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  100563. */
  100564. static CreatePolyhedron(name: string, options: {
  100565. type?: number;
  100566. size?: number;
  100567. sizeX?: number;
  100568. sizeY?: number;
  100569. sizeZ?: number;
  100570. custom?: any;
  100571. faceUV?: Vector4[];
  100572. faceColors?: Color4[];
  100573. flat?: boolean;
  100574. updatable?: boolean;
  100575. sideOrientation?: number;
  100576. frontUVs?: Vector4;
  100577. backUVs?: Vector4;
  100578. }, scene: Scene): Mesh;
  100579. }
  100580. }
  100581. declare module BABYLON {
  100582. /**
  100583. * Gizmo that enables scaling a mesh along 3 axis
  100584. */
  100585. export class ScaleGizmo extends Gizmo {
  100586. /**
  100587. * Internal gizmo used for interactions on the x axis
  100588. */
  100589. xGizmo: AxisScaleGizmo;
  100590. /**
  100591. * Internal gizmo used for interactions on the y axis
  100592. */
  100593. yGizmo: AxisScaleGizmo;
  100594. /**
  100595. * Internal gizmo used for interactions on the z axis
  100596. */
  100597. zGizmo: AxisScaleGizmo;
  100598. /**
  100599. * Internal gizmo used to scale all axis equally
  100600. */
  100601. uniformScaleGizmo: AxisScaleGizmo;
  100602. /** Fires an event when any of it's sub gizmos are dragged */
  100603. onDragStartObservable: Observable<{}>;
  100604. /** Fires an event when any of it's sub gizmos are released from dragging */
  100605. onDragEndObservable: Observable<{}>;
  100606. attachedMesh: Nullable<AbstractMesh>;
  100607. /**
  100608. * Creates a ScaleGizmo
  100609. * @param gizmoLayer The utility layer the gizmo will be added to
  100610. */
  100611. constructor(gizmoLayer?: UtilityLayerRenderer);
  100612. updateGizmoRotationToMatchAttachedMesh: boolean;
  100613. /**
  100614. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100615. */
  100616. snapDistance: number;
  100617. /**
  100618. * Ratio for the scale of the gizmo (Default: 1)
  100619. */
  100620. scaleRatio: number;
  100621. /**
  100622. * Disposes of the gizmo
  100623. */
  100624. dispose(): void;
  100625. }
  100626. }
  100627. declare module BABYLON {
  100628. /**
  100629. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  100630. */
  100631. export class GizmoManager implements IDisposable {
  100632. private scene;
  100633. /**
  100634. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  100635. */
  100636. gizmos: {
  100637. positionGizmo: Nullable<PositionGizmo>;
  100638. rotationGizmo: Nullable<RotationGizmo>;
  100639. scaleGizmo: Nullable<ScaleGizmo>;
  100640. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  100641. };
  100642. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  100643. clearGizmoOnEmptyPointerEvent: boolean;
  100644. /** Fires an event when the manager is attached to a mesh */
  100645. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  100646. private _gizmosEnabled;
  100647. private _pointerObserver;
  100648. private _attachedMesh;
  100649. private _boundingBoxColor;
  100650. private _defaultUtilityLayer;
  100651. private _defaultKeepDepthUtilityLayer;
  100652. /**
  100653. * When bounding box gizmo is enabled, this can be used to track drag/end events
  100654. */
  100655. boundingBoxDragBehavior: SixDofDragBehavior;
  100656. /**
  100657. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  100658. */
  100659. attachableMeshes: Nullable<Array<AbstractMesh>>;
  100660. /**
  100661. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  100662. */
  100663. usePointerToAttachGizmos: boolean;
  100664. /**
  100665. * Instatiates a gizmo manager
  100666. * @param scene the scene to overlay the gizmos on top of
  100667. */
  100668. constructor(scene: Scene);
  100669. /**
  100670. * Attaches a set of gizmos to the specified mesh
  100671. * @param mesh The mesh the gizmo's should be attached to
  100672. */
  100673. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  100674. /**
  100675. * If the position gizmo is enabled
  100676. */
  100677. positionGizmoEnabled: boolean;
  100678. /**
  100679. * If the rotation gizmo is enabled
  100680. */
  100681. rotationGizmoEnabled: boolean;
  100682. /**
  100683. * If the scale gizmo is enabled
  100684. */
  100685. scaleGizmoEnabled: boolean;
  100686. /**
  100687. * If the boundingBox gizmo is enabled
  100688. */
  100689. boundingBoxGizmoEnabled: boolean;
  100690. /**
  100691. * Disposes of the gizmo manager
  100692. */
  100693. dispose(): void;
  100694. }
  100695. }
  100696. declare module BABYLON {
  100697. /**
  100698. * Gizmo that enables viewing a light
  100699. */
  100700. export class LightGizmo extends Gizmo {
  100701. private _box;
  100702. /**
  100703. * Creates a LightGizmo
  100704. * @param gizmoLayer The utility layer the gizmo will be added to
  100705. */
  100706. constructor(gizmoLayer?: UtilityLayerRenderer);
  100707. private _light;
  100708. /**
  100709. * The light that the gizmo is attached to
  100710. */
  100711. light: Nullable<Light>;
  100712. /**
  100713. * @hidden
  100714. * Updates the gizmo to match the attached mesh's position/rotation
  100715. */
  100716. protected _update(): void;
  100717. }
  100718. }
  100719. declare module BABYLON {
  100720. /** @hidden */
  100721. export var backgroundFragmentDeclaration: {
  100722. name: string;
  100723. shader: string;
  100724. };
  100725. }
  100726. declare module BABYLON {
  100727. /** @hidden */
  100728. export var backgroundUboDeclaration: {
  100729. name: string;
  100730. shader: string;
  100731. };
  100732. }
  100733. declare module BABYLON {
  100734. /** @hidden */
  100735. export var backgroundPixelShader: {
  100736. name: string;
  100737. shader: string;
  100738. };
  100739. }
  100740. declare module BABYLON {
  100741. /** @hidden */
  100742. export var backgroundVertexDeclaration: {
  100743. name: string;
  100744. shader: string;
  100745. };
  100746. }
  100747. declare module BABYLON {
  100748. /** @hidden */
  100749. export var backgroundVertexShader: {
  100750. name: string;
  100751. shader: string;
  100752. };
  100753. }
  100754. declare module BABYLON {
  100755. /**
  100756. * Background material used to create an efficient environement around your scene.
  100757. */
  100758. export class BackgroundMaterial extends PushMaterial {
  100759. /**
  100760. * Standard reflectance value at parallel view angle.
  100761. */
  100762. static StandardReflectance0: number;
  100763. /**
  100764. * Standard reflectance value at grazing angle.
  100765. */
  100766. static StandardReflectance90: number;
  100767. protected _primaryColor: Color3;
  100768. /**
  100769. * Key light Color (multiply against the environement texture)
  100770. */
  100771. primaryColor: Color3;
  100772. protected __perceptualColor: Nullable<Color3>;
  100773. /**
  100774. * Experimental Internal Use Only.
  100775. *
  100776. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  100777. * This acts as a helper to set the primary color to a more "human friendly" value.
  100778. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  100779. * output color as close as possible from the chosen value.
  100780. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  100781. * part of lighting setup.)
  100782. */
  100783. _perceptualColor: Nullable<Color3>;
  100784. protected _primaryColorShadowLevel: float;
  100785. /**
  100786. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  100787. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  100788. */
  100789. primaryColorShadowLevel: float;
  100790. protected _primaryColorHighlightLevel: float;
  100791. /**
  100792. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  100793. * The primary color is used at the level chosen to define what the white area would look.
  100794. */
  100795. primaryColorHighlightLevel: float;
  100796. protected _reflectionTexture: Nullable<BaseTexture>;
  100797. /**
  100798. * Reflection Texture used in the material.
  100799. * Should be author in a specific way for the best result (refer to the documentation).
  100800. */
  100801. reflectionTexture: Nullable<BaseTexture>;
  100802. protected _reflectionBlur: float;
  100803. /**
  100804. * Reflection Texture level of blur.
  100805. *
  100806. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  100807. * texture twice.
  100808. */
  100809. reflectionBlur: float;
  100810. protected _diffuseTexture: Nullable<BaseTexture>;
  100811. /**
  100812. * Diffuse Texture used in the material.
  100813. * Should be author in a specific way for the best result (refer to the documentation).
  100814. */
  100815. diffuseTexture: Nullable<BaseTexture>;
  100816. protected _shadowLights: Nullable<IShadowLight[]>;
  100817. /**
  100818. * Specify the list of lights casting shadow on the material.
  100819. * All scene shadow lights will be included if null.
  100820. */
  100821. shadowLights: Nullable<IShadowLight[]>;
  100822. protected _shadowLevel: float;
  100823. /**
  100824. * Helps adjusting the shadow to a softer level if required.
  100825. * 0 means black shadows and 1 means no shadows.
  100826. */
  100827. shadowLevel: float;
  100828. protected _sceneCenter: Vector3;
  100829. /**
  100830. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  100831. * It is usually zero but might be interesting to modify according to your setup.
  100832. */
  100833. sceneCenter: Vector3;
  100834. protected _opacityFresnel: boolean;
  100835. /**
  100836. * This helps specifying that the material is falling off to the sky box at grazing angle.
  100837. * This helps ensuring a nice transition when the camera goes under the ground.
  100838. */
  100839. opacityFresnel: boolean;
  100840. protected _reflectionFresnel: boolean;
  100841. /**
  100842. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  100843. * This helps adding a mirror texture on the ground.
  100844. */
  100845. reflectionFresnel: boolean;
  100846. protected _reflectionFalloffDistance: number;
  100847. /**
  100848. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  100849. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  100850. */
  100851. reflectionFalloffDistance: number;
  100852. protected _reflectionAmount: number;
  100853. /**
  100854. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  100855. */
  100856. reflectionAmount: number;
  100857. protected _reflectionReflectance0: number;
  100858. /**
  100859. * This specifies the weight of the reflection at grazing angle.
  100860. */
  100861. reflectionReflectance0: number;
  100862. protected _reflectionReflectance90: number;
  100863. /**
  100864. * This specifies the weight of the reflection at a perpendicular point of view.
  100865. */
  100866. reflectionReflectance90: number;
  100867. /**
  100868. * Sets the reflection reflectance fresnel values according to the default standard
  100869. * empirically know to work well :-)
  100870. */
  100871. reflectionStandardFresnelWeight: number;
  100872. protected _useRGBColor: boolean;
  100873. /**
  100874. * Helps to directly use the maps channels instead of their level.
  100875. */
  100876. useRGBColor: boolean;
  100877. protected _enableNoise: boolean;
  100878. /**
  100879. * This helps reducing the banding effect that could occur on the background.
  100880. */
  100881. enableNoise: boolean;
  100882. /**
  100883. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100884. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  100885. * Recommended to be keep at 1.0 except for special cases.
  100886. */
  100887. fovMultiplier: number;
  100888. private _fovMultiplier;
  100889. /**
  100890. * Enable the FOV adjustment feature controlled by fovMultiplier.
  100891. */
  100892. useEquirectangularFOV: boolean;
  100893. private _maxSimultaneousLights;
  100894. /**
  100895. * Number of Simultaneous lights allowed on the material.
  100896. */
  100897. maxSimultaneousLights: int;
  100898. /**
  100899. * Default configuration related to image processing available in the Background Material.
  100900. */
  100901. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100902. /**
  100903. * Keep track of the image processing observer to allow dispose and replace.
  100904. */
  100905. private _imageProcessingObserver;
  100906. /**
  100907. * Attaches a new image processing configuration to the PBR Material.
  100908. * @param configuration (if null the scene configuration will be use)
  100909. */
  100910. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100911. /**
  100912. * Gets the image processing configuration used either in this material.
  100913. */
  100914. /**
  100915. * Sets the Default image processing configuration used either in the this material.
  100916. *
  100917. * If sets to null, the scene one is in use.
  100918. */
  100919. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  100920. /**
  100921. * Gets wether the color curves effect is enabled.
  100922. */
  100923. /**
  100924. * Sets wether the color curves effect is enabled.
  100925. */
  100926. cameraColorCurvesEnabled: boolean;
  100927. /**
  100928. * Gets wether the color grading effect is enabled.
  100929. */
  100930. /**
  100931. * Gets wether the color grading effect is enabled.
  100932. */
  100933. cameraColorGradingEnabled: boolean;
  100934. /**
  100935. * Gets wether tonemapping is enabled or not.
  100936. */
  100937. /**
  100938. * Sets wether tonemapping is enabled or not
  100939. */
  100940. cameraToneMappingEnabled: boolean;
  100941. /**
  100942. * The camera exposure used on this material.
  100943. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100944. * This corresponds to a photographic exposure.
  100945. */
  100946. /**
  100947. * The camera exposure used on this material.
  100948. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100949. * This corresponds to a photographic exposure.
  100950. */
  100951. cameraExposure: float;
  100952. /**
  100953. * Gets The camera contrast used on this material.
  100954. */
  100955. /**
  100956. * Sets The camera contrast used on this material.
  100957. */
  100958. cameraContrast: float;
  100959. /**
  100960. * Gets the Color Grading 2D Lookup Texture.
  100961. */
  100962. /**
  100963. * Sets the Color Grading 2D Lookup Texture.
  100964. */
  100965. cameraColorGradingTexture: Nullable<BaseTexture>;
  100966. /**
  100967. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100968. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100969. * 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;
  100970. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100971. */
  100972. /**
  100973. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100974. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100975. * 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;
  100976. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100977. */
  100978. cameraColorCurves: Nullable<ColorCurves>;
  100979. /**
  100980. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  100981. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  100982. */
  100983. switchToBGR: boolean;
  100984. private _renderTargets;
  100985. private _reflectionControls;
  100986. private _white;
  100987. private _primaryShadowColor;
  100988. private _primaryHighlightColor;
  100989. /**
  100990. * Instantiates a Background Material in the given scene
  100991. * @param name The friendly name of the material
  100992. * @param scene The scene to add the material to
  100993. */
  100994. constructor(name: string, scene: Scene);
  100995. /**
  100996. * Gets a boolean indicating that current material needs to register RTT
  100997. */
  100998. readonly hasRenderTargetTextures: boolean;
  100999. /**
  101000. * The entire material has been created in order to prevent overdraw.
  101001. * @returns false
  101002. */
  101003. needAlphaTesting(): boolean;
  101004. /**
  101005. * The entire material has been created in order to prevent overdraw.
  101006. * @returns true if blending is enable
  101007. */
  101008. needAlphaBlending(): boolean;
  101009. /**
  101010. * Checks wether the material is ready to be rendered for a given mesh.
  101011. * @param mesh The mesh to render
  101012. * @param subMesh The submesh to check against
  101013. * @param useInstances Specify wether or not the material is used with instances
  101014. * @returns true if all the dependencies are ready (Textures, Effects...)
  101015. */
  101016. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101017. /**
  101018. * Compute the primary color according to the chosen perceptual color.
  101019. */
  101020. private _computePrimaryColorFromPerceptualColor;
  101021. /**
  101022. * Compute the highlights and shadow colors according to their chosen levels.
  101023. */
  101024. private _computePrimaryColors;
  101025. /**
  101026. * Build the uniform buffer used in the material.
  101027. */
  101028. buildUniformLayout(): void;
  101029. /**
  101030. * Unbind the material.
  101031. */
  101032. unbind(): void;
  101033. /**
  101034. * Bind only the world matrix to the material.
  101035. * @param world The world matrix to bind.
  101036. */
  101037. bindOnlyWorldMatrix(world: Matrix): void;
  101038. /**
  101039. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  101040. * @param world The world matrix to bind.
  101041. * @param subMesh The submesh to bind for.
  101042. */
  101043. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101044. /**
  101045. * Dispose the material.
  101046. * @param forceDisposeEffect Force disposal of the associated effect.
  101047. * @param forceDisposeTextures Force disposal of the associated textures.
  101048. */
  101049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101050. /**
  101051. * Clones the material.
  101052. * @param name The cloned name.
  101053. * @returns The cloned material.
  101054. */
  101055. clone(name: string): BackgroundMaterial;
  101056. /**
  101057. * Serializes the current material to its JSON representation.
  101058. * @returns The JSON representation.
  101059. */
  101060. serialize(): any;
  101061. /**
  101062. * Gets the class name of the material
  101063. * @returns "BackgroundMaterial"
  101064. */
  101065. getClassName(): string;
  101066. /**
  101067. * Parse a JSON input to create back a background material.
  101068. * @param source The JSON data to parse
  101069. * @param scene The scene to create the parsed material in
  101070. * @param rootUrl The root url of the assets the material depends upon
  101071. * @returns the instantiated BackgroundMaterial.
  101072. */
  101073. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  101074. }
  101075. }
  101076. declare module BABYLON {
  101077. /**
  101078. * Represents the different options available during the creation of
  101079. * a Environment helper.
  101080. *
  101081. * This can control the default ground, skybox and image processing setup of your scene.
  101082. */
  101083. export interface IEnvironmentHelperOptions {
  101084. /**
  101085. * Specifies wether or not to create a ground.
  101086. * True by default.
  101087. */
  101088. createGround: boolean;
  101089. /**
  101090. * Specifies the ground size.
  101091. * 15 by default.
  101092. */
  101093. groundSize: number;
  101094. /**
  101095. * The texture used on the ground for the main color.
  101096. * Comes from the BabylonJS CDN by default.
  101097. *
  101098. * Remarks: Can be either a texture or a url.
  101099. */
  101100. groundTexture: string | BaseTexture;
  101101. /**
  101102. * The color mixed in the ground texture by default.
  101103. * BabylonJS clearColor by default.
  101104. */
  101105. groundColor: Color3;
  101106. /**
  101107. * Specifies the ground opacity.
  101108. * 1 by default.
  101109. */
  101110. groundOpacity: number;
  101111. /**
  101112. * Enables the ground to receive shadows.
  101113. * True by default.
  101114. */
  101115. enableGroundShadow: boolean;
  101116. /**
  101117. * Helps preventing the shadow to be fully black on the ground.
  101118. * 0.5 by default.
  101119. */
  101120. groundShadowLevel: number;
  101121. /**
  101122. * Creates a mirror texture attach to the ground.
  101123. * false by default.
  101124. */
  101125. enableGroundMirror: boolean;
  101126. /**
  101127. * Specifies the ground mirror size ratio.
  101128. * 0.3 by default as the default kernel is 64.
  101129. */
  101130. groundMirrorSizeRatio: number;
  101131. /**
  101132. * Specifies the ground mirror blur kernel size.
  101133. * 64 by default.
  101134. */
  101135. groundMirrorBlurKernel: number;
  101136. /**
  101137. * Specifies the ground mirror visibility amount.
  101138. * 1 by default
  101139. */
  101140. groundMirrorAmount: number;
  101141. /**
  101142. * Specifies the ground mirror reflectance weight.
  101143. * This uses the standard weight of the background material to setup the fresnel effect
  101144. * of the mirror.
  101145. * 1 by default.
  101146. */
  101147. groundMirrorFresnelWeight: number;
  101148. /**
  101149. * Specifies the ground mirror Falloff distance.
  101150. * This can helps reducing the size of the reflection.
  101151. * 0 by Default.
  101152. */
  101153. groundMirrorFallOffDistance: number;
  101154. /**
  101155. * Specifies the ground mirror texture type.
  101156. * Unsigned Int by Default.
  101157. */
  101158. groundMirrorTextureType: number;
  101159. /**
  101160. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  101161. * the shown objects.
  101162. */
  101163. groundYBias: number;
  101164. /**
  101165. * Specifies wether or not to create a skybox.
  101166. * True by default.
  101167. */
  101168. createSkybox: boolean;
  101169. /**
  101170. * Specifies the skybox size.
  101171. * 20 by default.
  101172. */
  101173. skyboxSize: number;
  101174. /**
  101175. * The texture used on the skybox for the main color.
  101176. * Comes from the BabylonJS CDN by default.
  101177. *
  101178. * Remarks: Can be either a texture or a url.
  101179. */
  101180. skyboxTexture: string | BaseTexture;
  101181. /**
  101182. * The color mixed in the skybox texture by default.
  101183. * BabylonJS clearColor by default.
  101184. */
  101185. skyboxColor: Color3;
  101186. /**
  101187. * The background rotation around the Y axis of the scene.
  101188. * This helps aligning the key lights of your scene with the background.
  101189. * 0 by default.
  101190. */
  101191. backgroundYRotation: number;
  101192. /**
  101193. * Compute automatically the size of the elements to best fit with the scene.
  101194. */
  101195. sizeAuto: boolean;
  101196. /**
  101197. * Default position of the rootMesh if autoSize is not true.
  101198. */
  101199. rootPosition: Vector3;
  101200. /**
  101201. * Sets up the image processing in the scene.
  101202. * true by default.
  101203. */
  101204. setupImageProcessing: boolean;
  101205. /**
  101206. * The texture used as your environment texture in the scene.
  101207. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  101208. *
  101209. * Remarks: Can be either a texture or a url.
  101210. */
  101211. environmentTexture: string | BaseTexture;
  101212. /**
  101213. * The value of the exposure to apply to the scene.
  101214. * 0.6 by default if setupImageProcessing is true.
  101215. */
  101216. cameraExposure: number;
  101217. /**
  101218. * The value of the contrast to apply to the scene.
  101219. * 1.6 by default if setupImageProcessing is true.
  101220. */
  101221. cameraContrast: number;
  101222. /**
  101223. * Specifies wether or not tonemapping should be enabled in the scene.
  101224. * true by default if setupImageProcessing is true.
  101225. */
  101226. toneMappingEnabled: boolean;
  101227. }
  101228. /**
  101229. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  101230. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  101231. * It also helps with the default setup of your imageProcessing configuration.
  101232. */
  101233. export class EnvironmentHelper {
  101234. /**
  101235. * Default ground texture URL.
  101236. */
  101237. private static _groundTextureCDNUrl;
  101238. /**
  101239. * Default skybox texture URL.
  101240. */
  101241. private static _skyboxTextureCDNUrl;
  101242. /**
  101243. * Default environment texture URL.
  101244. */
  101245. private static _environmentTextureCDNUrl;
  101246. /**
  101247. * Creates the default options for the helper.
  101248. */
  101249. private static _getDefaultOptions;
  101250. private _rootMesh;
  101251. /**
  101252. * Gets the root mesh created by the helper.
  101253. */
  101254. readonly rootMesh: Mesh;
  101255. private _skybox;
  101256. /**
  101257. * Gets the skybox created by the helper.
  101258. */
  101259. readonly skybox: Nullable<Mesh>;
  101260. private _skyboxTexture;
  101261. /**
  101262. * Gets the skybox texture created by the helper.
  101263. */
  101264. readonly skyboxTexture: Nullable<BaseTexture>;
  101265. private _skyboxMaterial;
  101266. /**
  101267. * Gets the skybox material created by the helper.
  101268. */
  101269. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  101270. private _ground;
  101271. /**
  101272. * Gets the ground mesh created by the helper.
  101273. */
  101274. readonly ground: Nullable<Mesh>;
  101275. private _groundTexture;
  101276. /**
  101277. * Gets the ground texture created by the helper.
  101278. */
  101279. readonly groundTexture: Nullable<BaseTexture>;
  101280. private _groundMirror;
  101281. /**
  101282. * Gets the ground mirror created by the helper.
  101283. */
  101284. readonly groundMirror: Nullable<MirrorTexture>;
  101285. /**
  101286. * Gets the ground mirror render list to helps pushing the meshes
  101287. * you wish in the ground reflection.
  101288. */
  101289. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  101290. private _groundMaterial;
  101291. /**
  101292. * Gets the ground material created by the helper.
  101293. */
  101294. readonly groundMaterial: Nullable<BackgroundMaterial>;
  101295. /**
  101296. * Stores the creation options.
  101297. */
  101298. private readonly _scene;
  101299. private _options;
  101300. /**
  101301. * This observable will be notified with any error during the creation of the environment,
  101302. * mainly texture creation errors.
  101303. */
  101304. onErrorObservable: Observable<{
  101305. message?: string;
  101306. exception?: any;
  101307. }>;
  101308. /**
  101309. * constructor
  101310. * @param options Defines the options we want to customize the helper
  101311. * @param scene The scene to add the material to
  101312. */
  101313. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  101314. /**
  101315. * Updates the background according to the new options
  101316. * @param options
  101317. */
  101318. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  101319. /**
  101320. * Sets the primary color of all the available elements.
  101321. * @param color the main color to affect to the ground and the background
  101322. */
  101323. setMainColor(color: Color3): void;
  101324. /**
  101325. * Setup the image processing according to the specified options.
  101326. */
  101327. private _setupImageProcessing;
  101328. /**
  101329. * Setup the environment texture according to the specified options.
  101330. */
  101331. private _setupEnvironmentTexture;
  101332. /**
  101333. * Setup the background according to the specified options.
  101334. */
  101335. private _setupBackground;
  101336. /**
  101337. * Get the scene sizes according to the setup.
  101338. */
  101339. private _getSceneSize;
  101340. /**
  101341. * Setup the ground according to the specified options.
  101342. */
  101343. private _setupGround;
  101344. /**
  101345. * Setup the ground material according to the specified options.
  101346. */
  101347. private _setupGroundMaterial;
  101348. /**
  101349. * Setup the ground diffuse texture according to the specified options.
  101350. */
  101351. private _setupGroundDiffuseTexture;
  101352. /**
  101353. * Setup the ground mirror texture according to the specified options.
  101354. */
  101355. private _setupGroundMirrorTexture;
  101356. /**
  101357. * Setup the ground to receive the mirror texture.
  101358. */
  101359. private _setupMirrorInGroundMaterial;
  101360. /**
  101361. * Setup the skybox according to the specified options.
  101362. */
  101363. private _setupSkybox;
  101364. /**
  101365. * Setup the skybox material according to the specified options.
  101366. */
  101367. private _setupSkyboxMaterial;
  101368. /**
  101369. * Setup the skybox reflection texture according to the specified options.
  101370. */
  101371. private _setupSkyboxReflectionTexture;
  101372. private _errorHandler;
  101373. /**
  101374. * Dispose all the elements created by the Helper.
  101375. */
  101376. dispose(): void;
  101377. }
  101378. }
  101379. declare module BABYLON {
  101380. /**
  101381. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  101382. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  101383. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  101384. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101385. */
  101386. export class PhotoDome extends TransformNode {
  101387. private _useDirectMapping;
  101388. /**
  101389. * The texture being displayed on the sphere
  101390. */
  101391. protected _photoTexture: Texture;
  101392. /**
  101393. * Gets or sets the texture being displayed on the sphere
  101394. */
  101395. photoTexture: Texture;
  101396. /**
  101397. * Observable raised when an error occured while loading the 360 image
  101398. */
  101399. onLoadErrorObservable: Observable<string>;
  101400. /**
  101401. * The skybox material
  101402. */
  101403. protected _material: BackgroundMaterial;
  101404. /**
  101405. * The surface used for the skybox
  101406. */
  101407. protected _mesh: Mesh;
  101408. /**
  101409. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101410. * Also see the options.resolution property.
  101411. */
  101412. fovMultiplier: number;
  101413. /**
  101414. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  101415. * @param name Element's name, child elements will append suffixes for their own names.
  101416. * @param urlsOfPhoto defines the url of the photo to display
  101417. * @param options defines an object containing optional or exposed sub element properties
  101418. * @param onError defines a callback called when an error occured while loading the texture
  101419. */
  101420. constructor(name: string, urlOfPhoto: string, options: {
  101421. resolution?: number;
  101422. size?: number;
  101423. useDirectMapping?: boolean;
  101424. faceForward?: boolean;
  101425. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  101426. /**
  101427. * Releases resources associated with this node.
  101428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101430. */
  101431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101432. }
  101433. }
  101434. declare module BABYLON {
  101435. /**
  101436. * Class used to host texture specific utilities
  101437. */
  101438. export class TextureTools {
  101439. /**
  101440. * Uses the GPU to create a copy texture rescaled at a given size
  101441. * @param texture Texture to copy from
  101442. * @param width defines the desired width
  101443. * @param height defines the desired height
  101444. * @param useBilinearMode defines if bilinear mode has to be used
  101445. * @return the generated texture
  101446. */
  101447. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  101448. /**
  101449. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  101450. * @param scene defines the hosting scene
  101451. * @returns the environment BRDF texture
  101452. */
  101453. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  101454. private static _environmentBRDFBase64Texture;
  101455. }
  101456. }
  101457. declare module BABYLON {
  101458. /**
  101459. * @hidden
  101460. */
  101461. export interface IMaterialClearCoatDefines {
  101462. CLEARCOAT: boolean;
  101463. CLEARCOAT_DEFAULTIOR: boolean;
  101464. CLEARCOAT_TEXTURE: boolean;
  101465. CLEARCOAT_TEXTUREDIRECTUV: number;
  101466. CLEARCOAT_BUMP: boolean;
  101467. CLEARCOAT_BUMPDIRECTUV: number;
  101468. CLEARCOAT_TINT: boolean;
  101469. CLEARCOAT_TINT_TEXTURE: boolean;
  101470. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  101471. /** @hidden */
  101472. _areTexturesDirty: boolean;
  101473. }
  101474. /**
  101475. * Define the code related to the clear coat parameters of the pbr material.
  101476. */
  101477. export class PBRClearCoatConfiguration {
  101478. /**
  101479. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101480. * The default fits with a polyurethane material.
  101481. */
  101482. private static readonly _DefaultIndiceOfRefraction;
  101483. private _isEnabled;
  101484. /**
  101485. * Defines if the clear coat is enabled in the material.
  101486. */
  101487. isEnabled: boolean;
  101488. /**
  101489. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  101490. */
  101491. intensity: number;
  101492. /**
  101493. * Defines the clear coat layer roughness.
  101494. */
  101495. roughness: number;
  101496. private _indiceOfRefraction;
  101497. /**
  101498. * Defines the indice of refraction of the clear coat.
  101499. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101500. * The default fits with a polyurethane material.
  101501. * Changing the default value is more performance intensive.
  101502. */
  101503. indiceOfRefraction: number;
  101504. private _texture;
  101505. /**
  101506. * Stores the clear coat values in a texture.
  101507. */
  101508. texture: Nullable<BaseTexture>;
  101509. private _bumpTexture;
  101510. /**
  101511. * Define the clear coat specific bump texture.
  101512. */
  101513. bumpTexture: Nullable<BaseTexture>;
  101514. private _isTintEnabled;
  101515. /**
  101516. * Defines if the clear coat tint is enabled in the material.
  101517. */
  101518. isTintEnabled: boolean;
  101519. /**
  101520. * Defines if the clear coat tint is enabled in the material.
  101521. * This is only use if tint is enabled
  101522. */
  101523. tintColor: Color3;
  101524. /**
  101525. * Defines if the distance at which the tint color should be found in the
  101526. * clear coat media.
  101527. * This is only use if tint is enabled
  101528. */
  101529. tintColorAtDistance: number;
  101530. /**
  101531. * Defines the clear coat layer thickness.
  101532. * This is only use if tint is enabled
  101533. */
  101534. tintThickness: number;
  101535. private _tintTexture;
  101536. /**
  101537. * Stores the clear tint values in a texture.
  101538. * rgb is tint
  101539. * a is a thickness factor
  101540. */
  101541. tintTexture: Nullable<BaseTexture>;
  101542. /** @hidden */
  101543. private _internalMarkAllSubMeshesAsTexturesDirty;
  101544. /** @hidden */
  101545. _markAllSubMeshesAsTexturesDirty(): void;
  101546. /**
  101547. * Instantiate a new istance of clear coat configuration.
  101548. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101549. */
  101550. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101551. /**
  101552. * Specifies that the submesh is ready to be used.
  101553. * @param defines the list of "defines" to update.
  101554. * @param scene defines the scene the material belongs to.
  101555. * @param engine defines the engine the material belongs to.
  101556. * @param disableBumpMap defines wether the material disables bump or not.
  101557. * @returns - boolean indicating that the submesh is ready or not.
  101558. */
  101559. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101560. /**
  101561. * Checks to see if a texture is used in the material.
  101562. * @param defines the list of "defines" to update.
  101563. * @param scene defines the scene to the material belongs to.
  101564. */
  101565. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101566. /**
  101567. * Binds the material data.
  101568. * @param uniformBuffer defines the Uniform buffer to fill in.
  101569. * @param scene defines the scene the material belongs to.
  101570. * @param engine defines the engine the material belongs to.
  101571. * @param disableBumpMap defines wether the material disables bump or not.
  101572. * @param isFrozen defines wether the material is frozen or not.
  101573. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101574. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101575. */
  101576. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  101577. /**
  101578. * Checks to see if a texture is used in the material.
  101579. * @param texture - Base texture to use.
  101580. * @returns - Boolean specifying if a texture is used in the material.
  101581. */
  101582. hasTexture(texture: BaseTexture): boolean;
  101583. /**
  101584. * Returns an array of the actively used textures.
  101585. * @param activeTextures Array of BaseTextures
  101586. */
  101587. getActiveTextures(activeTextures: BaseTexture[]): void;
  101588. /**
  101589. * Returns the animatable textures.
  101590. * @param animatables Array of animatable textures.
  101591. */
  101592. getAnimatables(animatables: IAnimatable[]): void;
  101593. /**
  101594. * Disposes the resources of the material.
  101595. * @param forceDisposeTextures - Forces the disposal of all textures.
  101596. */
  101597. dispose(forceDisposeTextures?: boolean): void;
  101598. /**
  101599. * Get the current class name of the texture useful for serialization or dynamic coding.
  101600. * @returns "PBRClearCoatConfiguration"
  101601. */
  101602. getClassName(): string;
  101603. /**
  101604. * Add fallbacks to the effect fallbacks list.
  101605. * @param defines defines the Base texture to use.
  101606. * @param fallbacks defines the current fallback list.
  101607. * @param currentRank defines the current fallback rank.
  101608. * @returns the new fallback rank.
  101609. */
  101610. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101611. /**
  101612. * Add the required uniforms to the current list.
  101613. * @param uniforms defines the current uniform list.
  101614. */
  101615. static AddUniforms(uniforms: string[]): void;
  101616. /**
  101617. * Add the required samplers to the current list.
  101618. * @param samplers defines the current sampler list.
  101619. */
  101620. static AddSamplers(samplers: string[]): void;
  101621. /**
  101622. * Add the required uniforms to the current buffer.
  101623. * @param uniformBuffer defines the current uniform buffer.
  101624. */
  101625. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101626. /**
  101627. * Makes a duplicate of the current configuration into another one.
  101628. * @param clearCoatConfiguration define the config where to copy the info
  101629. */
  101630. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101631. /**
  101632. * Serializes this clear coat configuration.
  101633. * @returns - An object with the serialized config.
  101634. */
  101635. serialize(): any;
  101636. /**
  101637. * Parses a Clear Coat Configuration from a serialized object.
  101638. * @param source - Serialized object.
  101639. */
  101640. parse(source: any): void;
  101641. }
  101642. }
  101643. declare module BABYLON {
  101644. /**
  101645. * @hidden
  101646. */
  101647. export interface IMaterialAnisotropicDefines {
  101648. ANISOTROPIC: boolean;
  101649. ANISOTROPIC_TEXTURE: boolean;
  101650. ANISOTROPIC_TEXTUREDIRECTUV: number;
  101651. MAINUV1: boolean;
  101652. _areTexturesDirty: boolean;
  101653. _needUVs: boolean;
  101654. }
  101655. /**
  101656. * Define the code related to the anisotropic parameters of the pbr material.
  101657. */
  101658. export class PBRAnisotropicConfiguration {
  101659. private _isEnabled;
  101660. /**
  101661. * Defines if the anisotropy is enabled in the material.
  101662. */
  101663. isEnabled: boolean;
  101664. /**
  101665. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  101666. */
  101667. intensity: number;
  101668. /**
  101669. * Defines if the effect is along the tangents, bitangents or in between.
  101670. * By default, the effect is "strectching" the highlights along the tangents.
  101671. */
  101672. direction: Vector2;
  101673. private _texture;
  101674. /**
  101675. * Stores the anisotropy values in a texture.
  101676. * rg is direction (like normal from -1 to 1)
  101677. * b is a intensity
  101678. */
  101679. texture: Nullable<BaseTexture>;
  101680. /** @hidden */
  101681. private _internalMarkAllSubMeshesAsTexturesDirty;
  101682. /** @hidden */
  101683. _markAllSubMeshesAsTexturesDirty(): void;
  101684. /**
  101685. * Instantiate a new istance of anisotropy configuration.
  101686. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101687. */
  101688. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101689. /**
  101690. * Specifies that the submesh is ready to be used.
  101691. * @param defines the list of "defines" to update.
  101692. * @param scene defines the scene the material belongs to.
  101693. * @returns - boolean indicating that the submesh is ready or not.
  101694. */
  101695. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101696. /**
  101697. * Checks to see if a texture is used in the material.
  101698. * @param defines the list of "defines" to update.
  101699. * @param mesh the mesh we are preparing the defines for.
  101700. * @param scene defines the scene the material belongs to.
  101701. */
  101702. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101703. /**
  101704. * Binds the material data.
  101705. * @param uniformBuffer defines the Uniform buffer to fill in.
  101706. * @param scene defines the scene the material belongs to.
  101707. * @param isFrozen defines wether the material is frozen or not.
  101708. */
  101709. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101710. /**
  101711. * Checks to see if a texture is used in the material.
  101712. * @param texture - Base texture to use.
  101713. * @returns - Boolean specifying if a texture is used in the material.
  101714. */
  101715. hasTexture(texture: BaseTexture): boolean;
  101716. /**
  101717. * Returns an array of the actively used textures.
  101718. * @param activeTextures Array of BaseTextures
  101719. */
  101720. getActiveTextures(activeTextures: BaseTexture[]): void;
  101721. /**
  101722. * Returns the animatable textures.
  101723. * @param animatables Array of animatable textures.
  101724. */
  101725. getAnimatables(animatables: IAnimatable[]): void;
  101726. /**
  101727. * Disposes the resources of the material.
  101728. * @param forceDisposeTextures - Forces the disposal of all textures.
  101729. */
  101730. dispose(forceDisposeTextures?: boolean): void;
  101731. /**
  101732. * Get the current class name of the texture useful for serialization or dynamic coding.
  101733. * @returns "PBRAnisotropicConfiguration"
  101734. */
  101735. getClassName(): string;
  101736. /**
  101737. * Add fallbacks to the effect fallbacks list.
  101738. * @param defines defines the Base texture to use.
  101739. * @param fallbacks defines the current fallback list.
  101740. * @param currentRank defines the current fallback rank.
  101741. * @returns the new fallback rank.
  101742. */
  101743. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101744. /**
  101745. * Add the required uniforms to the current list.
  101746. * @param uniforms defines the current uniform list.
  101747. */
  101748. static AddUniforms(uniforms: string[]): void;
  101749. /**
  101750. * Add the required uniforms to the current buffer.
  101751. * @param uniformBuffer defines the current uniform buffer.
  101752. */
  101753. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101754. /**
  101755. * Add the required samplers to the current list.
  101756. * @param samplers defines the current sampler list.
  101757. */
  101758. static AddSamplers(samplers: string[]): void;
  101759. /**
  101760. * Makes a duplicate of the current configuration into another one.
  101761. * @param anisotropicConfiguration define the config where to copy the info
  101762. */
  101763. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101764. /**
  101765. * Serializes this anisotropy configuration.
  101766. * @returns - An object with the serialized config.
  101767. */
  101768. serialize(): any;
  101769. /**
  101770. * Parses a anisotropy Configuration from a serialized object.
  101771. * @param source - Serialized object.
  101772. */
  101773. parse(source: any): void;
  101774. }
  101775. }
  101776. declare module BABYLON {
  101777. /**
  101778. * @hidden
  101779. */
  101780. export interface IMaterialBRDFDefines {
  101781. BRDF_V_HEIGHT_CORRELATED: boolean;
  101782. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101783. /** @hidden */
  101784. _areMiscDirty: boolean;
  101785. }
  101786. /**
  101787. * Define the code related to the BRDF parameters of the pbr material.
  101788. */
  101789. export class PBRBRDFConfiguration {
  101790. private _useEnergyConservation;
  101791. /**
  101792. * Defines if the material uses energy conservation.
  101793. */
  101794. useEnergyConservation: boolean;
  101795. private _useSmithVisibilityHeightCorrelated;
  101796. /**
  101797. * LEGACY Mode set to false
  101798. * Defines if the material uses height smith correlated visibility term.
  101799. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101800. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101801. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101802. * Not relying on height correlated will also disable energy conservation.
  101803. */
  101804. useSmithVisibilityHeightCorrelated: boolean;
  101805. /** @hidden */
  101806. private _internalMarkAllSubMeshesAsMiscDirty;
  101807. /** @hidden */
  101808. _markAllSubMeshesAsMiscDirty(): void;
  101809. /**
  101810. * Instantiate a new istance of clear coat configuration.
  101811. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101812. */
  101813. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101814. /**
  101815. * Checks to see if a texture is used in the material.
  101816. * @param defines the list of "defines" to update.
  101817. */
  101818. prepareDefines(defines: IMaterialBRDFDefines): void;
  101819. /**
  101820. * Get the current class name of the texture useful for serialization or dynamic coding.
  101821. * @returns "PBRClearCoatConfiguration"
  101822. */
  101823. getClassName(): string;
  101824. /**
  101825. * Makes a duplicate of the current configuration into another one.
  101826. * @param brdfConfiguration define the config where to copy the info
  101827. */
  101828. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101829. /**
  101830. * Serializes this BRDF configuration.
  101831. * @returns - An object with the serialized config.
  101832. */
  101833. serialize(): any;
  101834. /**
  101835. * Parses a BRDF Configuration from a serialized object.
  101836. * @param source - Serialized object.
  101837. */
  101838. parse(source: any): void;
  101839. }
  101840. }
  101841. declare module BABYLON {
  101842. /**
  101843. * @hidden
  101844. */
  101845. export interface IMaterialSheenDefines {
  101846. SHEEN: boolean;
  101847. SHEEN_TEXTURE: boolean;
  101848. SHEEN_TEXTUREDIRECTUV: number;
  101849. SHEEN_LINKWITHALBEDO: boolean;
  101850. /** @hidden */
  101851. _areTexturesDirty: boolean;
  101852. }
  101853. /**
  101854. * Define the code related to the Sheen parameters of the pbr material.
  101855. */
  101856. export class PBRSheenConfiguration {
  101857. private _isEnabled;
  101858. /**
  101859. * Defines if the material uses sheen.
  101860. */
  101861. isEnabled: boolean;
  101862. private _linkSheenWithAlbedo;
  101863. /**
  101864. * Defines if the sheen is linked to the sheen color.
  101865. */
  101866. linkSheenWithAlbedo: boolean;
  101867. /**
  101868. * Defines the sheen intensity.
  101869. */
  101870. intensity: number;
  101871. /**
  101872. * Defines the sheen color.
  101873. */
  101874. color: Color3;
  101875. private _texture;
  101876. /**
  101877. * Stores the sheen tint values in a texture.
  101878. * rgb is tint
  101879. * a is a intensity
  101880. */
  101881. texture: Nullable<BaseTexture>;
  101882. /** @hidden */
  101883. private _internalMarkAllSubMeshesAsTexturesDirty;
  101884. /** @hidden */
  101885. _markAllSubMeshesAsTexturesDirty(): void;
  101886. /**
  101887. * Instantiate a new istance of clear coat configuration.
  101888. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101889. */
  101890. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101891. /**
  101892. * Specifies that the submesh is ready to be used.
  101893. * @param defines the list of "defines" to update.
  101894. * @param scene defines the scene the material belongs to.
  101895. * @returns - boolean indicating that the submesh is ready or not.
  101896. */
  101897. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101898. /**
  101899. * Checks to see if a texture is used in the material.
  101900. * @param defines the list of "defines" to update.
  101901. * @param scene defines the scene the material belongs to.
  101902. */
  101903. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101904. /**
  101905. * Binds the material data.
  101906. * @param uniformBuffer defines the Uniform buffer to fill in.
  101907. * @param scene defines the scene the material belongs to.
  101908. * @param isFrozen defines wether the material is frozen or not.
  101909. */
  101910. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101911. /**
  101912. * Checks to see if a texture is used in the material.
  101913. * @param texture - Base texture to use.
  101914. * @returns - Boolean specifying if a texture is used in the material.
  101915. */
  101916. hasTexture(texture: BaseTexture): boolean;
  101917. /**
  101918. * Returns an array of the actively used textures.
  101919. * @param activeTextures Array of BaseTextures
  101920. */
  101921. getActiveTextures(activeTextures: BaseTexture[]): void;
  101922. /**
  101923. * Returns the animatable textures.
  101924. * @param animatables Array of animatable textures.
  101925. */
  101926. getAnimatables(animatables: IAnimatable[]): void;
  101927. /**
  101928. * Disposes the resources of the material.
  101929. * @param forceDisposeTextures - Forces the disposal of all textures.
  101930. */
  101931. dispose(forceDisposeTextures?: boolean): void;
  101932. /**
  101933. * Get the current class name of the texture useful for serialization or dynamic coding.
  101934. * @returns "PBRSheenConfiguration"
  101935. */
  101936. getClassName(): string;
  101937. /**
  101938. * Add fallbacks to the effect fallbacks list.
  101939. * @param defines defines the Base texture to use.
  101940. * @param fallbacks defines the current fallback list.
  101941. * @param currentRank defines the current fallback rank.
  101942. * @returns the new fallback rank.
  101943. */
  101944. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101945. /**
  101946. * Add the required uniforms to the current list.
  101947. * @param uniforms defines the current uniform list.
  101948. */
  101949. static AddUniforms(uniforms: string[]): void;
  101950. /**
  101951. * Add the required uniforms to the current buffer.
  101952. * @param uniformBuffer defines the current uniform buffer.
  101953. */
  101954. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101955. /**
  101956. * Add the required samplers to the current list.
  101957. * @param samplers defines the current sampler list.
  101958. */
  101959. static AddSamplers(samplers: string[]): void;
  101960. /**
  101961. * Makes a duplicate of the current configuration into another one.
  101962. * @param sheenConfiguration define the config where to copy the info
  101963. */
  101964. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101965. /**
  101966. * Serializes this BRDF configuration.
  101967. * @returns - An object with the serialized config.
  101968. */
  101969. serialize(): any;
  101970. /**
  101971. * Parses a Sheen Configuration from a serialized object.
  101972. * @param source - Serialized object.
  101973. */
  101974. parse(source: any): void;
  101975. }
  101976. }
  101977. declare module BABYLON {
  101978. /** @hidden */
  101979. export var pbrFragmentDeclaration: {
  101980. name: string;
  101981. shader: string;
  101982. };
  101983. }
  101984. declare module BABYLON {
  101985. /** @hidden */
  101986. export var pbrUboDeclaration: {
  101987. name: string;
  101988. shader: string;
  101989. };
  101990. }
  101991. declare module BABYLON {
  101992. /** @hidden */
  101993. export var pbrFunctions: {
  101994. name: string;
  101995. shader: string;
  101996. };
  101997. }
  101998. declare module BABYLON {
  101999. /** @hidden */
  102000. export var harmonicsFunctions: {
  102001. name: string;
  102002. shader: string;
  102003. };
  102004. }
  102005. declare module BABYLON {
  102006. /** @hidden */
  102007. export var pbrPreLightingFunctions: {
  102008. name: string;
  102009. shader: string;
  102010. };
  102011. }
  102012. declare module BABYLON {
  102013. /** @hidden */
  102014. export var pbrFalloffLightingFunctions: {
  102015. name: string;
  102016. shader: string;
  102017. };
  102018. }
  102019. declare module BABYLON {
  102020. /** @hidden */
  102021. export var pbrLightingFunctions: {
  102022. name: string;
  102023. shader: string;
  102024. };
  102025. }
  102026. declare module BABYLON {
  102027. /** @hidden */
  102028. export var pbrDebug: {
  102029. name: string;
  102030. shader: string;
  102031. };
  102032. }
  102033. declare module BABYLON {
  102034. /** @hidden */
  102035. export var pbrPixelShader: {
  102036. name: string;
  102037. shader: string;
  102038. };
  102039. }
  102040. declare module BABYLON {
  102041. /** @hidden */
  102042. export var pbrVertexDeclaration: {
  102043. name: string;
  102044. shader: string;
  102045. };
  102046. }
  102047. declare module BABYLON {
  102048. /** @hidden */
  102049. export var pbrVertexShader: {
  102050. name: string;
  102051. shader: string;
  102052. };
  102053. }
  102054. declare module BABYLON {
  102055. /**
  102056. * The Physically based material base class of BJS.
  102057. *
  102058. * This offers the main features of a standard PBR material.
  102059. * For more information, please refer to the documentation :
  102060. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102061. */
  102062. export abstract class PBRBaseMaterial extends PushMaterial {
  102063. /**
  102064. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102065. */
  102066. static readonly PBRMATERIAL_OPAQUE: number;
  102067. /**
  102068. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102069. */
  102070. static readonly PBRMATERIAL_ALPHATEST: number;
  102071. /**
  102072. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102073. */
  102074. static readonly PBRMATERIAL_ALPHABLEND: number;
  102075. /**
  102076. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102077. * They are also discarded below the alpha cutoff threshold to improve performances.
  102078. */
  102079. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102080. /**
  102081. * Defines the default value of how much AO map is occluding the analytical lights
  102082. * (point spot...).
  102083. */
  102084. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102085. /**
  102086. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102087. */
  102088. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102089. /**
  102090. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102091. * to enhance interoperability with other engines.
  102092. */
  102093. static readonly LIGHTFALLOFF_GLTF: number;
  102094. /**
  102095. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102096. * to enhance interoperability with other materials.
  102097. */
  102098. static readonly LIGHTFALLOFF_STANDARD: number;
  102099. /**
  102100. * Intensity of the direct lights e.g. the four lights available in your scene.
  102101. * This impacts both the direct diffuse and specular highlights.
  102102. */
  102103. protected _directIntensity: number;
  102104. /**
  102105. * Intensity of the emissive part of the material.
  102106. * This helps controlling the emissive effect without modifying the emissive color.
  102107. */
  102108. protected _emissiveIntensity: number;
  102109. /**
  102110. * Intensity of the environment e.g. how much the environment will light the object
  102111. * either through harmonics for rough material or through the refelction for shiny ones.
  102112. */
  102113. protected _environmentIntensity: number;
  102114. /**
  102115. * This is a special control allowing the reduction of the specular highlights coming from the
  102116. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102117. */
  102118. protected _specularIntensity: number;
  102119. /**
  102120. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102121. */
  102122. private _lightingInfos;
  102123. /**
  102124. * Debug Control allowing disabling the bump map on this material.
  102125. */
  102126. protected _disableBumpMap: boolean;
  102127. /**
  102128. * AKA Diffuse Texture in standard nomenclature.
  102129. */
  102130. protected _albedoTexture: BaseTexture;
  102131. /**
  102132. * AKA Occlusion Texture in other nomenclature.
  102133. */
  102134. protected _ambientTexture: BaseTexture;
  102135. /**
  102136. * AKA Occlusion Texture Intensity in other nomenclature.
  102137. */
  102138. protected _ambientTextureStrength: number;
  102139. /**
  102140. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102141. * 1 means it completely occludes it
  102142. * 0 mean it has no impact
  102143. */
  102144. protected _ambientTextureImpactOnAnalyticalLights: number;
  102145. /**
  102146. * Stores the alpha values in a texture.
  102147. */
  102148. protected _opacityTexture: BaseTexture;
  102149. /**
  102150. * Stores the reflection values in a texture.
  102151. */
  102152. protected _reflectionTexture: BaseTexture;
  102153. /**
  102154. * Stores the refraction values in a texture.
  102155. */
  102156. protected _refractionTexture: BaseTexture;
  102157. /**
  102158. * Stores the emissive values in a texture.
  102159. */
  102160. protected _emissiveTexture: BaseTexture;
  102161. /**
  102162. * AKA Specular texture in other nomenclature.
  102163. */
  102164. protected _reflectivityTexture: BaseTexture;
  102165. /**
  102166. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102167. */
  102168. protected _metallicTexture: BaseTexture;
  102169. /**
  102170. * Specifies the metallic scalar of the metallic/roughness workflow.
  102171. * Can also be used to scale the metalness values of the metallic texture.
  102172. */
  102173. protected _metallic: Nullable<number>;
  102174. /**
  102175. * Specifies the roughness scalar of the metallic/roughness workflow.
  102176. * Can also be used to scale the roughness values of the metallic texture.
  102177. */
  102178. protected _roughness: Nullable<number>;
  102179. /**
  102180. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102181. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102182. */
  102183. protected _microSurfaceTexture: BaseTexture;
  102184. /**
  102185. * Stores surface normal data used to displace a mesh in a texture.
  102186. */
  102187. protected _bumpTexture: BaseTexture;
  102188. /**
  102189. * Stores the pre-calculated light information of a mesh in a texture.
  102190. */
  102191. protected _lightmapTexture: BaseTexture;
  102192. /**
  102193. * The color of a material in ambient lighting.
  102194. */
  102195. protected _ambientColor: Color3;
  102196. /**
  102197. * AKA Diffuse Color in other nomenclature.
  102198. */
  102199. protected _albedoColor: Color3;
  102200. /**
  102201. * AKA Specular Color in other nomenclature.
  102202. */
  102203. protected _reflectivityColor: Color3;
  102204. /**
  102205. * The color applied when light is reflected from a material.
  102206. */
  102207. protected _reflectionColor: Color3;
  102208. /**
  102209. * The color applied when light is emitted from a material.
  102210. */
  102211. protected _emissiveColor: Color3;
  102212. /**
  102213. * AKA Glossiness in other nomenclature.
  102214. */
  102215. protected _microSurface: number;
  102216. /**
  102217. * source material index of refraction (IOR)' / 'destination material IOR.
  102218. */
  102219. protected _indexOfRefraction: number;
  102220. /**
  102221. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102222. */
  102223. protected _invertRefractionY: boolean;
  102224. /**
  102225. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102226. * Materials half opaque for instance using refraction could benefit from this control.
  102227. */
  102228. protected _linkRefractionWithTransparency: boolean;
  102229. /**
  102230. * Specifies that the material will use the light map as a show map.
  102231. */
  102232. protected _useLightmapAsShadowmap: boolean;
  102233. /**
  102234. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102235. * makes the reflect vector face the model (under horizon).
  102236. */
  102237. protected _useHorizonOcclusion: boolean;
  102238. /**
  102239. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102240. * too much the area relying on ambient texture to define their ambient occlusion.
  102241. */
  102242. protected _useRadianceOcclusion: boolean;
  102243. /**
  102244. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102245. */
  102246. protected _useAlphaFromAlbedoTexture: boolean;
  102247. /**
  102248. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102249. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102250. */
  102251. protected _useSpecularOverAlpha: boolean;
  102252. /**
  102253. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102254. */
  102255. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102256. /**
  102257. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102258. */
  102259. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102260. /**
  102261. * Specifies if the metallic texture contains the roughness information in its green channel.
  102262. */
  102263. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102264. /**
  102265. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102266. */
  102267. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102268. /**
  102269. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102270. */
  102271. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102272. /**
  102273. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102274. */
  102275. protected _useAmbientInGrayScale: boolean;
  102276. /**
  102277. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102278. * The material will try to infer what glossiness each pixel should be.
  102279. */
  102280. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102281. /**
  102282. * Defines the falloff type used in this material.
  102283. * It by default is Physical.
  102284. */
  102285. protected _lightFalloff: number;
  102286. /**
  102287. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102288. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102289. */
  102290. protected _useRadianceOverAlpha: boolean;
  102291. /**
  102292. * Allows using an object space normal map (instead of tangent space).
  102293. */
  102294. protected _useObjectSpaceNormalMap: boolean;
  102295. /**
  102296. * Allows using the bump map in parallax mode.
  102297. */
  102298. protected _useParallax: boolean;
  102299. /**
  102300. * Allows using the bump map in parallax occlusion mode.
  102301. */
  102302. protected _useParallaxOcclusion: boolean;
  102303. /**
  102304. * Controls the scale bias of the parallax mode.
  102305. */
  102306. protected _parallaxScaleBias: number;
  102307. /**
  102308. * If sets to true, disables all the lights affecting the material.
  102309. */
  102310. protected _disableLighting: boolean;
  102311. /**
  102312. * Number of Simultaneous lights allowed on the material.
  102313. */
  102314. protected _maxSimultaneousLights: number;
  102315. /**
  102316. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102317. */
  102318. protected _invertNormalMapX: boolean;
  102319. /**
  102320. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102321. */
  102322. protected _invertNormalMapY: boolean;
  102323. /**
  102324. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102325. */
  102326. protected _twoSidedLighting: boolean;
  102327. /**
  102328. * Defines the alpha limits in alpha test mode.
  102329. */
  102330. protected _alphaCutOff: number;
  102331. /**
  102332. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102333. */
  102334. protected _forceAlphaTest: boolean;
  102335. /**
  102336. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102337. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102338. */
  102339. protected _useAlphaFresnel: boolean;
  102340. /**
  102341. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102342. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102343. */
  102344. protected _useLinearAlphaFresnel: boolean;
  102345. /**
  102346. * The transparency mode of the material.
  102347. */
  102348. protected _transparencyMode: Nullable<number>;
  102349. /**
  102350. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102351. * from cos thetav and roughness:
  102352. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102353. */
  102354. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102355. /**
  102356. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102357. */
  102358. protected _forceIrradianceInFragment: boolean;
  102359. /**
  102360. * Force normal to face away from face.
  102361. */
  102362. protected _forceNormalForward: boolean;
  102363. /**
  102364. * Enables specular anti aliasing in the PBR shader.
  102365. * It will both interacts on the Geometry for analytical and IBL lighting.
  102366. * It also prefilter the roughness map based on the bump values.
  102367. */
  102368. protected _enableSpecularAntiAliasing: boolean;
  102369. /**
  102370. * Default configuration related to image processing available in the PBR Material.
  102371. */
  102372. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102373. /**
  102374. * Keep track of the image processing observer to allow dispose and replace.
  102375. */
  102376. private _imageProcessingObserver;
  102377. /**
  102378. * Attaches a new image processing configuration to the PBR Material.
  102379. * @param configuration
  102380. */
  102381. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102382. /**
  102383. * Stores the available render targets.
  102384. */
  102385. private _renderTargets;
  102386. /**
  102387. * Sets the global ambient color for the material used in lighting calculations.
  102388. */
  102389. private _globalAmbientColor;
  102390. /**
  102391. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102392. */
  102393. private _useLogarithmicDepth;
  102394. /**
  102395. * If set to true, no lighting calculations will be applied.
  102396. */
  102397. private _unlit;
  102398. private _debugMode;
  102399. /**
  102400. * @hidden
  102401. * This is reserved for the inspector.
  102402. * Defines the material debug mode.
  102403. * It helps seeing only some components of the material while troubleshooting.
  102404. */
  102405. debugMode: number;
  102406. /**
  102407. * @hidden
  102408. * This is reserved for the inspector.
  102409. * Specify from where on screen the debug mode should start.
  102410. * The value goes from -1 (full screen) to 1 (not visible)
  102411. * It helps with side by side comparison against the final render
  102412. * This defaults to -1
  102413. */
  102414. private debugLimit;
  102415. /**
  102416. * @hidden
  102417. * This is reserved for the inspector.
  102418. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102419. * You can use the factor to better multiply the final value.
  102420. */
  102421. private debugFactor;
  102422. /**
  102423. * Defines the clear coat layer parameters for the material.
  102424. */
  102425. readonly clearCoat: PBRClearCoatConfiguration;
  102426. /**
  102427. * Defines the anisotropic parameters for the material.
  102428. */
  102429. readonly anisotropy: PBRAnisotropicConfiguration;
  102430. /**
  102431. * Defines the BRDF parameters for the material.
  102432. */
  102433. readonly brdf: PBRBRDFConfiguration;
  102434. /**
  102435. * Defines the Sheen parameters for the material.
  102436. */
  102437. readonly sheen: PBRSheenConfiguration;
  102438. /**
  102439. * Instantiates a new PBRMaterial instance.
  102440. *
  102441. * @param name The material name
  102442. * @param scene The scene the material will be use in.
  102443. */
  102444. constructor(name: string, scene: Scene);
  102445. /**
  102446. * Gets a boolean indicating that current material needs to register RTT
  102447. */
  102448. readonly hasRenderTargetTextures: boolean;
  102449. /**
  102450. * Gets the name of the material class.
  102451. */
  102452. getClassName(): string;
  102453. /**
  102454. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102455. */
  102456. /**
  102457. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102458. */
  102459. useLogarithmicDepth: boolean;
  102460. /**
  102461. * Gets the current transparency mode.
  102462. */
  102463. /**
  102464. * Sets the transparency mode of the material.
  102465. *
  102466. * | Value | Type | Description |
  102467. * | ----- | ----------------------------------- | ----------- |
  102468. * | 0 | OPAQUE | |
  102469. * | 1 | ALPHATEST | |
  102470. * | 2 | ALPHABLEND | |
  102471. * | 3 | ALPHATESTANDBLEND | |
  102472. *
  102473. */
  102474. transparencyMode: Nullable<number>;
  102475. /**
  102476. * Returns true if alpha blending should be disabled.
  102477. */
  102478. private readonly _disableAlphaBlending;
  102479. /**
  102480. * Specifies whether or not this material should be rendered in alpha blend mode.
  102481. */
  102482. needAlphaBlending(): boolean;
  102483. /**
  102484. * Specifies if the mesh will require alpha blending.
  102485. * @param mesh - BJS mesh.
  102486. */
  102487. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102488. /**
  102489. * Specifies whether or not this material should be rendered in alpha test mode.
  102490. */
  102491. needAlphaTesting(): boolean;
  102492. /**
  102493. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102494. */
  102495. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102496. /**
  102497. * Gets the texture used for the alpha test.
  102498. */
  102499. getAlphaTestTexture(): BaseTexture;
  102500. /**
  102501. * Specifies that the submesh is ready to be used.
  102502. * @param mesh - BJS mesh.
  102503. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102504. * @param useInstances - Specifies that instances should be used.
  102505. * @returns - boolean indicating that the submesh is ready or not.
  102506. */
  102507. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102508. /**
  102509. * Specifies if the material uses metallic roughness workflow.
  102510. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102511. */
  102512. isMetallicWorkflow(): boolean;
  102513. private _prepareEffect;
  102514. private _prepareDefines;
  102515. /**
  102516. * Force shader compilation
  102517. */
  102518. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  102519. clipPlane: boolean;
  102520. }>): void;
  102521. /**
  102522. * Initializes the uniform buffer layout for the shader.
  102523. */
  102524. buildUniformLayout(): void;
  102525. /**
  102526. * Unbinds the textures.
  102527. */
  102528. unbind(): void;
  102529. /**
  102530. * Binds the submesh data.
  102531. * @param world - The world matrix.
  102532. * @param mesh - The BJS mesh.
  102533. * @param subMesh - A submesh of the BJS mesh.
  102534. */
  102535. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102536. /**
  102537. * Returns the animatable textures.
  102538. * @returns - Array of animatable textures.
  102539. */
  102540. getAnimatables(): IAnimatable[];
  102541. /**
  102542. * Returns the texture used for reflections.
  102543. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102544. */
  102545. private _getReflectionTexture;
  102546. /**
  102547. * Returns the texture used for refraction or null if none is used.
  102548. * @returns - Refection texture if present. If no refraction texture and refraction
  102549. * is linked with transparency, returns environment texture. Otherwise, returns null.
  102550. */
  102551. private _getRefractionTexture;
  102552. /**
  102553. * Returns an array of the actively used textures.
  102554. * @returns - Array of BaseTextures
  102555. */
  102556. getActiveTextures(): BaseTexture[];
  102557. /**
  102558. * Checks to see if a texture is used in the material.
  102559. * @param texture - Base texture to use.
  102560. * @returns - Boolean specifying if a texture is used in the material.
  102561. */
  102562. hasTexture(texture: BaseTexture): boolean;
  102563. /**
  102564. * Disposes the resources of the material.
  102565. * @param forceDisposeEffect - Forces the disposal of effects.
  102566. * @param forceDisposeTextures - Forces the disposal of all textures.
  102567. */
  102568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102569. }
  102570. }
  102571. declare module BABYLON {
  102572. /**
  102573. * The Physically based material of BJS.
  102574. *
  102575. * This offers the main features of a standard PBR material.
  102576. * For more information, please refer to the documentation :
  102577. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102578. */
  102579. export class PBRMaterial extends PBRBaseMaterial {
  102580. /**
  102581. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102582. */
  102583. static readonly PBRMATERIAL_OPAQUE: number;
  102584. /**
  102585. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102586. */
  102587. static readonly PBRMATERIAL_ALPHATEST: number;
  102588. /**
  102589. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102590. */
  102591. static readonly PBRMATERIAL_ALPHABLEND: number;
  102592. /**
  102593. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102594. * They are also discarded below the alpha cutoff threshold to improve performances.
  102595. */
  102596. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102597. /**
  102598. * Defines the default value of how much AO map is occluding the analytical lights
  102599. * (point spot...).
  102600. */
  102601. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102602. /**
  102603. * Intensity of the direct lights e.g. the four lights available in your scene.
  102604. * This impacts both the direct diffuse and specular highlights.
  102605. */
  102606. directIntensity: number;
  102607. /**
  102608. * Intensity of the emissive part of the material.
  102609. * This helps controlling the emissive effect without modifying the emissive color.
  102610. */
  102611. emissiveIntensity: number;
  102612. /**
  102613. * Intensity of the environment e.g. how much the environment will light the object
  102614. * either through harmonics for rough material or through the refelction for shiny ones.
  102615. */
  102616. environmentIntensity: number;
  102617. /**
  102618. * This is a special control allowing the reduction of the specular highlights coming from the
  102619. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102620. */
  102621. specularIntensity: number;
  102622. /**
  102623. * Debug Control allowing disabling the bump map on this material.
  102624. */
  102625. disableBumpMap: boolean;
  102626. /**
  102627. * AKA Diffuse Texture in standard nomenclature.
  102628. */
  102629. albedoTexture: BaseTexture;
  102630. /**
  102631. * AKA Occlusion Texture in other nomenclature.
  102632. */
  102633. ambientTexture: BaseTexture;
  102634. /**
  102635. * AKA Occlusion Texture Intensity in other nomenclature.
  102636. */
  102637. ambientTextureStrength: number;
  102638. /**
  102639. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102640. * 1 means it completely occludes it
  102641. * 0 mean it has no impact
  102642. */
  102643. ambientTextureImpactOnAnalyticalLights: number;
  102644. /**
  102645. * Stores the alpha values in a texture.
  102646. */
  102647. opacityTexture: BaseTexture;
  102648. /**
  102649. * Stores the reflection values in a texture.
  102650. */
  102651. reflectionTexture: Nullable<BaseTexture>;
  102652. /**
  102653. * Stores the emissive values in a texture.
  102654. */
  102655. emissiveTexture: BaseTexture;
  102656. /**
  102657. * AKA Specular texture in other nomenclature.
  102658. */
  102659. reflectivityTexture: BaseTexture;
  102660. /**
  102661. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102662. */
  102663. metallicTexture: BaseTexture;
  102664. /**
  102665. * Specifies the metallic scalar of the metallic/roughness workflow.
  102666. * Can also be used to scale the metalness values of the metallic texture.
  102667. */
  102668. metallic: Nullable<number>;
  102669. /**
  102670. * Specifies the roughness scalar of the metallic/roughness workflow.
  102671. * Can also be used to scale the roughness values of the metallic texture.
  102672. */
  102673. roughness: Nullable<number>;
  102674. /**
  102675. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102676. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102677. */
  102678. microSurfaceTexture: BaseTexture;
  102679. /**
  102680. * Stores surface normal data used to displace a mesh in a texture.
  102681. */
  102682. bumpTexture: BaseTexture;
  102683. /**
  102684. * Stores the pre-calculated light information of a mesh in a texture.
  102685. */
  102686. lightmapTexture: BaseTexture;
  102687. /**
  102688. * Stores the refracted light information in a texture.
  102689. */
  102690. refractionTexture: BaseTexture;
  102691. /**
  102692. * The color of a material in ambient lighting.
  102693. */
  102694. ambientColor: Color3;
  102695. /**
  102696. * AKA Diffuse Color in other nomenclature.
  102697. */
  102698. albedoColor: Color3;
  102699. /**
  102700. * AKA Specular Color in other nomenclature.
  102701. */
  102702. reflectivityColor: Color3;
  102703. /**
  102704. * The color reflected from the material.
  102705. */
  102706. reflectionColor: Color3;
  102707. /**
  102708. * The color emitted from the material.
  102709. */
  102710. emissiveColor: Color3;
  102711. /**
  102712. * AKA Glossiness in other nomenclature.
  102713. */
  102714. microSurface: number;
  102715. /**
  102716. * source material index of refraction (IOR)' / 'destination material IOR.
  102717. */
  102718. indexOfRefraction: number;
  102719. /**
  102720. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102721. */
  102722. invertRefractionY: boolean;
  102723. /**
  102724. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102725. * Materials half opaque for instance using refraction could benefit from this control.
  102726. */
  102727. linkRefractionWithTransparency: boolean;
  102728. /**
  102729. * If true, the light map contains occlusion information instead of lighting info.
  102730. */
  102731. useLightmapAsShadowmap: boolean;
  102732. /**
  102733. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102734. */
  102735. useAlphaFromAlbedoTexture: boolean;
  102736. /**
  102737. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102738. */
  102739. forceAlphaTest: boolean;
  102740. /**
  102741. * Defines the alpha limits in alpha test mode.
  102742. */
  102743. alphaCutOff: number;
  102744. /**
  102745. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102746. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102747. */
  102748. useSpecularOverAlpha: boolean;
  102749. /**
  102750. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102751. */
  102752. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102753. /**
  102754. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102755. */
  102756. useRoughnessFromMetallicTextureAlpha: boolean;
  102757. /**
  102758. * Specifies if the metallic texture contains the roughness information in its green channel.
  102759. */
  102760. useRoughnessFromMetallicTextureGreen: boolean;
  102761. /**
  102762. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102763. */
  102764. useMetallnessFromMetallicTextureBlue: boolean;
  102765. /**
  102766. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102767. */
  102768. useAmbientOcclusionFromMetallicTextureRed: boolean;
  102769. /**
  102770. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102771. */
  102772. useAmbientInGrayScale: boolean;
  102773. /**
  102774. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102775. * The material will try to infer what glossiness each pixel should be.
  102776. */
  102777. useAutoMicroSurfaceFromReflectivityMap: boolean;
  102778. /**
  102779. * BJS is using an harcoded light falloff based on a manually sets up range.
  102780. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102781. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102782. */
  102783. /**
  102784. * BJS is using an harcoded light falloff based on a manually sets up range.
  102785. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102786. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102787. */
  102788. usePhysicalLightFalloff: boolean;
  102789. /**
  102790. * In order to support the falloff compatibility with gltf, a special mode has been added
  102791. * to reproduce the gltf light falloff.
  102792. */
  102793. /**
  102794. * In order to support the falloff compatibility with gltf, a special mode has been added
  102795. * to reproduce the gltf light falloff.
  102796. */
  102797. useGLTFLightFalloff: boolean;
  102798. /**
  102799. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102800. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102801. */
  102802. useRadianceOverAlpha: boolean;
  102803. /**
  102804. * Allows using an object space normal map (instead of tangent space).
  102805. */
  102806. useObjectSpaceNormalMap: boolean;
  102807. /**
  102808. * Allows using the bump map in parallax mode.
  102809. */
  102810. useParallax: boolean;
  102811. /**
  102812. * Allows using the bump map in parallax occlusion mode.
  102813. */
  102814. useParallaxOcclusion: boolean;
  102815. /**
  102816. * Controls the scale bias of the parallax mode.
  102817. */
  102818. parallaxScaleBias: number;
  102819. /**
  102820. * If sets to true, disables all the lights affecting the material.
  102821. */
  102822. disableLighting: boolean;
  102823. /**
  102824. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102825. */
  102826. forceIrradianceInFragment: boolean;
  102827. /**
  102828. * Number of Simultaneous lights allowed on the material.
  102829. */
  102830. maxSimultaneousLights: number;
  102831. /**
  102832. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102833. */
  102834. invertNormalMapX: boolean;
  102835. /**
  102836. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102837. */
  102838. invertNormalMapY: boolean;
  102839. /**
  102840. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102841. */
  102842. twoSidedLighting: boolean;
  102843. /**
  102844. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102845. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102846. */
  102847. useAlphaFresnel: boolean;
  102848. /**
  102849. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102850. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102851. */
  102852. useLinearAlphaFresnel: boolean;
  102853. /**
  102854. * Let user defines the brdf lookup texture used for IBL.
  102855. * A default 8bit version is embedded but you could point at :
  102856. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  102857. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  102858. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  102859. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  102860. */
  102861. environmentBRDFTexture: Nullable<BaseTexture>;
  102862. /**
  102863. * Force normal to face away from face.
  102864. */
  102865. forceNormalForward: boolean;
  102866. /**
  102867. * Enables specular anti aliasing in the PBR shader.
  102868. * It will both interacts on the Geometry for analytical and IBL lighting.
  102869. * It also prefilter the roughness map based on the bump values.
  102870. */
  102871. enableSpecularAntiAliasing: boolean;
  102872. /**
  102873. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102874. * makes the reflect vector face the model (under horizon).
  102875. */
  102876. useHorizonOcclusion: boolean;
  102877. /**
  102878. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102879. * too much the area relying on ambient texture to define their ambient occlusion.
  102880. */
  102881. useRadianceOcclusion: boolean;
  102882. /**
  102883. * If set to true, no lighting calculations will be applied.
  102884. */
  102885. unlit: boolean;
  102886. /**
  102887. * Gets the image processing configuration used either in this material.
  102888. */
  102889. /**
  102890. * Sets the Default image processing configuration used either in the this material.
  102891. *
  102892. * If sets to null, the scene one is in use.
  102893. */
  102894. imageProcessingConfiguration: ImageProcessingConfiguration;
  102895. /**
  102896. * Gets wether the color curves effect is enabled.
  102897. */
  102898. /**
  102899. * Sets wether the color curves effect is enabled.
  102900. */
  102901. cameraColorCurvesEnabled: boolean;
  102902. /**
  102903. * Gets wether the color grading effect is enabled.
  102904. */
  102905. /**
  102906. * Gets wether the color grading effect is enabled.
  102907. */
  102908. cameraColorGradingEnabled: boolean;
  102909. /**
  102910. * Gets wether tonemapping is enabled or not.
  102911. */
  102912. /**
  102913. * Sets wether tonemapping is enabled or not
  102914. */
  102915. cameraToneMappingEnabled: boolean;
  102916. /**
  102917. * The camera exposure used on this material.
  102918. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102919. * This corresponds to a photographic exposure.
  102920. */
  102921. /**
  102922. * The camera exposure used on this material.
  102923. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102924. * This corresponds to a photographic exposure.
  102925. */
  102926. cameraExposure: number;
  102927. /**
  102928. * Gets The camera contrast used on this material.
  102929. */
  102930. /**
  102931. * Sets The camera contrast used on this material.
  102932. */
  102933. cameraContrast: number;
  102934. /**
  102935. * Gets the Color Grading 2D Lookup Texture.
  102936. */
  102937. /**
  102938. * Sets the Color Grading 2D Lookup Texture.
  102939. */
  102940. cameraColorGradingTexture: Nullable<BaseTexture>;
  102941. /**
  102942. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102943. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102944. * 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;
  102945. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102946. */
  102947. /**
  102948. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102949. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102950. * 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;
  102951. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102952. */
  102953. cameraColorCurves: Nullable<ColorCurves>;
  102954. /**
  102955. * Instantiates a new PBRMaterial instance.
  102956. *
  102957. * @param name The material name
  102958. * @param scene The scene the material will be use in.
  102959. */
  102960. constructor(name: string, scene: Scene);
  102961. /**
  102962. * Returns the name of this material class.
  102963. */
  102964. getClassName(): string;
  102965. /**
  102966. * Makes a duplicate of the current material.
  102967. * @param name - name to use for the new material.
  102968. */
  102969. clone(name: string): PBRMaterial;
  102970. /**
  102971. * Serializes this PBR Material.
  102972. * @returns - An object with the serialized material.
  102973. */
  102974. serialize(): any;
  102975. /**
  102976. * Parses a PBR Material from a serialized object.
  102977. * @param source - Serialized object.
  102978. * @param scene - BJS scene instance.
  102979. * @param rootUrl - url for the scene object
  102980. * @returns - PBRMaterial
  102981. */
  102982. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  102983. }
  102984. }
  102985. declare module BABYLON {
  102986. /**
  102987. * Direct draw surface info
  102988. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102989. */
  102990. export interface DDSInfo {
  102991. /**
  102992. * Width of the texture
  102993. */
  102994. width: number;
  102995. /**
  102996. * Width of the texture
  102997. */
  102998. height: number;
  102999. /**
  103000. * Number of Mipmaps for the texture
  103001. * @see https://en.wikipedia.org/wiki/Mipmap
  103002. */
  103003. mipmapCount: number;
  103004. /**
  103005. * If the textures format is a known fourCC format
  103006. * @see https://www.fourcc.org/
  103007. */
  103008. isFourCC: boolean;
  103009. /**
  103010. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103011. */
  103012. isRGB: boolean;
  103013. /**
  103014. * If the texture is a lumincance format
  103015. */
  103016. isLuminance: boolean;
  103017. /**
  103018. * If this is a cube texture
  103019. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103020. */
  103021. isCube: boolean;
  103022. /**
  103023. * If the texture is a compressed format eg. FOURCC_DXT1
  103024. */
  103025. isCompressed: boolean;
  103026. /**
  103027. * The dxgiFormat of the texture
  103028. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103029. */
  103030. dxgiFormat: number;
  103031. /**
  103032. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103033. */
  103034. textureType: number;
  103035. /**
  103036. * Sphericle polynomial created for the dds texture
  103037. */
  103038. sphericalPolynomial?: SphericalPolynomial;
  103039. }
  103040. /**
  103041. * Class used to provide DDS decompression tools
  103042. */
  103043. export class DDSTools {
  103044. /**
  103045. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103046. */
  103047. static StoreLODInAlphaChannel: boolean;
  103048. /**
  103049. * Gets DDS information from an array buffer
  103050. * @param arrayBuffer defines the array buffer to read data from
  103051. * @returns the DDS information
  103052. */
  103053. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103054. private static _FloatView;
  103055. private static _Int32View;
  103056. private static _ToHalfFloat;
  103057. private static _FromHalfFloat;
  103058. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103059. private static _GetHalfFloatRGBAArrayBuffer;
  103060. private static _GetFloatRGBAArrayBuffer;
  103061. private static _GetFloatAsUIntRGBAArrayBuffer;
  103062. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103063. private static _GetRGBAArrayBuffer;
  103064. private static _ExtractLongWordOrder;
  103065. private static _GetRGBArrayBuffer;
  103066. private static _GetLuminanceArrayBuffer;
  103067. /**
  103068. * Uploads DDS Levels to a Babylon Texture
  103069. * @hidden
  103070. */
  103071. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  103072. }
  103073. interface Engine {
  103074. /**
  103075. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  103076. * @param rootUrl defines the url where the file to load is located
  103077. * @param scene defines the current scene
  103078. * @param lodScale defines scale to apply to the mip map selection
  103079. * @param lodOffset defines offset to apply to the mip map selection
  103080. * @param onLoad defines an optional callback raised when the texture is loaded
  103081. * @param onError defines an optional callback raised if there is an issue to load the texture
  103082. * @param format defines the format of the data
  103083. * @param forcedExtension defines the extension to use to pick the right loader
  103084. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  103085. * @returns the cube texture as an InternalTexture
  103086. */
  103087. 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;
  103088. }
  103089. }
  103090. declare module BABYLON {
  103091. /**
  103092. * Implementation of the DDS Texture Loader.
  103093. * @hidden
  103094. */
  103095. export class _DDSTextureLoader implements IInternalTextureLoader {
  103096. /**
  103097. * Defines wether the loader supports cascade loading the different faces.
  103098. */
  103099. readonly supportCascades: boolean;
  103100. /**
  103101. * This returns if the loader support the current file information.
  103102. * @param extension defines the file extension of the file being loaded
  103103. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103104. * @param fallback defines the fallback internal texture if any
  103105. * @param isBase64 defines whether the texture is encoded as a base64
  103106. * @param isBuffer defines whether the texture data are stored as a buffer
  103107. * @returns true if the loader can load the specified file
  103108. */
  103109. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103110. /**
  103111. * Transform the url before loading if required.
  103112. * @param rootUrl the url of the texture
  103113. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103114. * @returns the transformed texture
  103115. */
  103116. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103117. /**
  103118. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103119. * @param rootUrl the url of the texture
  103120. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103121. * @returns the fallback texture
  103122. */
  103123. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103124. /**
  103125. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103126. * @param data contains the texture data
  103127. * @param texture defines the BabylonJS internal texture
  103128. * @param createPolynomials will be true if polynomials have been requested
  103129. * @param onLoad defines the callback to trigger once the texture is ready
  103130. * @param onError defines the callback to trigger in case of error
  103131. */
  103132. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103133. /**
  103134. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103135. * @param data contains the texture data
  103136. * @param texture defines the BabylonJS internal texture
  103137. * @param callback defines the method to call once ready to upload
  103138. */
  103139. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103140. }
  103141. }
  103142. declare module BABYLON {
  103143. /** @hidden */
  103144. export var rgbdEncodePixelShader: {
  103145. name: string;
  103146. shader: string;
  103147. };
  103148. }
  103149. declare module BABYLON {
  103150. /** @hidden */
  103151. export var rgbdDecodePixelShader: {
  103152. name: string;
  103153. shader: string;
  103154. };
  103155. }
  103156. declare module BABYLON {
  103157. /**
  103158. * Raw texture data and descriptor sufficient for WebGL texture upload
  103159. */
  103160. export interface EnvironmentTextureInfo {
  103161. /**
  103162. * Version of the environment map
  103163. */
  103164. version: number;
  103165. /**
  103166. * Width of image
  103167. */
  103168. width: number;
  103169. /**
  103170. * Irradiance information stored in the file.
  103171. */
  103172. irradiance: any;
  103173. /**
  103174. * Specular information stored in the file.
  103175. */
  103176. specular: any;
  103177. }
  103178. /**
  103179. * Sets of helpers addressing the serialization and deserialization of environment texture
  103180. * stored in a BabylonJS env file.
  103181. * Those files are usually stored as .env files.
  103182. */
  103183. export class EnvironmentTextureTools {
  103184. /**
  103185. * Magic number identifying the env file.
  103186. */
  103187. private static _MagicBytes;
  103188. /**
  103189. * Gets the environment info from an env file.
  103190. * @param data The array buffer containing the .env bytes.
  103191. * @returns the environment file info (the json header) if successfully parsed.
  103192. */
  103193. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103194. /**
  103195. * Creates an environment texture from a loaded cube texture.
  103196. * @param texture defines the cube texture to convert in env file
  103197. * @return a promise containing the environment data if succesfull.
  103198. */
  103199. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103200. /**
  103201. * Creates a JSON representation of the spherical data.
  103202. * @param texture defines the texture containing the polynomials
  103203. * @return the JSON representation of the spherical info
  103204. */
  103205. private static _CreateEnvTextureIrradiance;
  103206. /**
  103207. * Uploads the texture info contained in the env file to the GPU.
  103208. * @param texture defines the internal texture to upload to
  103209. * @param arrayBuffer defines the buffer cotaining the data to load
  103210. * @param info defines the texture info retrieved through the GetEnvInfo method
  103211. * @returns a promise
  103212. */
  103213. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103214. /**
  103215. * Uploads the levels of image data to the GPU.
  103216. * @param texture defines the internal texture to upload to
  103217. * @param imageData defines the array buffer views of image data [mipmap][face]
  103218. * @returns a promise
  103219. */
  103220. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103221. /**
  103222. * Uploads spherical polynomials information to the texture.
  103223. * @param texture defines the texture we are trying to upload the information to
  103224. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103225. */
  103226. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103227. /** @hidden */
  103228. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103229. }
  103230. }
  103231. declare module BABYLON {
  103232. /**
  103233. * Implementation of the ENV Texture Loader.
  103234. * @hidden
  103235. */
  103236. export class _ENVTextureLoader implements IInternalTextureLoader {
  103237. /**
  103238. * Defines wether the loader supports cascade loading the different faces.
  103239. */
  103240. readonly supportCascades: boolean;
  103241. /**
  103242. * This returns if the loader support the current file information.
  103243. * @param extension defines the file extension of the file being loaded
  103244. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103245. * @param fallback defines the fallback internal texture if any
  103246. * @param isBase64 defines whether the texture is encoded as a base64
  103247. * @param isBuffer defines whether the texture data are stored as a buffer
  103248. * @returns true if the loader can load the specified file
  103249. */
  103250. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103251. /**
  103252. * Transform the url before loading if required.
  103253. * @param rootUrl the url of the texture
  103254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103255. * @returns the transformed texture
  103256. */
  103257. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103258. /**
  103259. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103260. * @param rootUrl the url of the texture
  103261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103262. * @returns the fallback texture
  103263. */
  103264. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103265. /**
  103266. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103267. * @param data contains the texture data
  103268. * @param texture defines the BabylonJS internal texture
  103269. * @param createPolynomials will be true if polynomials have been requested
  103270. * @param onLoad defines the callback to trigger once the texture is ready
  103271. * @param onError defines the callback to trigger in case of error
  103272. */
  103273. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103274. /**
  103275. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103276. * @param data contains the texture data
  103277. * @param texture defines the BabylonJS internal texture
  103278. * @param callback defines the method to call once ready to upload
  103279. */
  103280. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103281. }
  103282. }
  103283. declare module BABYLON {
  103284. /**
  103285. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103286. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103287. */
  103288. export class KhronosTextureContainer {
  103289. /** contents of the KTX container file */
  103290. arrayBuffer: any;
  103291. private static HEADER_LEN;
  103292. private static COMPRESSED_2D;
  103293. private static COMPRESSED_3D;
  103294. private static TEX_2D;
  103295. private static TEX_3D;
  103296. /**
  103297. * Gets the openGL type
  103298. */
  103299. glType: number;
  103300. /**
  103301. * Gets the openGL type size
  103302. */
  103303. glTypeSize: number;
  103304. /**
  103305. * Gets the openGL format
  103306. */
  103307. glFormat: number;
  103308. /**
  103309. * Gets the openGL internal format
  103310. */
  103311. glInternalFormat: number;
  103312. /**
  103313. * Gets the base internal format
  103314. */
  103315. glBaseInternalFormat: number;
  103316. /**
  103317. * Gets image width in pixel
  103318. */
  103319. pixelWidth: number;
  103320. /**
  103321. * Gets image height in pixel
  103322. */
  103323. pixelHeight: number;
  103324. /**
  103325. * Gets image depth in pixels
  103326. */
  103327. pixelDepth: number;
  103328. /**
  103329. * Gets the number of array elements
  103330. */
  103331. numberOfArrayElements: number;
  103332. /**
  103333. * Gets the number of faces
  103334. */
  103335. numberOfFaces: number;
  103336. /**
  103337. * Gets the number of mipmap levels
  103338. */
  103339. numberOfMipmapLevels: number;
  103340. /**
  103341. * Gets the bytes of key value data
  103342. */
  103343. bytesOfKeyValueData: number;
  103344. /**
  103345. * Gets the load type
  103346. */
  103347. loadType: number;
  103348. /**
  103349. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103350. */
  103351. isInvalid: boolean;
  103352. /**
  103353. * Creates a new KhronosTextureContainer
  103354. * @param arrayBuffer contents of the KTX container file
  103355. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103356. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103357. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103358. */
  103359. constructor(
  103360. /** contents of the KTX container file */
  103361. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103362. /**
  103363. * Uploads KTX content to a Babylon Texture.
  103364. * It is assumed that the texture has already been created & is currently bound
  103365. * @hidden
  103366. */
  103367. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103368. private _upload2DCompressedLevels;
  103369. }
  103370. }
  103371. declare module BABYLON {
  103372. /**
  103373. * Implementation of the KTX Texture Loader.
  103374. * @hidden
  103375. */
  103376. export class _KTXTextureLoader implements IInternalTextureLoader {
  103377. /**
  103378. * Defines wether the loader supports cascade loading the different faces.
  103379. */
  103380. readonly supportCascades: boolean;
  103381. /**
  103382. * This returns if the loader support the current file information.
  103383. * @param extension defines the file extension of the file being loaded
  103384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103385. * @param fallback defines the fallback internal texture if any
  103386. * @param isBase64 defines whether the texture is encoded as a base64
  103387. * @param isBuffer defines whether the texture data are stored as a buffer
  103388. * @returns true if the loader can load the specified file
  103389. */
  103390. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103391. /**
  103392. * Transform the url before loading if required.
  103393. * @param rootUrl the url of the texture
  103394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103395. * @returns the transformed texture
  103396. */
  103397. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103398. /**
  103399. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103400. * @param rootUrl the url of the texture
  103401. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103402. * @returns the fallback texture
  103403. */
  103404. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103405. /**
  103406. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103407. * @param data contains the texture data
  103408. * @param texture defines the BabylonJS internal texture
  103409. * @param createPolynomials will be true if polynomials have been requested
  103410. * @param onLoad defines the callback to trigger once the texture is ready
  103411. * @param onError defines the callback to trigger in case of error
  103412. */
  103413. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103414. /**
  103415. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103416. * @param data contains the texture data
  103417. * @param texture defines the BabylonJS internal texture
  103418. * @param callback defines the method to call once ready to upload
  103419. */
  103420. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103421. }
  103422. }
  103423. declare module BABYLON {
  103424. /** @hidden */
  103425. export var _forceSceneHelpersToBundle: boolean;
  103426. interface Scene {
  103427. /**
  103428. * Creates a default light for the scene.
  103429. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  103430. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  103431. */
  103432. createDefaultLight(replace?: boolean): void;
  103433. /**
  103434. * Creates a default camera for the scene.
  103435. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  103436. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103437. * @param replace has default false, when true replaces the active camera in the scene
  103438. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  103439. */
  103440. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103441. /**
  103442. * Creates a default camera and a default light.
  103443. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  103444. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103445. * @param replace has the default false, when true replaces the active camera/light in the scene
  103446. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  103447. */
  103448. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103449. /**
  103450. * Creates a new sky box
  103451. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  103452. * @param environmentTexture defines the texture to use as environment texture
  103453. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  103454. * @param scale defines the overall scale of the skybox
  103455. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  103456. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  103457. * @returns a new mesh holding the sky box
  103458. */
  103459. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  103460. /**
  103461. * Creates a new environment
  103462. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  103463. * @param options defines the options you can use to configure the environment
  103464. * @returns the new EnvironmentHelper
  103465. */
  103466. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  103467. /**
  103468. * Creates a new VREXperienceHelper
  103469. * @see http://doc.babylonjs.com/how_to/webvr_helper
  103470. * @param webVROptions defines the options used to create the new VREXperienceHelper
  103471. * @returns a new VREXperienceHelper
  103472. */
  103473. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  103474. /**
  103475. * Creates a new XREXperienceHelper
  103476. * @see http://doc.babylonjs.com/how_to/webxr
  103477. * @returns a promise for a new XREXperienceHelper
  103478. */
  103479. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  103480. }
  103481. }
  103482. declare module BABYLON {
  103483. /**
  103484. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  103485. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  103486. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  103487. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103488. */
  103489. export class VideoDome extends TransformNode {
  103490. /**
  103491. * Define the video source as a Monoscopic panoramic 360 video.
  103492. */
  103493. static readonly MODE_MONOSCOPIC: number;
  103494. /**
  103495. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103496. */
  103497. static readonly MODE_TOPBOTTOM: number;
  103498. /**
  103499. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103500. */
  103501. static readonly MODE_SIDEBYSIDE: number;
  103502. private _useDirectMapping;
  103503. /**
  103504. * The video texture being displayed on the sphere
  103505. */
  103506. protected _videoTexture: VideoTexture;
  103507. /**
  103508. * Gets the video texture being displayed on the sphere
  103509. */
  103510. readonly videoTexture: VideoTexture;
  103511. /**
  103512. * The skybox material
  103513. */
  103514. protected _material: BackgroundMaterial;
  103515. /**
  103516. * The surface used for the skybox
  103517. */
  103518. protected _mesh: Mesh;
  103519. /**
  103520. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103521. * Also see the options.resolution property.
  103522. */
  103523. fovMultiplier: number;
  103524. private _videoMode;
  103525. /**
  103526. * Gets or set the current video mode for the video. It can be:
  103527. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  103528. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103529. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103530. */
  103531. videoMode: number;
  103532. /**
  103533. * Oberserver used in Stereoscopic VR Mode.
  103534. */
  103535. private _onBeforeCameraRenderObserver;
  103536. /**
  103537. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  103538. * @param name Element's name, child elements will append suffixes for their own names.
  103539. * @param urlsOrVideo defines the url(s) or the video element to use
  103540. * @param options An object containing optional or exposed sub element properties
  103541. */
  103542. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  103543. resolution?: number;
  103544. clickToPlay?: boolean;
  103545. autoPlay?: boolean;
  103546. loop?: boolean;
  103547. size?: number;
  103548. poster?: string;
  103549. faceForward?: boolean;
  103550. useDirectMapping?: boolean;
  103551. }, scene: Scene);
  103552. private _changeVideoMode;
  103553. /**
  103554. * Releases resources associated with this node.
  103555. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103556. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103557. */
  103558. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103559. }
  103560. }
  103561. declare module BABYLON {
  103562. /**
  103563. * This class can be used to get instrumentation data from a Babylon engine
  103564. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103565. */
  103566. export class EngineInstrumentation implements IDisposable {
  103567. /**
  103568. * Define the instrumented engine.
  103569. */
  103570. engine: Engine;
  103571. private _captureGPUFrameTime;
  103572. private _gpuFrameTimeToken;
  103573. private _gpuFrameTime;
  103574. private _captureShaderCompilationTime;
  103575. private _shaderCompilationTime;
  103576. private _onBeginFrameObserver;
  103577. private _onEndFrameObserver;
  103578. private _onBeforeShaderCompilationObserver;
  103579. private _onAfterShaderCompilationObserver;
  103580. /**
  103581. * Gets the perf counter used for GPU frame time
  103582. */
  103583. readonly gpuFrameTimeCounter: PerfCounter;
  103584. /**
  103585. * Gets the GPU frame time capture status
  103586. */
  103587. /**
  103588. * Enable or disable the GPU frame time capture
  103589. */
  103590. captureGPUFrameTime: boolean;
  103591. /**
  103592. * Gets the perf counter used for shader compilation time
  103593. */
  103594. readonly shaderCompilationTimeCounter: PerfCounter;
  103595. /**
  103596. * Gets the shader compilation time capture status
  103597. */
  103598. /**
  103599. * Enable or disable the shader compilation time capture
  103600. */
  103601. captureShaderCompilationTime: boolean;
  103602. /**
  103603. * Instantiates a new engine instrumentation.
  103604. * This class can be used to get instrumentation data from a Babylon engine
  103605. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103606. * @param engine Defines the engine to instrument
  103607. */
  103608. constructor(
  103609. /**
  103610. * Define the instrumented engine.
  103611. */
  103612. engine: Engine);
  103613. /**
  103614. * Dispose and release associated resources.
  103615. */
  103616. dispose(): void;
  103617. }
  103618. }
  103619. declare module BABYLON {
  103620. /**
  103621. * This class can be used to get instrumentation data from a Babylon engine
  103622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103623. */
  103624. export class SceneInstrumentation implements IDisposable {
  103625. /**
  103626. * Defines the scene to instrument
  103627. */
  103628. scene: Scene;
  103629. private _captureActiveMeshesEvaluationTime;
  103630. private _activeMeshesEvaluationTime;
  103631. private _captureRenderTargetsRenderTime;
  103632. private _renderTargetsRenderTime;
  103633. private _captureFrameTime;
  103634. private _frameTime;
  103635. private _captureRenderTime;
  103636. private _renderTime;
  103637. private _captureInterFrameTime;
  103638. private _interFrameTime;
  103639. private _captureParticlesRenderTime;
  103640. private _particlesRenderTime;
  103641. private _captureSpritesRenderTime;
  103642. private _spritesRenderTime;
  103643. private _capturePhysicsTime;
  103644. private _physicsTime;
  103645. private _captureAnimationsTime;
  103646. private _animationsTime;
  103647. private _captureCameraRenderTime;
  103648. private _cameraRenderTime;
  103649. private _onBeforeActiveMeshesEvaluationObserver;
  103650. private _onAfterActiveMeshesEvaluationObserver;
  103651. private _onBeforeRenderTargetsRenderObserver;
  103652. private _onAfterRenderTargetsRenderObserver;
  103653. private _onAfterRenderObserver;
  103654. private _onBeforeDrawPhaseObserver;
  103655. private _onAfterDrawPhaseObserver;
  103656. private _onBeforeAnimationsObserver;
  103657. private _onBeforeParticlesRenderingObserver;
  103658. private _onAfterParticlesRenderingObserver;
  103659. private _onBeforeSpritesRenderingObserver;
  103660. private _onAfterSpritesRenderingObserver;
  103661. private _onBeforePhysicsObserver;
  103662. private _onAfterPhysicsObserver;
  103663. private _onAfterAnimationsObserver;
  103664. private _onBeforeCameraRenderObserver;
  103665. private _onAfterCameraRenderObserver;
  103666. /**
  103667. * Gets the perf counter used for active meshes evaluation time
  103668. */
  103669. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  103670. /**
  103671. * Gets the active meshes evaluation time capture status
  103672. */
  103673. /**
  103674. * Enable or disable the active meshes evaluation time capture
  103675. */
  103676. captureActiveMeshesEvaluationTime: boolean;
  103677. /**
  103678. * Gets the perf counter used for render targets render time
  103679. */
  103680. readonly renderTargetsRenderTimeCounter: PerfCounter;
  103681. /**
  103682. * Gets the render targets render time capture status
  103683. */
  103684. /**
  103685. * Enable or disable the render targets render time capture
  103686. */
  103687. captureRenderTargetsRenderTime: boolean;
  103688. /**
  103689. * Gets the perf counter used for particles render time
  103690. */
  103691. readonly particlesRenderTimeCounter: PerfCounter;
  103692. /**
  103693. * Gets the particles render time capture status
  103694. */
  103695. /**
  103696. * Enable or disable the particles render time capture
  103697. */
  103698. captureParticlesRenderTime: boolean;
  103699. /**
  103700. * Gets the perf counter used for sprites render time
  103701. */
  103702. readonly spritesRenderTimeCounter: PerfCounter;
  103703. /**
  103704. * Gets the sprites render time capture status
  103705. */
  103706. /**
  103707. * Enable or disable the sprites render time capture
  103708. */
  103709. captureSpritesRenderTime: boolean;
  103710. /**
  103711. * Gets the perf counter used for physics time
  103712. */
  103713. readonly physicsTimeCounter: PerfCounter;
  103714. /**
  103715. * Gets the physics time capture status
  103716. */
  103717. /**
  103718. * Enable or disable the physics time capture
  103719. */
  103720. capturePhysicsTime: boolean;
  103721. /**
  103722. * Gets the perf counter used for animations time
  103723. */
  103724. readonly animationsTimeCounter: PerfCounter;
  103725. /**
  103726. * Gets the animations time capture status
  103727. */
  103728. /**
  103729. * Enable or disable the animations time capture
  103730. */
  103731. captureAnimationsTime: boolean;
  103732. /**
  103733. * Gets the perf counter used for frame time capture
  103734. */
  103735. readonly frameTimeCounter: PerfCounter;
  103736. /**
  103737. * Gets the frame time capture status
  103738. */
  103739. /**
  103740. * Enable or disable the frame time capture
  103741. */
  103742. captureFrameTime: boolean;
  103743. /**
  103744. * Gets the perf counter used for inter-frames time capture
  103745. */
  103746. readonly interFrameTimeCounter: PerfCounter;
  103747. /**
  103748. * Gets the inter-frames time capture status
  103749. */
  103750. /**
  103751. * Enable or disable the inter-frames time capture
  103752. */
  103753. captureInterFrameTime: boolean;
  103754. /**
  103755. * Gets the perf counter used for render time capture
  103756. */
  103757. readonly renderTimeCounter: PerfCounter;
  103758. /**
  103759. * Gets the render time capture status
  103760. */
  103761. /**
  103762. * Enable or disable the render time capture
  103763. */
  103764. captureRenderTime: boolean;
  103765. /**
  103766. * Gets the perf counter used for camera render time capture
  103767. */
  103768. readonly cameraRenderTimeCounter: PerfCounter;
  103769. /**
  103770. * Gets the camera render time capture status
  103771. */
  103772. /**
  103773. * Enable or disable the camera render time capture
  103774. */
  103775. captureCameraRenderTime: boolean;
  103776. /**
  103777. * Gets the perf counter used for draw calls
  103778. */
  103779. readonly drawCallsCounter: PerfCounter;
  103780. /**
  103781. * Gets the perf counter used for texture collisions
  103782. */
  103783. readonly textureCollisionsCounter: PerfCounter;
  103784. /**
  103785. * Instantiates a new scene instrumentation.
  103786. * This class can be used to get instrumentation data from a Babylon engine
  103787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103788. * @param scene Defines the scene to instrument
  103789. */
  103790. constructor(
  103791. /**
  103792. * Defines the scene to instrument
  103793. */
  103794. scene: Scene);
  103795. /**
  103796. * Dispose and release associated resources.
  103797. */
  103798. dispose(): void;
  103799. }
  103800. }
  103801. declare module BABYLON {
  103802. /** @hidden */
  103803. export var glowMapGenerationPixelShader: {
  103804. name: string;
  103805. shader: string;
  103806. };
  103807. }
  103808. declare module BABYLON {
  103809. /** @hidden */
  103810. export var glowMapGenerationVertexShader: {
  103811. name: string;
  103812. shader: string;
  103813. };
  103814. }
  103815. declare module BABYLON {
  103816. /**
  103817. * Effect layer options. This helps customizing the behaviour
  103818. * of the effect layer.
  103819. */
  103820. export interface IEffectLayerOptions {
  103821. /**
  103822. * Multiplication factor apply to the canvas size to compute the render target size
  103823. * used to generated the objects (the smaller the faster).
  103824. */
  103825. mainTextureRatio: number;
  103826. /**
  103827. * Enforces a fixed size texture to ensure effect stability across devices.
  103828. */
  103829. mainTextureFixedSize?: number;
  103830. /**
  103831. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  103832. */
  103833. alphaBlendingMode: number;
  103834. /**
  103835. * The camera attached to the layer.
  103836. */
  103837. camera: Nullable<Camera>;
  103838. /**
  103839. * The rendering group to draw the layer in.
  103840. */
  103841. renderingGroupId: number;
  103842. }
  103843. /**
  103844. * The effect layer Helps adding post process effect blended with the main pass.
  103845. *
  103846. * This can be for instance use to generate glow or higlight effects on the scene.
  103847. *
  103848. * The effect layer class can not be used directly and is intented to inherited from to be
  103849. * customized per effects.
  103850. */
  103851. export abstract class EffectLayer {
  103852. private _vertexBuffers;
  103853. private _indexBuffer;
  103854. private _cachedDefines;
  103855. private _effectLayerMapGenerationEffect;
  103856. private _effectLayerOptions;
  103857. private _mergeEffect;
  103858. protected _scene: Scene;
  103859. protected _engine: Engine;
  103860. protected _maxSize: number;
  103861. protected _mainTextureDesiredSize: ISize;
  103862. protected _mainTexture: RenderTargetTexture;
  103863. protected _shouldRender: boolean;
  103864. protected _postProcesses: PostProcess[];
  103865. protected _textures: BaseTexture[];
  103866. protected _emissiveTextureAndColor: {
  103867. texture: Nullable<BaseTexture>;
  103868. color: Color4;
  103869. };
  103870. /**
  103871. * The name of the layer
  103872. */
  103873. name: string;
  103874. /**
  103875. * The clear color of the texture used to generate the glow map.
  103876. */
  103877. neutralColor: Color4;
  103878. /**
  103879. * Specifies wether the highlight layer is enabled or not.
  103880. */
  103881. isEnabled: boolean;
  103882. /**
  103883. * Gets the camera attached to the layer.
  103884. */
  103885. readonly camera: Nullable<Camera>;
  103886. /**
  103887. * Gets the rendering group id the layer should render in.
  103888. */
  103889. readonly renderingGroupId: number;
  103890. /**
  103891. * An event triggered when the effect layer has been disposed.
  103892. */
  103893. onDisposeObservable: Observable<EffectLayer>;
  103894. /**
  103895. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  103896. */
  103897. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  103898. /**
  103899. * An event triggered when the generated texture is being merged in the scene.
  103900. */
  103901. onBeforeComposeObservable: Observable<EffectLayer>;
  103902. /**
  103903. * An event triggered when the generated texture has been merged in the scene.
  103904. */
  103905. onAfterComposeObservable: Observable<EffectLayer>;
  103906. /**
  103907. * An event triggered when the efffect layer changes its size.
  103908. */
  103909. onSizeChangedObservable: Observable<EffectLayer>;
  103910. /** @hidden */
  103911. static _SceneComponentInitialization: (scene: Scene) => void;
  103912. /**
  103913. * Instantiates a new effect Layer and references it in the scene.
  103914. * @param name The name of the layer
  103915. * @param scene The scene to use the layer in
  103916. */
  103917. constructor(
  103918. /** The Friendly of the effect in the scene */
  103919. name: string, scene: Scene);
  103920. /**
  103921. * Get the effect name of the layer.
  103922. * @return The effect name
  103923. */
  103924. abstract getEffectName(): string;
  103925. /**
  103926. * Checks for the readiness of the element composing the layer.
  103927. * @param subMesh the mesh to check for
  103928. * @param useInstances specify wether or not to use instances to render the mesh
  103929. * @return true if ready otherwise, false
  103930. */
  103931. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103932. /**
  103933. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103934. * @returns true if the effect requires stencil during the main canvas render pass.
  103935. */
  103936. abstract needStencil(): boolean;
  103937. /**
  103938. * Create the merge effect. This is the shader use to blit the information back
  103939. * to the main canvas at the end of the scene rendering.
  103940. * @returns The effect containing the shader used to merge the effect on the main canvas
  103941. */
  103942. protected abstract _createMergeEffect(): Effect;
  103943. /**
  103944. * Creates the render target textures and post processes used in the effect layer.
  103945. */
  103946. protected abstract _createTextureAndPostProcesses(): void;
  103947. /**
  103948. * Implementation specific of rendering the generating effect on the main canvas.
  103949. * @param effect The effect used to render through
  103950. */
  103951. protected abstract _internalRender(effect: Effect): void;
  103952. /**
  103953. * Sets the required values for both the emissive texture and and the main color.
  103954. */
  103955. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103956. /**
  103957. * Free any resources and references associated to a mesh.
  103958. * Internal use
  103959. * @param mesh The mesh to free.
  103960. */
  103961. abstract _disposeMesh(mesh: Mesh): void;
  103962. /**
  103963. * Serializes this layer (Glow or Highlight for example)
  103964. * @returns a serialized layer object
  103965. */
  103966. abstract serialize?(): any;
  103967. /**
  103968. * Initializes the effect layer with the required options.
  103969. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  103970. */
  103971. protected _init(options: Partial<IEffectLayerOptions>): void;
  103972. /**
  103973. * Generates the index buffer of the full screen quad blending to the main canvas.
  103974. */
  103975. private _generateIndexBuffer;
  103976. /**
  103977. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  103978. */
  103979. private _genrateVertexBuffer;
  103980. /**
  103981. * Sets the main texture desired size which is the closest power of two
  103982. * of the engine canvas size.
  103983. */
  103984. private _setMainTextureSize;
  103985. /**
  103986. * Creates the main texture for the effect layer.
  103987. */
  103988. protected _createMainTexture(): void;
  103989. /**
  103990. * Adds specific effects defines.
  103991. * @param defines The defines to add specifics to.
  103992. */
  103993. protected _addCustomEffectDefines(defines: string[]): void;
  103994. /**
  103995. * Checks for the readiness of the element composing the layer.
  103996. * @param subMesh the mesh to check for
  103997. * @param useInstances specify wether or not to use instances to render the mesh
  103998. * @param emissiveTexture the associated emissive texture used to generate the glow
  103999. * @return true if ready otherwise, false
  104000. */
  104001. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  104002. /**
  104003. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  104004. */
  104005. render(): void;
  104006. /**
  104007. * Determine if a given mesh will be used in the current effect.
  104008. * @param mesh mesh to test
  104009. * @returns true if the mesh will be used
  104010. */
  104011. hasMesh(mesh: AbstractMesh): boolean;
  104012. /**
  104013. * Returns true if the layer contains information to display, otherwise false.
  104014. * @returns true if the glow layer should be rendered
  104015. */
  104016. shouldRender(): boolean;
  104017. /**
  104018. * Returns true if the mesh should render, otherwise false.
  104019. * @param mesh The mesh to render
  104020. * @returns true if it should render otherwise false
  104021. */
  104022. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  104023. /**
  104024. * Returns true if the mesh can be rendered, otherwise false.
  104025. * @param mesh The mesh to render
  104026. * @param material The material used on the mesh
  104027. * @returns true if it can be rendered otherwise false
  104028. */
  104029. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104030. /**
  104031. * Returns true if the mesh should render, otherwise false.
  104032. * @param mesh The mesh to render
  104033. * @returns true if it should render otherwise false
  104034. */
  104035. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  104036. /**
  104037. * Renders the submesh passed in parameter to the generation map.
  104038. */
  104039. protected _renderSubMesh(subMesh: SubMesh): void;
  104040. /**
  104041. * Rebuild the required buffers.
  104042. * @hidden Internal use only.
  104043. */
  104044. _rebuild(): void;
  104045. /**
  104046. * Dispose only the render target textures and post process.
  104047. */
  104048. private _disposeTextureAndPostProcesses;
  104049. /**
  104050. * Dispose the highlight layer and free resources.
  104051. */
  104052. dispose(): void;
  104053. /**
  104054. * Gets the class name of the effect layer
  104055. * @returns the string with the class name of the effect layer
  104056. */
  104057. getClassName(): string;
  104058. /**
  104059. * Creates an effect layer from parsed effect layer data
  104060. * @param parsedEffectLayer defines effect layer data
  104061. * @param scene defines the current scene
  104062. * @param rootUrl defines the root URL containing the effect layer information
  104063. * @returns a parsed effect Layer
  104064. */
  104065. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  104066. }
  104067. }
  104068. declare module BABYLON {
  104069. interface AbstractScene {
  104070. /**
  104071. * The list of effect layers (highlights/glow) added to the scene
  104072. * @see http://doc.babylonjs.com/how_to/highlight_layer
  104073. * @see http://doc.babylonjs.com/how_to/glow_layer
  104074. */
  104075. effectLayers: Array<EffectLayer>;
  104076. /**
  104077. * Removes the given effect layer from this scene.
  104078. * @param toRemove defines the effect layer to remove
  104079. * @returns the index of the removed effect layer
  104080. */
  104081. removeEffectLayer(toRemove: EffectLayer): number;
  104082. /**
  104083. * Adds the given effect layer to this scene
  104084. * @param newEffectLayer defines the effect layer to add
  104085. */
  104086. addEffectLayer(newEffectLayer: EffectLayer): void;
  104087. }
  104088. /**
  104089. * Defines the layer scene component responsible to manage any effect layers
  104090. * in a given scene.
  104091. */
  104092. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  104093. /**
  104094. * The component name helpfull to identify the component in the list of scene components.
  104095. */
  104096. readonly name: string;
  104097. /**
  104098. * The scene the component belongs to.
  104099. */
  104100. scene: Scene;
  104101. private _engine;
  104102. private _renderEffects;
  104103. private _needStencil;
  104104. private _previousStencilState;
  104105. /**
  104106. * Creates a new instance of the component for the given scene
  104107. * @param scene Defines the scene to register the component in
  104108. */
  104109. constructor(scene: Scene);
  104110. /**
  104111. * Registers the component in a given scene
  104112. */
  104113. register(): void;
  104114. /**
  104115. * Rebuilds the elements related to this component in case of
  104116. * context lost for instance.
  104117. */
  104118. rebuild(): void;
  104119. /**
  104120. * Serializes the component data to the specified json object
  104121. * @param serializationObject The object to serialize to
  104122. */
  104123. serialize(serializationObject: any): void;
  104124. /**
  104125. * Adds all the element from the container to the scene
  104126. * @param container the container holding the elements
  104127. */
  104128. addFromContainer(container: AbstractScene): void;
  104129. /**
  104130. * Removes all the elements in the container from the scene
  104131. * @param container contains the elements to remove
  104132. */
  104133. removeFromContainer(container: AbstractScene): void;
  104134. /**
  104135. * Disposes the component and the associated ressources.
  104136. */
  104137. dispose(): void;
  104138. private _isReadyForMesh;
  104139. private _renderMainTexture;
  104140. private _setStencil;
  104141. private _setStencilBack;
  104142. private _draw;
  104143. private _drawCamera;
  104144. private _drawRenderingGroup;
  104145. }
  104146. }
  104147. declare module BABYLON {
  104148. /** @hidden */
  104149. export var glowMapMergePixelShader: {
  104150. name: string;
  104151. shader: string;
  104152. };
  104153. }
  104154. declare module BABYLON {
  104155. /** @hidden */
  104156. export var glowMapMergeVertexShader: {
  104157. name: string;
  104158. shader: string;
  104159. };
  104160. }
  104161. declare module BABYLON {
  104162. interface AbstractScene {
  104163. /**
  104164. * Return a the first highlight layer of the scene with a given name.
  104165. * @param name The name of the highlight layer to look for.
  104166. * @return The highlight layer if found otherwise null.
  104167. */
  104168. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  104169. }
  104170. /**
  104171. * Glow layer options. This helps customizing the behaviour
  104172. * of the glow layer.
  104173. */
  104174. export interface IGlowLayerOptions {
  104175. /**
  104176. * Multiplication factor apply to the canvas size to compute the render target size
  104177. * used to generated the glowing objects (the smaller the faster).
  104178. */
  104179. mainTextureRatio: number;
  104180. /**
  104181. * Enforces a fixed size texture to ensure resize independant blur.
  104182. */
  104183. mainTextureFixedSize?: number;
  104184. /**
  104185. * How big is the kernel of the blur texture.
  104186. */
  104187. blurKernelSize: number;
  104188. /**
  104189. * The camera attached to the layer.
  104190. */
  104191. camera: Nullable<Camera>;
  104192. /**
  104193. * Enable MSAA by chosing the number of samples.
  104194. */
  104195. mainTextureSamples?: number;
  104196. /**
  104197. * The rendering group to draw the layer in.
  104198. */
  104199. renderingGroupId: number;
  104200. }
  104201. /**
  104202. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  104203. *
  104204. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104205. * glowy meshes to your scene.
  104206. *
  104207. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  104208. */
  104209. export class GlowLayer extends EffectLayer {
  104210. /**
  104211. * Effect Name of the layer.
  104212. */
  104213. static readonly EffectName: string;
  104214. /**
  104215. * The default blur kernel size used for the glow.
  104216. */
  104217. static DefaultBlurKernelSize: number;
  104218. /**
  104219. * The default texture size ratio used for the glow.
  104220. */
  104221. static DefaultTextureRatio: number;
  104222. /**
  104223. * Sets the kernel size of the blur.
  104224. */
  104225. /**
  104226. * Gets the kernel size of the blur.
  104227. */
  104228. blurKernelSize: number;
  104229. /**
  104230. * Sets the glow intensity.
  104231. */
  104232. /**
  104233. * Gets the glow intensity.
  104234. */
  104235. intensity: number;
  104236. private _options;
  104237. private _intensity;
  104238. private _horizontalBlurPostprocess1;
  104239. private _verticalBlurPostprocess1;
  104240. private _horizontalBlurPostprocess2;
  104241. private _verticalBlurPostprocess2;
  104242. private _blurTexture1;
  104243. private _blurTexture2;
  104244. private _postProcesses1;
  104245. private _postProcesses2;
  104246. private _includedOnlyMeshes;
  104247. private _excludedMeshes;
  104248. /**
  104249. * Callback used to let the user override the color selection on a per mesh basis
  104250. */
  104251. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  104252. /**
  104253. * Callback used to let the user override the texture selection on a per mesh basis
  104254. */
  104255. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  104256. /**
  104257. * Instantiates a new glow Layer and references it to the scene.
  104258. * @param name The name of the layer
  104259. * @param scene The scene to use the layer in
  104260. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  104261. */
  104262. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  104263. /**
  104264. * Get the effect name of the layer.
  104265. * @return The effect name
  104266. */
  104267. getEffectName(): string;
  104268. /**
  104269. * Create the merge effect. This is the shader use to blit the information back
  104270. * to the main canvas at the end of the scene rendering.
  104271. */
  104272. protected _createMergeEffect(): Effect;
  104273. /**
  104274. * Creates the render target textures and post processes used in the glow layer.
  104275. */
  104276. protected _createTextureAndPostProcesses(): void;
  104277. /**
  104278. * Checks for the readiness of the element composing the layer.
  104279. * @param subMesh the mesh to check for
  104280. * @param useInstances specify wether or not to use instances to render the mesh
  104281. * @param emissiveTexture the associated emissive texture used to generate the glow
  104282. * @return true if ready otherwise, false
  104283. */
  104284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104285. /**
  104286. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104287. */
  104288. needStencil(): boolean;
  104289. /**
  104290. * Returns true if the mesh can be rendered, otherwise false.
  104291. * @param mesh The mesh to render
  104292. * @param material The material used on the mesh
  104293. * @returns true if it can be rendered otherwise false
  104294. */
  104295. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104296. /**
  104297. * Implementation specific of rendering the generating effect on the main canvas.
  104298. * @param effect The effect used to render through
  104299. */
  104300. protected _internalRender(effect: Effect): void;
  104301. /**
  104302. * Sets the required values for both the emissive texture and and the main color.
  104303. */
  104304. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104305. /**
  104306. * Returns true if the mesh should render, otherwise false.
  104307. * @param mesh The mesh to render
  104308. * @returns true if it should render otherwise false
  104309. */
  104310. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104311. /**
  104312. * Adds specific effects defines.
  104313. * @param defines The defines to add specifics to.
  104314. */
  104315. protected _addCustomEffectDefines(defines: string[]): void;
  104316. /**
  104317. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  104318. * @param mesh The mesh to exclude from the glow layer
  104319. */
  104320. addExcludedMesh(mesh: Mesh): void;
  104321. /**
  104322. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  104323. * @param mesh The mesh to remove
  104324. */
  104325. removeExcludedMesh(mesh: Mesh): void;
  104326. /**
  104327. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  104328. * @param mesh The mesh to include in the glow layer
  104329. */
  104330. addIncludedOnlyMesh(mesh: Mesh): void;
  104331. /**
  104332. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  104333. * @param mesh The mesh to remove
  104334. */
  104335. removeIncludedOnlyMesh(mesh: Mesh): void;
  104336. /**
  104337. * Determine if a given mesh will be used in the glow layer
  104338. * @param mesh The mesh to test
  104339. * @returns true if the mesh will be highlighted by the current glow layer
  104340. */
  104341. hasMesh(mesh: AbstractMesh): boolean;
  104342. /**
  104343. * Free any resources and references associated to a mesh.
  104344. * Internal use
  104345. * @param mesh The mesh to free.
  104346. * @hidden
  104347. */
  104348. _disposeMesh(mesh: Mesh): void;
  104349. /**
  104350. * Gets the class name of the effect layer
  104351. * @returns the string with the class name of the effect layer
  104352. */
  104353. getClassName(): string;
  104354. /**
  104355. * Serializes this glow layer
  104356. * @returns a serialized glow layer object
  104357. */
  104358. serialize(): any;
  104359. /**
  104360. * Creates a Glow Layer from parsed glow layer data
  104361. * @param parsedGlowLayer defines glow layer data
  104362. * @param scene defines the current scene
  104363. * @param rootUrl defines the root URL containing the glow layer information
  104364. * @returns a parsed Glow Layer
  104365. */
  104366. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  104367. }
  104368. }
  104369. declare module BABYLON {
  104370. /** @hidden */
  104371. export var glowBlurPostProcessPixelShader: {
  104372. name: string;
  104373. shader: string;
  104374. };
  104375. }
  104376. declare module BABYLON {
  104377. interface AbstractScene {
  104378. /**
  104379. * Return a the first highlight layer of the scene with a given name.
  104380. * @param name The name of the highlight layer to look for.
  104381. * @return The highlight layer if found otherwise null.
  104382. */
  104383. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  104384. }
  104385. /**
  104386. * Highlight layer options. This helps customizing the behaviour
  104387. * of the highlight layer.
  104388. */
  104389. export interface IHighlightLayerOptions {
  104390. /**
  104391. * Multiplication factor apply to the canvas size to compute the render target size
  104392. * used to generated the glowing objects (the smaller the faster).
  104393. */
  104394. mainTextureRatio: number;
  104395. /**
  104396. * Enforces a fixed size texture to ensure resize independant blur.
  104397. */
  104398. mainTextureFixedSize?: number;
  104399. /**
  104400. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  104401. * of the picture to blur (the smaller the faster).
  104402. */
  104403. blurTextureSizeRatio: number;
  104404. /**
  104405. * How big in texel of the blur texture is the vertical blur.
  104406. */
  104407. blurVerticalSize: number;
  104408. /**
  104409. * How big in texel of the blur texture is the horizontal blur.
  104410. */
  104411. blurHorizontalSize: number;
  104412. /**
  104413. * Alpha blending mode used to apply the blur. Default is combine.
  104414. */
  104415. alphaBlendingMode: number;
  104416. /**
  104417. * The camera attached to the layer.
  104418. */
  104419. camera: Nullable<Camera>;
  104420. /**
  104421. * Should we display highlight as a solid stroke?
  104422. */
  104423. isStroke?: boolean;
  104424. /**
  104425. * The rendering group to draw the layer in.
  104426. */
  104427. renderingGroupId: number;
  104428. }
  104429. /**
  104430. * The highlight layer Helps adding a glow effect around a mesh.
  104431. *
  104432. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104433. * glowy meshes to your scene.
  104434. *
  104435. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  104436. */
  104437. export class HighlightLayer extends EffectLayer {
  104438. name: string;
  104439. /**
  104440. * Effect Name of the highlight layer.
  104441. */
  104442. static readonly EffectName: string;
  104443. /**
  104444. * The neutral color used during the preparation of the glow effect.
  104445. * This is black by default as the blend operation is a blend operation.
  104446. */
  104447. static NeutralColor: Color4;
  104448. /**
  104449. * Stencil value used for glowing meshes.
  104450. */
  104451. static GlowingMeshStencilReference: number;
  104452. /**
  104453. * Stencil value used for the other meshes in the scene.
  104454. */
  104455. static NormalMeshStencilReference: number;
  104456. /**
  104457. * Specifies whether or not the inner glow is ACTIVE in the layer.
  104458. */
  104459. innerGlow: boolean;
  104460. /**
  104461. * Specifies whether or not the outer glow is ACTIVE in the layer.
  104462. */
  104463. outerGlow: boolean;
  104464. /**
  104465. * Specifies the horizontal size of the blur.
  104466. */
  104467. /**
  104468. * Gets the horizontal size of the blur.
  104469. */
  104470. blurHorizontalSize: number;
  104471. /**
  104472. * Specifies the vertical size of the blur.
  104473. */
  104474. /**
  104475. * Gets the vertical size of the blur.
  104476. */
  104477. blurVerticalSize: number;
  104478. /**
  104479. * An event triggered when the highlight layer is being blurred.
  104480. */
  104481. onBeforeBlurObservable: Observable<HighlightLayer>;
  104482. /**
  104483. * An event triggered when the highlight layer has been blurred.
  104484. */
  104485. onAfterBlurObservable: Observable<HighlightLayer>;
  104486. private _instanceGlowingMeshStencilReference;
  104487. private _options;
  104488. private _downSamplePostprocess;
  104489. private _horizontalBlurPostprocess;
  104490. private _verticalBlurPostprocess;
  104491. private _blurTexture;
  104492. private _meshes;
  104493. private _excludedMeshes;
  104494. /**
  104495. * Instantiates a new highlight Layer and references it to the scene..
  104496. * @param name The name of the layer
  104497. * @param scene The scene to use the layer in
  104498. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  104499. */
  104500. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  104501. /**
  104502. * Get the effect name of the layer.
  104503. * @return The effect name
  104504. */
  104505. getEffectName(): string;
  104506. /**
  104507. * Create the merge effect. This is the shader use to blit the information back
  104508. * to the main canvas at the end of the scene rendering.
  104509. */
  104510. protected _createMergeEffect(): Effect;
  104511. /**
  104512. * Creates the render target textures and post processes used in the highlight layer.
  104513. */
  104514. protected _createTextureAndPostProcesses(): void;
  104515. /**
  104516. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104517. */
  104518. needStencil(): boolean;
  104519. /**
  104520. * Checks for the readiness of the element composing the layer.
  104521. * @param subMesh the mesh to check for
  104522. * @param useInstances specify wether or not to use instances to render the mesh
  104523. * @param emissiveTexture the associated emissive texture used to generate the glow
  104524. * @return true if ready otherwise, false
  104525. */
  104526. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104527. /**
  104528. * Implementation specific of rendering the generating effect on the main canvas.
  104529. * @param effect The effect used to render through
  104530. */
  104531. protected _internalRender(effect: Effect): void;
  104532. /**
  104533. * Returns true if the layer contains information to display, otherwise false.
  104534. */
  104535. shouldRender(): boolean;
  104536. /**
  104537. * Returns true if the mesh should render, otherwise false.
  104538. * @param mesh The mesh to render
  104539. * @returns true if it should render otherwise false
  104540. */
  104541. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104542. /**
  104543. * Sets the required values for both the emissive texture and and the main color.
  104544. */
  104545. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104546. /**
  104547. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  104548. * @param mesh The mesh to exclude from the highlight layer
  104549. */
  104550. addExcludedMesh(mesh: Mesh): void;
  104551. /**
  104552. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  104553. * @param mesh The mesh to highlight
  104554. */
  104555. removeExcludedMesh(mesh: Mesh): void;
  104556. /**
  104557. * Determine if a given mesh will be highlighted by the current HighlightLayer
  104558. * @param mesh mesh to test
  104559. * @returns true if the mesh will be highlighted by the current HighlightLayer
  104560. */
  104561. hasMesh(mesh: AbstractMesh): boolean;
  104562. /**
  104563. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  104564. * @param mesh The mesh to highlight
  104565. * @param color The color of the highlight
  104566. * @param glowEmissiveOnly Extract the glow from the emissive texture
  104567. */
  104568. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  104569. /**
  104570. * Remove a mesh from the highlight layer in order to make it stop glowing.
  104571. * @param mesh The mesh to highlight
  104572. */
  104573. removeMesh(mesh: Mesh): void;
  104574. /**
  104575. * Force the stencil to the normal expected value for none glowing parts
  104576. */
  104577. private _defaultStencilReference;
  104578. /**
  104579. * Free any resources and references associated to a mesh.
  104580. * Internal use
  104581. * @param mesh The mesh to free.
  104582. * @hidden
  104583. */
  104584. _disposeMesh(mesh: Mesh): void;
  104585. /**
  104586. * Dispose the highlight layer and free resources.
  104587. */
  104588. dispose(): void;
  104589. /**
  104590. * Gets the class name of the effect layer
  104591. * @returns the string with the class name of the effect layer
  104592. */
  104593. getClassName(): string;
  104594. /**
  104595. * Serializes this Highlight layer
  104596. * @returns a serialized Highlight layer object
  104597. */
  104598. serialize(): any;
  104599. /**
  104600. * Creates a Highlight layer from parsed Highlight layer data
  104601. * @param parsedHightlightLayer defines the Highlight layer data
  104602. * @param scene defines the current scene
  104603. * @param rootUrl defines the root URL containing the Highlight layer information
  104604. * @returns a parsed Highlight layer
  104605. */
  104606. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  104607. }
  104608. }
  104609. declare module BABYLON {
  104610. /** @hidden */
  104611. export var lensFlarePixelShader: {
  104612. name: string;
  104613. shader: string;
  104614. };
  104615. }
  104616. declare module BABYLON {
  104617. /** @hidden */
  104618. export var lensFlareVertexShader: {
  104619. name: string;
  104620. shader: string;
  104621. };
  104622. }
  104623. declare module BABYLON {
  104624. /**
  104625. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104626. * It is usually composed of several `lensFlare`.
  104627. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104628. */
  104629. export class LensFlareSystem {
  104630. /**
  104631. * Define the name of the lens flare system
  104632. */
  104633. name: string;
  104634. /**
  104635. * List of lens flares used in this system.
  104636. */
  104637. lensFlares: LensFlare[];
  104638. /**
  104639. * Define a limit from the border the lens flare can be visible.
  104640. */
  104641. borderLimit: number;
  104642. /**
  104643. * Define a viewport border we do not want to see the lens flare in.
  104644. */
  104645. viewportBorder: number;
  104646. /**
  104647. * Define a predicate which could limit the list of meshes able to occlude the effect.
  104648. */
  104649. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104650. /**
  104651. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  104652. */
  104653. layerMask: number;
  104654. /**
  104655. * Define the id of the lens flare system in the scene.
  104656. * (equal to name by default)
  104657. */
  104658. id: string;
  104659. private _scene;
  104660. private _emitter;
  104661. private _vertexBuffers;
  104662. private _indexBuffer;
  104663. private _effect;
  104664. private _positionX;
  104665. private _positionY;
  104666. private _isEnabled;
  104667. /** @hidden */
  104668. static _SceneComponentInitialization: (scene: Scene) => void;
  104669. /**
  104670. * Instantiates a lens flare system.
  104671. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104672. * It is usually composed of several `lensFlare`.
  104673. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104674. * @param name Define the name of the lens flare system in the scene
  104675. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  104676. * @param scene Define the scene the lens flare system belongs to
  104677. */
  104678. constructor(
  104679. /**
  104680. * Define the name of the lens flare system
  104681. */
  104682. name: string, emitter: any, scene: Scene);
  104683. /**
  104684. * Define if the lens flare system is enabled.
  104685. */
  104686. isEnabled: boolean;
  104687. /**
  104688. * Get the scene the effects belongs to.
  104689. * @returns the scene holding the lens flare system
  104690. */
  104691. getScene(): Scene;
  104692. /**
  104693. * Get the emitter of the lens flare system.
  104694. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104695. * @returns the emitter of the lens flare system
  104696. */
  104697. getEmitter(): any;
  104698. /**
  104699. * Set the emitter of the lens flare system.
  104700. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104701. * @param newEmitter Define the new emitter of the system
  104702. */
  104703. setEmitter(newEmitter: any): void;
  104704. /**
  104705. * Get the lens flare system emitter position.
  104706. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  104707. * @returns the position
  104708. */
  104709. getEmitterPosition(): Vector3;
  104710. /**
  104711. * @hidden
  104712. */
  104713. computeEffectivePosition(globalViewport: Viewport): boolean;
  104714. /** @hidden */
  104715. _isVisible(): boolean;
  104716. /**
  104717. * @hidden
  104718. */
  104719. render(): boolean;
  104720. /**
  104721. * Dispose and release the lens flare with its associated resources.
  104722. */
  104723. dispose(): void;
  104724. /**
  104725. * Parse a lens flare system from a JSON repressentation
  104726. * @param parsedLensFlareSystem Define the JSON to parse
  104727. * @param scene Define the scene the parsed system should be instantiated in
  104728. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  104729. * @returns the parsed system
  104730. */
  104731. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  104732. /**
  104733. * Serialize the current Lens Flare System into a JSON representation.
  104734. * @returns the serialized JSON
  104735. */
  104736. serialize(): any;
  104737. }
  104738. }
  104739. declare module BABYLON {
  104740. /**
  104741. * This represents one of the lens effect in a `lensFlareSystem`.
  104742. * It controls one of the indiviual texture used in the effect.
  104743. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104744. */
  104745. export class LensFlare {
  104746. /**
  104747. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104748. */
  104749. size: number;
  104750. /**
  104751. * 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.
  104752. */
  104753. position: number;
  104754. /**
  104755. * Define the lens color.
  104756. */
  104757. color: Color3;
  104758. /**
  104759. * Define the lens texture.
  104760. */
  104761. texture: Nullable<Texture>;
  104762. /**
  104763. * Define the alpha mode to render this particular lens.
  104764. */
  104765. alphaMode: number;
  104766. private _system;
  104767. /**
  104768. * Creates a new Lens Flare.
  104769. * This represents one of the lens effect in a `lensFlareSystem`.
  104770. * It controls one of the indiviual texture used in the effect.
  104771. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104772. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  104773. * @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.
  104774. * @param color Define the lens color
  104775. * @param imgUrl Define the lens texture url
  104776. * @param system Define the `lensFlareSystem` this flare is part of
  104777. * @returns The newly created Lens Flare
  104778. */
  104779. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  104780. /**
  104781. * Instantiates a new Lens Flare.
  104782. * This represents one of the lens effect in a `lensFlareSystem`.
  104783. * It controls one of the indiviual texture used in the effect.
  104784. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104785. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  104786. * @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.
  104787. * @param color Define the lens color
  104788. * @param imgUrl Define the lens texture url
  104789. * @param system Define the `lensFlareSystem` this flare is part of
  104790. */
  104791. constructor(
  104792. /**
  104793. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104794. */
  104795. size: number,
  104796. /**
  104797. * 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.
  104798. */
  104799. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  104800. /**
  104801. * Dispose and release the lens flare with its associated resources.
  104802. */
  104803. dispose(): void;
  104804. }
  104805. }
  104806. declare module BABYLON {
  104807. interface AbstractScene {
  104808. /**
  104809. * The list of lens flare system added to the scene
  104810. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104811. */
  104812. lensFlareSystems: Array<LensFlareSystem>;
  104813. /**
  104814. * Removes the given lens flare system from this scene.
  104815. * @param toRemove The lens flare system to remove
  104816. * @returns The index of the removed lens flare system
  104817. */
  104818. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  104819. /**
  104820. * Adds the given lens flare system to this scene
  104821. * @param newLensFlareSystem The lens flare system to add
  104822. */
  104823. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  104824. /**
  104825. * Gets a lens flare system using its name
  104826. * @param name defines the name to look for
  104827. * @returns the lens flare system or null if not found
  104828. */
  104829. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  104830. /**
  104831. * Gets a lens flare system using its id
  104832. * @param id defines the id to look for
  104833. * @returns the lens flare system or null if not found
  104834. */
  104835. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  104836. }
  104837. /**
  104838. * Defines the lens flare scene component responsible to manage any lens flares
  104839. * in a given scene.
  104840. */
  104841. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  104842. /**
  104843. * The component name helpfull to identify the component in the list of scene components.
  104844. */
  104845. readonly name: string;
  104846. /**
  104847. * The scene the component belongs to.
  104848. */
  104849. scene: Scene;
  104850. /**
  104851. * Creates a new instance of the component for the given scene
  104852. * @param scene Defines the scene to register the component in
  104853. */
  104854. constructor(scene: Scene);
  104855. /**
  104856. * Registers the component in a given scene
  104857. */
  104858. register(): void;
  104859. /**
  104860. * Rebuilds the elements related to this component in case of
  104861. * context lost for instance.
  104862. */
  104863. rebuild(): void;
  104864. /**
  104865. * Adds all the element from the container to the scene
  104866. * @param container the container holding the elements
  104867. */
  104868. addFromContainer(container: AbstractScene): void;
  104869. /**
  104870. * Removes all the elements in the container from the scene
  104871. * @param container contains the elements to remove
  104872. */
  104873. removeFromContainer(container: AbstractScene): void;
  104874. /**
  104875. * Serializes the component data to the specified json object
  104876. * @param serializationObject The object to serialize to
  104877. */
  104878. serialize(serializationObject: any): void;
  104879. /**
  104880. * Disposes the component and the associated ressources.
  104881. */
  104882. dispose(): void;
  104883. private _draw;
  104884. }
  104885. }
  104886. declare module BABYLON {
  104887. /**
  104888. * Defines the shadow generator component responsible to manage any shadow generators
  104889. * in a given scene.
  104890. */
  104891. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  104892. /**
  104893. * The component name helpfull to identify the component in the list of scene components.
  104894. */
  104895. readonly name: string;
  104896. /**
  104897. * The scene the component belongs to.
  104898. */
  104899. scene: Scene;
  104900. /**
  104901. * Creates a new instance of the component for the given scene
  104902. * @param scene Defines the scene to register the component in
  104903. */
  104904. constructor(scene: Scene);
  104905. /**
  104906. * Registers the component in a given scene
  104907. */
  104908. register(): void;
  104909. /**
  104910. * Rebuilds the elements related to this component in case of
  104911. * context lost for instance.
  104912. */
  104913. rebuild(): void;
  104914. /**
  104915. * Serializes the component data to the specified json object
  104916. * @param serializationObject The object to serialize to
  104917. */
  104918. serialize(serializationObject: any): void;
  104919. /**
  104920. * Adds all the element from the container to the scene
  104921. * @param container the container holding the elements
  104922. */
  104923. addFromContainer(container: AbstractScene): void;
  104924. /**
  104925. * Removes all the elements in the container from the scene
  104926. * @param container contains the elements to remove
  104927. */
  104928. removeFromContainer(container: AbstractScene): void;
  104929. /**
  104930. * Rebuilds the elements related to this component in case of
  104931. * context lost for instance.
  104932. */
  104933. dispose(): void;
  104934. private _gatherRenderTargets;
  104935. }
  104936. }
  104937. declare module BABYLON {
  104938. /**
  104939. * A directional light is defined by a direction (what a surprise!).
  104940. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  104941. * 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.
  104942. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104943. */
  104944. export class DirectionalLight extends ShadowLight {
  104945. private _shadowFrustumSize;
  104946. /**
  104947. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  104948. */
  104949. /**
  104950. * Specifies a fix frustum size for the shadow generation.
  104951. */
  104952. shadowFrustumSize: number;
  104953. private _shadowOrthoScale;
  104954. /**
  104955. * Gets the shadow projection scale against the optimal computed one.
  104956. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104957. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104958. */
  104959. /**
  104960. * Sets the shadow projection scale against the optimal computed one.
  104961. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104962. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104963. */
  104964. shadowOrthoScale: number;
  104965. /**
  104966. * Automatically compute the projection matrix to best fit (including all the casters)
  104967. * on each frame.
  104968. */
  104969. autoUpdateExtends: boolean;
  104970. private _orthoLeft;
  104971. private _orthoRight;
  104972. private _orthoTop;
  104973. private _orthoBottom;
  104974. /**
  104975. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  104976. * The directional light is emitted from everywhere in the given direction.
  104977. * It can cast shadows.
  104978. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104979. * @param name The friendly name of the light
  104980. * @param direction The direction of the light
  104981. * @param scene The scene the light belongs to
  104982. */
  104983. constructor(name: string, direction: Vector3, scene: Scene);
  104984. /**
  104985. * Returns the string "DirectionalLight".
  104986. * @return The class name
  104987. */
  104988. getClassName(): string;
  104989. /**
  104990. * Returns the integer 1.
  104991. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104992. */
  104993. getTypeID(): number;
  104994. /**
  104995. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  104996. * Returns the DirectionalLight Shadow projection matrix.
  104997. */
  104998. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104999. /**
  105000. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105001. * Returns the DirectionalLight Shadow projection matrix.
  105002. */
  105003. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105004. /**
  105005. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105006. * Returns the DirectionalLight Shadow projection matrix.
  105007. */
  105008. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105009. protected _buildUniformLayout(): void;
  105010. /**
  105011. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105012. * @param effect The effect to update
  105013. * @param lightIndex The index of the light in the effect to update
  105014. * @returns The directional light
  105015. */
  105016. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105017. /**
  105018. * Gets the minZ used for shadow according to both the scene and the light.
  105019. *
  105020. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105021. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105022. * @param activeCamera The camera we are returning the min for
  105023. * @returns the depth min z
  105024. */
  105025. getDepthMinZ(activeCamera: Camera): number;
  105026. /**
  105027. * Gets the maxZ used for shadow according to both the scene and the light.
  105028. *
  105029. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105030. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105031. * @param activeCamera The camera we are returning the max for
  105032. * @returns the depth max z
  105033. */
  105034. getDepthMaxZ(activeCamera: Camera): number;
  105035. /**
  105036. * Prepares the list of defines specific to the light type.
  105037. * @param defines the list of defines
  105038. * @param lightIndex defines the index of the light for the effect
  105039. */
  105040. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105041. }
  105042. }
  105043. declare module BABYLON {
  105044. /**
  105045. * A point light is a light defined by an unique point in world space.
  105046. * The light is emitted in every direction from this point.
  105047. * A good example of a point light is a standard light bulb.
  105048. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105049. */
  105050. export class PointLight extends ShadowLight {
  105051. private _shadowAngle;
  105052. /**
  105053. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105054. * This specifies what angle the shadow will use to be created.
  105055. *
  105056. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105057. */
  105058. /**
  105059. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105060. * This specifies what angle the shadow will use to be created.
  105061. *
  105062. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105063. */
  105064. shadowAngle: number;
  105065. /**
  105066. * Gets the direction if it has been set.
  105067. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105068. */
  105069. /**
  105070. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105071. */
  105072. direction: Vector3;
  105073. /**
  105074. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  105075. * A PointLight emits the light in every direction.
  105076. * It can cast shadows.
  105077. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  105078. * ```javascript
  105079. * var pointLight = new PointLight("pl", camera.position, scene);
  105080. * ```
  105081. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105082. * @param name The light friendly name
  105083. * @param position The position of the point light in the scene
  105084. * @param scene The scene the lights belongs to
  105085. */
  105086. constructor(name: string, position: Vector3, scene: Scene);
  105087. /**
  105088. * Returns the string "PointLight"
  105089. * @returns the class name
  105090. */
  105091. getClassName(): string;
  105092. /**
  105093. * Returns the integer 0.
  105094. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105095. */
  105096. getTypeID(): number;
  105097. /**
  105098. * Specifies wether or not the shadowmap should be a cube texture.
  105099. * @returns true if the shadowmap needs to be a cube texture.
  105100. */
  105101. needCube(): boolean;
  105102. /**
  105103. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  105104. * @param faceIndex The index of the face we are computed the direction to generate shadow
  105105. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  105106. */
  105107. getShadowDirection(faceIndex?: number): Vector3;
  105108. /**
  105109. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  105110. * - fov = PI / 2
  105111. * - aspect ratio : 1.0
  105112. * - z-near and far equal to the active camera minZ and maxZ.
  105113. * Returns the PointLight.
  105114. */
  105115. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105116. protected _buildUniformLayout(): void;
  105117. /**
  105118. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  105119. * @param effect The effect to update
  105120. * @param lightIndex The index of the light in the effect to update
  105121. * @returns The point light
  105122. */
  105123. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  105124. /**
  105125. * Prepares the list of defines specific to the light type.
  105126. * @param defines the list of defines
  105127. * @param lightIndex defines the index of the light for the effect
  105128. */
  105129. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105130. }
  105131. }
  105132. declare module BABYLON {
  105133. /**
  105134. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105135. * These values define a cone of light starting from the position, emitting toward the direction.
  105136. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105137. * and the exponent defines the speed of the decay of the light with distance (reach).
  105138. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105139. */
  105140. export class SpotLight extends ShadowLight {
  105141. private _angle;
  105142. private _innerAngle;
  105143. private _cosHalfAngle;
  105144. private _lightAngleScale;
  105145. private _lightAngleOffset;
  105146. /**
  105147. * Gets the cone angle of the spot light in Radians.
  105148. */
  105149. /**
  105150. * Sets the cone angle of the spot light in Radians.
  105151. */
  105152. angle: number;
  105153. /**
  105154. * Only used in gltf falloff mode, this defines the angle where
  105155. * the directional falloff will start before cutting at angle which could be seen
  105156. * as outer angle.
  105157. */
  105158. /**
  105159. * Only used in gltf falloff mode, this defines the angle where
  105160. * the directional falloff will start before cutting at angle which could be seen
  105161. * as outer angle.
  105162. */
  105163. innerAngle: number;
  105164. private _shadowAngleScale;
  105165. /**
  105166. * Allows scaling the angle of the light for shadow generation only.
  105167. */
  105168. /**
  105169. * Allows scaling the angle of the light for shadow generation only.
  105170. */
  105171. shadowAngleScale: number;
  105172. /**
  105173. * The light decay speed with the distance from the emission spot.
  105174. */
  105175. exponent: number;
  105176. private _projectionTextureMatrix;
  105177. /**
  105178. * Allows reading the projecton texture
  105179. */
  105180. readonly projectionTextureMatrix: Matrix;
  105181. protected _projectionTextureLightNear: number;
  105182. /**
  105183. * Gets the near clip of the Spotlight for texture projection.
  105184. */
  105185. /**
  105186. * Sets the near clip of the Spotlight for texture projection.
  105187. */
  105188. projectionTextureLightNear: number;
  105189. protected _projectionTextureLightFar: number;
  105190. /**
  105191. * Gets the far clip of the Spotlight for texture projection.
  105192. */
  105193. /**
  105194. * Sets the far clip of the Spotlight for texture projection.
  105195. */
  105196. projectionTextureLightFar: number;
  105197. protected _projectionTextureUpDirection: Vector3;
  105198. /**
  105199. * Gets the Up vector of the Spotlight for texture projection.
  105200. */
  105201. /**
  105202. * Sets the Up vector of the Spotlight for texture projection.
  105203. */
  105204. projectionTextureUpDirection: Vector3;
  105205. private _projectionTexture;
  105206. /**
  105207. * Gets the projection texture of the light.
  105208. */
  105209. /**
  105210. * Sets the projection texture of the light.
  105211. */
  105212. projectionTexture: Nullable<BaseTexture>;
  105213. private _projectionTextureViewLightDirty;
  105214. private _projectionTextureProjectionLightDirty;
  105215. private _projectionTextureDirty;
  105216. private _projectionTextureViewTargetVector;
  105217. private _projectionTextureViewLightMatrix;
  105218. private _projectionTextureProjectionLightMatrix;
  105219. private _projectionTextureScalingMatrix;
  105220. /**
  105221. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105222. * It can cast shadows.
  105223. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105224. * @param name The light friendly name
  105225. * @param position The position of the spot light in the scene
  105226. * @param direction The direction of the light in the scene
  105227. * @param angle The cone angle of the light in Radians
  105228. * @param exponent The light decay speed with the distance from the emission spot
  105229. * @param scene The scene the lights belongs to
  105230. */
  105231. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105232. /**
  105233. * Returns the string "SpotLight".
  105234. * @returns the class name
  105235. */
  105236. getClassName(): string;
  105237. /**
  105238. * Returns the integer 2.
  105239. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105240. */
  105241. getTypeID(): number;
  105242. /**
  105243. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105244. */
  105245. protected _setDirection(value: Vector3): void;
  105246. /**
  105247. * Overrides the position setter to recompute the projection texture view light Matrix.
  105248. */
  105249. protected _setPosition(value: Vector3): void;
  105250. /**
  105251. * 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.
  105252. * Returns the SpotLight.
  105253. */
  105254. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105255. protected _computeProjectionTextureViewLightMatrix(): void;
  105256. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105257. /**
  105258. * Main function for light texture projection matrix computing.
  105259. */
  105260. protected _computeProjectionTextureMatrix(): void;
  105261. protected _buildUniformLayout(): void;
  105262. private _computeAngleValues;
  105263. /**
  105264. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105265. * @param effect The effect to update
  105266. * @param lightIndex The index of the light in the effect to update
  105267. * @returns The spot light
  105268. */
  105269. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105270. /**
  105271. * Disposes the light and the associated resources.
  105272. */
  105273. dispose(): void;
  105274. /**
  105275. * Prepares the list of defines specific to the light type.
  105276. * @param defines the list of defines
  105277. * @param lightIndex defines the index of the light for the effect
  105278. */
  105279. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105280. }
  105281. }
  105282. declare module BABYLON {
  105283. /**
  105284. * Header information of HDR texture files.
  105285. */
  105286. export interface HDRInfo {
  105287. /**
  105288. * The height of the texture in pixels.
  105289. */
  105290. height: number;
  105291. /**
  105292. * The width of the texture in pixels.
  105293. */
  105294. width: number;
  105295. /**
  105296. * The index of the beginning of the data in the binary file.
  105297. */
  105298. dataPosition: number;
  105299. }
  105300. /**
  105301. * This groups tools to convert HDR texture to native colors array.
  105302. */
  105303. export class HDRTools {
  105304. private static Ldexp;
  105305. private static Rgbe2float;
  105306. private static readStringLine;
  105307. /**
  105308. * Reads header information from an RGBE texture stored in a native array.
  105309. * More information on this format are available here:
  105310. * https://en.wikipedia.org/wiki/RGBE_image_format
  105311. *
  105312. * @param uint8array The binary file stored in native array.
  105313. * @return The header information.
  105314. */
  105315. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  105316. /**
  105317. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  105318. * This RGBE texture needs to store the information as a panorama.
  105319. *
  105320. * More information on this format are available here:
  105321. * https://en.wikipedia.org/wiki/RGBE_image_format
  105322. *
  105323. * @param buffer The binary file stored in an array buffer.
  105324. * @param size The expected size of the extracted cubemap.
  105325. * @return The Cube Map information.
  105326. */
  105327. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  105328. /**
  105329. * Returns the pixels data extracted from an RGBE texture.
  105330. * This pixels will be stored left to right up to down in the R G B order in one array.
  105331. *
  105332. * More information on this format are available here:
  105333. * https://en.wikipedia.org/wiki/RGBE_image_format
  105334. *
  105335. * @param uint8array The binary file stored in an array buffer.
  105336. * @param hdrInfo The header information of the file.
  105337. * @return The pixels data in RGB right to left up to down order.
  105338. */
  105339. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  105340. private static RGBE_ReadPixels_RLE;
  105341. }
  105342. }
  105343. declare module BABYLON {
  105344. /**
  105345. * This represents a texture coming from an HDR input.
  105346. *
  105347. * The only supported format is currently panorama picture stored in RGBE format.
  105348. * Example of such files can be found on HDRLib: http://hdrlib.com/
  105349. */
  105350. export class HDRCubeTexture extends BaseTexture {
  105351. private static _facesMapping;
  105352. private _generateHarmonics;
  105353. private _noMipmap;
  105354. private _textureMatrix;
  105355. private _size;
  105356. private _onLoad;
  105357. private _onError;
  105358. /**
  105359. * The texture URL.
  105360. */
  105361. url: string;
  105362. /**
  105363. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  105364. */
  105365. coordinatesMode: number;
  105366. protected _isBlocking: boolean;
  105367. /**
  105368. * Sets wether or not the texture is blocking during loading.
  105369. */
  105370. /**
  105371. * Gets wether or not the texture is blocking during loading.
  105372. */
  105373. isBlocking: boolean;
  105374. protected _rotationY: number;
  105375. /**
  105376. * Sets texture matrix rotation angle around Y axis in radians.
  105377. */
  105378. /**
  105379. * Gets texture matrix rotation angle around Y axis radians.
  105380. */
  105381. rotationY: number;
  105382. /**
  105383. * Gets or sets the center of the bounding box associated with the cube texture
  105384. * It must define where the camera used to render the texture was set
  105385. */
  105386. boundingBoxPosition: Vector3;
  105387. private _boundingBoxSize;
  105388. /**
  105389. * Gets or sets the size of the bounding box associated with the cube texture
  105390. * When defined, the cubemap will switch to local mode
  105391. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  105392. * @example https://www.babylonjs-playground.com/#RNASML
  105393. */
  105394. boundingBoxSize: Vector3;
  105395. /**
  105396. * Instantiates an HDRTexture from the following parameters.
  105397. *
  105398. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  105399. * @param scene The scene the texture will be used in
  105400. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105401. * @param noMipmap Forces to not generate the mipmap if true
  105402. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  105403. * @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)
  105404. * @param reserved Reserved flag for internal use.
  105405. */
  105406. 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>);
  105407. /**
  105408. * Get the current class name of the texture useful for serialization or dynamic coding.
  105409. * @returns "HDRCubeTexture"
  105410. */
  105411. getClassName(): string;
  105412. /**
  105413. * Occurs when the file is raw .hdr file.
  105414. */
  105415. private loadTexture;
  105416. clone(): HDRCubeTexture;
  105417. delayLoad(): void;
  105418. /**
  105419. * Get the texture reflection matrix used to rotate/transform the reflection.
  105420. * @returns the reflection matrix
  105421. */
  105422. getReflectionTextureMatrix(): Matrix;
  105423. /**
  105424. * Set the texture reflection matrix used to rotate/transform the reflection.
  105425. * @param value Define the reflection matrix to set
  105426. */
  105427. setReflectionTextureMatrix(value: Matrix): void;
  105428. /**
  105429. * Parses a JSON representation of an HDR Texture in order to create the texture
  105430. * @param parsedTexture Define the JSON representation
  105431. * @param scene Define the scene the texture should be created in
  105432. * @param rootUrl Define the root url in case we need to load relative dependencies
  105433. * @returns the newly created texture after parsing
  105434. */
  105435. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  105436. serialize(): any;
  105437. }
  105438. }
  105439. declare module BABYLON {
  105440. /**
  105441. * Class used to control physics engine
  105442. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105443. */
  105444. export class PhysicsEngine implements IPhysicsEngine {
  105445. private _physicsPlugin;
  105446. /**
  105447. * Global value used to control the smallest number supported by the simulation
  105448. */
  105449. static Epsilon: number;
  105450. private _impostors;
  105451. private _joints;
  105452. /**
  105453. * Gets the gravity vector used by the simulation
  105454. */
  105455. gravity: Vector3;
  105456. /**
  105457. * Factory used to create the default physics plugin.
  105458. * @returns The default physics plugin
  105459. */
  105460. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  105461. /**
  105462. * Creates a new Physics Engine
  105463. * @param gravity defines the gravity vector used by the simulation
  105464. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  105465. */
  105466. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  105467. /**
  105468. * Sets the gravity vector used by the simulation
  105469. * @param gravity defines the gravity vector to use
  105470. */
  105471. setGravity(gravity: Vector3): void;
  105472. /**
  105473. * Set the time step of the physics engine.
  105474. * Default is 1/60.
  105475. * To slow it down, enter 1/600 for example.
  105476. * To speed it up, 1/30
  105477. * @param newTimeStep defines the new timestep to apply to this world.
  105478. */
  105479. setTimeStep(newTimeStep?: number): void;
  105480. /**
  105481. * Get the time step of the physics engine.
  105482. * @returns the current time step
  105483. */
  105484. getTimeStep(): number;
  105485. /**
  105486. * Release all resources
  105487. */
  105488. dispose(): void;
  105489. /**
  105490. * Gets the name of the current physics plugin
  105491. * @returns the name of the plugin
  105492. */
  105493. getPhysicsPluginName(): string;
  105494. /**
  105495. * Adding a new impostor for the impostor tracking.
  105496. * This will be done by the impostor itself.
  105497. * @param impostor the impostor to add
  105498. */
  105499. addImpostor(impostor: PhysicsImpostor): void;
  105500. /**
  105501. * Remove an impostor from the engine.
  105502. * This impostor and its mesh will not longer be updated by the physics engine.
  105503. * @param impostor the impostor to remove
  105504. */
  105505. removeImpostor(impostor: PhysicsImpostor): void;
  105506. /**
  105507. * Add a joint to the physics engine
  105508. * @param mainImpostor defines the main impostor to which the joint is added.
  105509. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  105510. * @param joint defines the joint that will connect both impostors.
  105511. */
  105512. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105513. /**
  105514. * Removes a joint from the simulation
  105515. * @param mainImpostor defines the impostor used with the joint
  105516. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  105517. * @param joint defines the joint to remove
  105518. */
  105519. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105520. /**
  105521. * Called by the scene. No need to call it.
  105522. * @param delta defines the timespam between frames
  105523. */
  105524. _step(delta: number): void;
  105525. /**
  105526. * Gets the current plugin used to run the simulation
  105527. * @returns current plugin
  105528. */
  105529. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105530. /**
  105531. * Gets the list of physic impostors
  105532. * @returns an array of PhysicsImpostor
  105533. */
  105534. getImpostors(): Array<PhysicsImpostor>;
  105535. /**
  105536. * Gets the impostor for a physics enabled object
  105537. * @param object defines the object impersonated by the impostor
  105538. * @returns the PhysicsImpostor or null if not found
  105539. */
  105540. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105541. /**
  105542. * Gets the impostor for a physics body object
  105543. * @param body defines physics body used by the impostor
  105544. * @returns the PhysicsImpostor or null if not found
  105545. */
  105546. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105547. /**
  105548. * Does a raycast in the physics world
  105549. * @param from when should the ray start?
  105550. * @param to when should the ray end?
  105551. * @returns PhysicsRaycastResult
  105552. */
  105553. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105554. }
  105555. }
  105556. declare module BABYLON {
  105557. /** @hidden */
  105558. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  105559. private _useDeltaForWorldStep;
  105560. world: any;
  105561. name: string;
  105562. private _physicsMaterials;
  105563. private _fixedTimeStep;
  105564. private _cannonRaycastResult;
  105565. private _raycastResult;
  105566. BJSCANNON: any;
  105567. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  105568. setGravity(gravity: Vector3): void;
  105569. setTimeStep(timeStep: number): void;
  105570. getTimeStep(): number;
  105571. executeStep(delta: number): void;
  105572. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105573. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105574. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105575. private _processChildMeshes;
  105576. removePhysicsBody(impostor: PhysicsImpostor): void;
  105577. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105578. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105579. private _addMaterial;
  105580. private _checkWithEpsilon;
  105581. private _createShape;
  105582. private _createHeightmap;
  105583. private _minus90X;
  105584. private _plus90X;
  105585. private _tmpPosition;
  105586. private _tmpDeltaPosition;
  105587. private _tmpUnityRotation;
  105588. private _updatePhysicsBodyTransformation;
  105589. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105590. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105591. isSupported(): boolean;
  105592. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105593. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105594. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105595. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105596. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105597. getBodyMass(impostor: PhysicsImpostor): number;
  105598. getBodyFriction(impostor: PhysicsImpostor): number;
  105599. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105600. getBodyRestitution(impostor: PhysicsImpostor): number;
  105601. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105602. sleepBody(impostor: PhysicsImpostor): void;
  105603. wakeUpBody(impostor: PhysicsImpostor): void;
  105604. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  105605. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105606. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105607. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105608. getRadius(impostor: PhysicsImpostor): number;
  105609. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105610. dispose(): void;
  105611. private _extendNamespace;
  105612. /**
  105613. * Does a raycast in the physics world
  105614. * @param from when should the ray start?
  105615. * @param to when should the ray end?
  105616. * @returns PhysicsRaycastResult
  105617. */
  105618. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105619. }
  105620. }
  105621. declare module BABYLON {
  105622. /** @hidden */
  105623. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  105624. world: any;
  105625. name: string;
  105626. BJSOIMO: any;
  105627. private _raycastResult;
  105628. constructor(iterations?: number, oimoInjection?: any);
  105629. setGravity(gravity: Vector3): void;
  105630. setTimeStep(timeStep: number): void;
  105631. getTimeStep(): number;
  105632. private _tmpImpostorsArray;
  105633. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105634. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105635. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105636. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105637. private _tmpPositionVector;
  105638. removePhysicsBody(impostor: PhysicsImpostor): void;
  105639. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105640. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105641. isSupported(): boolean;
  105642. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105643. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105644. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105645. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105646. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105647. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105648. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105649. getBodyMass(impostor: PhysicsImpostor): number;
  105650. getBodyFriction(impostor: PhysicsImpostor): number;
  105651. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105652. getBodyRestitution(impostor: PhysicsImpostor): number;
  105653. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105654. sleepBody(impostor: PhysicsImpostor): void;
  105655. wakeUpBody(impostor: PhysicsImpostor): void;
  105656. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105657. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  105658. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105659. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105660. getRadius(impostor: PhysicsImpostor): number;
  105661. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105662. dispose(): void;
  105663. /**
  105664. * Does a raycast in the physics world
  105665. * @param from when should the ray start?
  105666. * @param to when should the ray end?
  105667. * @returns PhysicsRaycastResult
  105668. */
  105669. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105670. }
  105671. }
  105672. declare module BABYLON {
  105673. interface AbstractScene {
  105674. /**
  105675. * The list of reflection probes added to the scene
  105676. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105677. */
  105678. reflectionProbes: Array<ReflectionProbe>;
  105679. /**
  105680. * Removes the given reflection probe from this scene.
  105681. * @param toRemove The reflection probe to remove
  105682. * @returns The index of the removed reflection probe
  105683. */
  105684. removeReflectionProbe(toRemove: ReflectionProbe): number;
  105685. /**
  105686. * Adds the given reflection probe to this scene.
  105687. * @param newReflectionProbe The reflection probe to add
  105688. */
  105689. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  105690. }
  105691. /**
  105692. * Class used to generate realtime reflection / refraction cube textures
  105693. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105694. */
  105695. export class ReflectionProbe {
  105696. /** defines the name of the probe */
  105697. name: string;
  105698. private _scene;
  105699. private _renderTargetTexture;
  105700. private _projectionMatrix;
  105701. private _viewMatrix;
  105702. private _target;
  105703. private _add;
  105704. private _attachedMesh;
  105705. private _invertYAxis;
  105706. /** Gets or sets probe position (center of the cube map) */
  105707. position: Vector3;
  105708. /**
  105709. * Creates a new reflection probe
  105710. * @param name defines the name of the probe
  105711. * @param size defines the texture resolution (for each face)
  105712. * @param scene defines the hosting scene
  105713. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  105714. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  105715. */
  105716. constructor(
  105717. /** defines the name of the probe */
  105718. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  105719. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  105720. samples: number;
  105721. /** Gets or sets the refresh rate to use (on every frame by default) */
  105722. refreshRate: number;
  105723. /**
  105724. * Gets the hosting scene
  105725. * @returns a Scene
  105726. */
  105727. getScene(): Scene;
  105728. /** Gets the internal CubeTexture used to render to */
  105729. readonly cubeTexture: RenderTargetTexture;
  105730. /** Gets the list of meshes to render */
  105731. readonly renderList: Nullable<AbstractMesh[]>;
  105732. /**
  105733. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  105734. * @param mesh defines the mesh to attach to
  105735. */
  105736. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105737. /**
  105738. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  105739. * @param renderingGroupId The rendering group id corresponding to its index
  105740. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105741. */
  105742. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  105743. /**
  105744. * Clean all associated resources
  105745. */
  105746. dispose(): void;
  105747. /**
  105748. * Converts the reflection probe information to a readable string for debug purpose.
  105749. * @param fullDetails Supports for multiple levels of logging within scene loading
  105750. * @returns the human readable reflection probe info
  105751. */
  105752. toString(fullDetails?: boolean): string;
  105753. /**
  105754. * Get the class name of the relfection probe.
  105755. * @returns "ReflectionProbe"
  105756. */
  105757. getClassName(): string;
  105758. /**
  105759. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  105760. * @returns The JSON representation of the texture
  105761. */
  105762. serialize(): any;
  105763. /**
  105764. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  105765. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  105766. * @param scene Define the scene the parsed reflection probe should be instantiated in
  105767. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  105768. * @returns The parsed reflection probe if successful
  105769. */
  105770. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  105771. }
  105772. }
  105773. declare module BABYLON {
  105774. /** @hidden */
  105775. export var _BabylonLoaderRegistered: boolean;
  105776. }
  105777. declare module BABYLON {
  105778. /**
  105779. * The Physically based simple base material of BJS.
  105780. *
  105781. * This enables better naming and convention enforcements on top of the pbrMaterial.
  105782. * It is used as the base class for both the specGloss and metalRough conventions.
  105783. */
  105784. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  105785. /**
  105786. * Number of Simultaneous lights allowed on the material.
  105787. */
  105788. maxSimultaneousLights: number;
  105789. /**
  105790. * If sets to true, disables all the lights affecting the material.
  105791. */
  105792. disableLighting: boolean;
  105793. /**
  105794. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  105795. */
  105796. environmentTexture: BaseTexture;
  105797. /**
  105798. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105799. */
  105800. invertNormalMapX: boolean;
  105801. /**
  105802. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105803. */
  105804. invertNormalMapY: boolean;
  105805. /**
  105806. * Normal map used in the model.
  105807. */
  105808. normalTexture: BaseTexture;
  105809. /**
  105810. * Emissivie color used to self-illuminate the model.
  105811. */
  105812. emissiveColor: Color3;
  105813. /**
  105814. * Emissivie texture used to self-illuminate the model.
  105815. */
  105816. emissiveTexture: BaseTexture;
  105817. /**
  105818. * Occlusion Channel Strenght.
  105819. */
  105820. occlusionStrength: number;
  105821. /**
  105822. * Occlusion Texture of the material (adding extra occlusion effects).
  105823. */
  105824. occlusionTexture: BaseTexture;
  105825. /**
  105826. * Defines the alpha limits in alpha test mode.
  105827. */
  105828. alphaCutOff: number;
  105829. /**
  105830. * Gets the current double sided mode.
  105831. */
  105832. /**
  105833. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105834. */
  105835. doubleSided: boolean;
  105836. /**
  105837. * Stores the pre-calculated light information of a mesh in a texture.
  105838. */
  105839. lightmapTexture: BaseTexture;
  105840. /**
  105841. * If true, the light map contains occlusion information instead of lighting info.
  105842. */
  105843. useLightmapAsShadowmap: boolean;
  105844. /**
  105845. * Instantiates a new PBRMaterial instance.
  105846. *
  105847. * @param name The material name
  105848. * @param scene The scene the material will be use in.
  105849. */
  105850. constructor(name: string, scene: Scene);
  105851. getClassName(): string;
  105852. }
  105853. }
  105854. declare module BABYLON {
  105855. /**
  105856. * The PBR material of BJS following the metal roughness convention.
  105857. *
  105858. * This fits to the PBR convention in the GLTF definition:
  105859. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  105860. */
  105861. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  105862. /**
  105863. * The base color has two different interpretations depending on the value of metalness.
  105864. * When the material is a metal, the base color is the specific measured reflectance value
  105865. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  105866. * of the material.
  105867. */
  105868. baseColor: Color3;
  105869. /**
  105870. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  105871. * well as opacity information in the alpha channel.
  105872. */
  105873. baseTexture: BaseTexture;
  105874. /**
  105875. * Specifies the metallic scalar value of the material.
  105876. * Can also be used to scale the metalness values of the metallic texture.
  105877. */
  105878. metallic: number;
  105879. /**
  105880. * Specifies the roughness scalar value of the material.
  105881. * Can also be used to scale the roughness values of the metallic texture.
  105882. */
  105883. roughness: number;
  105884. /**
  105885. * Texture containing both the metallic value in the B channel and the
  105886. * roughness value in the G channel to keep better precision.
  105887. */
  105888. metallicRoughnessTexture: BaseTexture;
  105889. /**
  105890. * Instantiates a new PBRMetalRoughnessMaterial instance.
  105891. *
  105892. * @param name The material name
  105893. * @param scene The scene the material will be use in.
  105894. */
  105895. constructor(name: string, scene: Scene);
  105896. /**
  105897. * Return the currrent class name of the material.
  105898. */
  105899. getClassName(): string;
  105900. /**
  105901. * Makes a duplicate of the current material.
  105902. * @param name - name to use for the new material.
  105903. */
  105904. clone(name: string): PBRMetallicRoughnessMaterial;
  105905. /**
  105906. * Serialize the material to a parsable JSON object.
  105907. */
  105908. serialize(): any;
  105909. /**
  105910. * Parses a JSON object correponding to the serialize function.
  105911. */
  105912. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  105913. }
  105914. }
  105915. declare module BABYLON {
  105916. /**
  105917. * The PBR material of BJS following the specular glossiness convention.
  105918. *
  105919. * This fits to the PBR convention in the GLTF definition:
  105920. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  105921. */
  105922. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  105923. /**
  105924. * Specifies the diffuse color of the material.
  105925. */
  105926. diffuseColor: Color3;
  105927. /**
  105928. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  105929. * channel.
  105930. */
  105931. diffuseTexture: BaseTexture;
  105932. /**
  105933. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  105934. */
  105935. specularColor: Color3;
  105936. /**
  105937. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  105938. */
  105939. glossiness: number;
  105940. /**
  105941. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  105942. */
  105943. specularGlossinessTexture: BaseTexture;
  105944. /**
  105945. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  105946. *
  105947. * @param name The material name
  105948. * @param scene The scene the material will be use in.
  105949. */
  105950. constructor(name: string, scene: Scene);
  105951. /**
  105952. * Return the currrent class name of the material.
  105953. */
  105954. getClassName(): string;
  105955. /**
  105956. * Makes a duplicate of the current material.
  105957. * @param name - name to use for the new material.
  105958. */
  105959. clone(name: string): PBRSpecularGlossinessMaterial;
  105960. /**
  105961. * Serialize the material to a parsable JSON object.
  105962. */
  105963. serialize(): any;
  105964. /**
  105965. * Parses a JSON object correponding to the serialize function.
  105966. */
  105967. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  105968. }
  105969. }
  105970. declare module BABYLON {
  105971. /**
  105972. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  105973. * It can help converting any input color in a desired output one. This can then be used to create effects
  105974. * from sepia, black and white to sixties or futuristic rendering...
  105975. *
  105976. * The only supported format is currently 3dl.
  105977. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  105978. */
  105979. export class ColorGradingTexture extends BaseTexture {
  105980. /**
  105981. * The current texture matrix. (will always be identity in color grading texture)
  105982. */
  105983. private _textureMatrix;
  105984. /**
  105985. * The texture URL.
  105986. */
  105987. url: string;
  105988. /**
  105989. * Empty line regex stored for GC.
  105990. */
  105991. private static _noneEmptyLineRegex;
  105992. private _engine;
  105993. /**
  105994. * Instantiates a ColorGradingTexture from the following parameters.
  105995. *
  105996. * @param url The location of the color gradind data (currently only supporting 3dl)
  105997. * @param scene The scene the texture will be used in
  105998. */
  105999. constructor(url: string, scene: Scene);
  106000. /**
  106001. * Returns the texture matrix used in most of the material.
  106002. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  106003. */
  106004. getTextureMatrix(): Matrix;
  106005. /**
  106006. * Occurs when the file being loaded is a .3dl LUT file.
  106007. */
  106008. private load3dlTexture;
  106009. /**
  106010. * Starts the loading process of the texture.
  106011. */
  106012. private loadTexture;
  106013. /**
  106014. * Clones the color gradind texture.
  106015. */
  106016. clone(): ColorGradingTexture;
  106017. /**
  106018. * Called during delayed load for textures.
  106019. */
  106020. delayLoad(): void;
  106021. /**
  106022. * Parses a color grading texture serialized by Babylon.
  106023. * @param parsedTexture The texture information being parsedTexture
  106024. * @param scene The scene to load the texture in
  106025. * @param rootUrl The root url of the data assets to load
  106026. * @return A color gradind texture
  106027. */
  106028. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  106029. /**
  106030. * Serializes the LUT texture to json format.
  106031. */
  106032. serialize(): any;
  106033. }
  106034. }
  106035. declare module BABYLON {
  106036. /**
  106037. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  106038. */
  106039. export class EquiRectangularCubeTexture extends BaseTexture {
  106040. /** The six faces of the cube. */
  106041. private static _FacesMapping;
  106042. private _noMipmap;
  106043. private _onLoad;
  106044. private _onError;
  106045. /** The size of the cubemap. */
  106046. private _size;
  106047. /** The buffer of the image. */
  106048. private _buffer;
  106049. /** The width of the input image. */
  106050. private _width;
  106051. /** The height of the input image. */
  106052. private _height;
  106053. /** The URL to the image. */
  106054. url: string;
  106055. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  106056. coordinatesMode: number;
  106057. /**
  106058. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  106059. * @param url The location of the image
  106060. * @param scene The scene the texture will be used in
  106061. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  106062. * @param noMipmap Forces to not generate the mipmap if true
  106063. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  106064. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  106065. * @param onLoad — defines a callback called when texture is loaded
  106066. * @param onError — defines a callback called if there is an error
  106067. */
  106068. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  106069. /**
  106070. * Load the image data, by putting the image on a canvas and extracting its buffer.
  106071. */
  106072. private loadImage;
  106073. /**
  106074. * Convert the image buffer into a cubemap and create a CubeTexture.
  106075. */
  106076. private loadTexture;
  106077. /**
  106078. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  106079. * @param buffer The ArrayBuffer that should be converted.
  106080. * @returns The buffer as Float32Array.
  106081. */
  106082. private getFloat32ArrayFromArrayBuffer;
  106083. /**
  106084. * Get the current class name of the texture useful for serialization or dynamic coding.
  106085. * @returns "EquiRectangularCubeTexture"
  106086. */
  106087. getClassName(): string;
  106088. /**
  106089. * Create a clone of the current EquiRectangularCubeTexture and return it.
  106090. * @returns A clone of the current EquiRectangularCubeTexture.
  106091. */
  106092. clone(): EquiRectangularCubeTexture;
  106093. }
  106094. }
  106095. declare module BABYLON {
  106096. /**
  106097. * Based on jsTGALoader - Javascript loader for TGA file
  106098. * By Vincent Thibault
  106099. * @see http://blog.robrowser.com/javascript-tga-loader.html
  106100. */
  106101. export class TGATools {
  106102. private static _TYPE_INDEXED;
  106103. private static _TYPE_RGB;
  106104. private static _TYPE_GREY;
  106105. private static _TYPE_RLE_INDEXED;
  106106. private static _TYPE_RLE_RGB;
  106107. private static _TYPE_RLE_GREY;
  106108. private static _ORIGIN_MASK;
  106109. private static _ORIGIN_SHIFT;
  106110. private static _ORIGIN_BL;
  106111. private static _ORIGIN_BR;
  106112. private static _ORIGIN_UL;
  106113. private static _ORIGIN_UR;
  106114. /**
  106115. * Gets the header of a TGA file
  106116. * @param data defines the TGA data
  106117. * @returns the header
  106118. */
  106119. static GetTGAHeader(data: Uint8Array): any;
  106120. /**
  106121. * Uploads TGA content to a Babylon Texture
  106122. * @hidden
  106123. */
  106124. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  106125. /** @hidden */
  106126. 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;
  106127. /** @hidden */
  106128. 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;
  106129. /** @hidden */
  106130. 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;
  106131. /** @hidden */
  106132. 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;
  106133. /** @hidden */
  106134. 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;
  106135. /** @hidden */
  106136. 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;
  106137. }
  106138. }
  106139. declare module BABYLON {
  106140. /**
  106141. * Implementation of the TGA Texture Loader.
  106142. * @hidden
  106143. */
  106144. export class _TGATextureLoader implements IInternalTextureLoader {
  106145. /**
  106146. * Defines wether the loader supports cascade loading the different faces.
  106147. */
  106148. readonly supportCascades: boolean;
  106149. /**
  106150. * This returns if the loader support the current file information.
  106151. * @param extension defines the file extension of the file being loaded
  106152. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106153. * @param fallback defines the fallback internal texture if any
  106154. * @param isBase64 defines whether the texture is encoded as a base64
  106155. * @param isBuffer defines whether the texture data are stored as a buffer
  106156. * @returns true if the loader can load the specified file
  106157. */
  106158. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106159. /**
  106160. * Transform the url before loading if required.
  106161. * @param rootUrl the url of the texture
  106162. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106163. * @returns the transformed texture
  106164. */
  106165. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106166. /**
  106167. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106168. * @param rootUrl the url of the texture
  106169. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106170. * @returns the fallback texture
  106171. */
  106172. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106173. /**
  106174. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106175. * @param data contains the texture data
  106176. * @param texture defines the BabylonJS internal texture
  106177. * @param createPolynomials will be true if polynomials have been requested
  106178. * @param onLoad defines the callback to trigger once the texture is ready
  106179. * @param onError defines the callback to trigger in case of error
  106180. */
  106181. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106182. /**
  106183. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106184. * @param data contains the texture data
  106185. * @param texture defines the BabylonJS internal texture
  106186. * @param callback defines the method to call once ready to upload
  106187. */
  106188. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106189. }
  106190. }
  106191. declare module BABYLON {
  106192. /**
  106193. * 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.
  106194. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106195. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106196. */
  106197. export class CustomProceduralTexture extends ProceduralTexture {
  106198. private _animate;
  106199. private _time;
  106200. private _config;
  106201. private _texturePath;
  106202. /**
  106203. * Instantiates a new Custom Procedural Texture.
  106204. * 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.
  106205. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106206. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106207. * @param name Define the name of the texture
  106208. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  106209. * @param size Define the size of the texture to create
  106210. * @param scene Define the scene the texture belongs to
  106211. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  106212. * @param generateMipMaps Define if the texture should creates mip maps or not
  106213. */
  106214. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106215. private _loadJson;
  106216. /**
  106217. * Is the texture ready to be used ? (rendered at least once)
  106218. * @returns true if ready, otherwise, false.
  106219. */
  106220. isReady(): boolean;
  106221. /**
  106222. * Render the texture to its associated render target.
  106223. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  106224. */
  106225. render(useCameraPostProcess?: boolean): void;
  106226. /**
  106227. * Update the list of dependant textures samplers in the shader.
  106228. */
  106229. updateTextures(): void;
  106230. /**
  106231. * Update the uniform values of the procedural texture in the shader.
  106232. */
  106233. updateShaderUniforms(): void;
  106234. /**
  106235. * Define if the texture animates or not.
  106236. */
  106237. animate: boolean;
  106238. }
  106239. }
  106240. declare module BABYLON {
  106241. /** @hidden */
  106242. export var noisePixelShader: {
  106243. name: string;
  106244. shader: string;
  106245. };
  106246. }
  106247. declare module BABYLON {
  106248. /**
  106249. * Class used to generate noise procedural textures
  106250. */
  106251. export class NoiseProceduralTexture extends ProceduralTexture {
  106252. private _time;
  106253. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  106254. brightness: number;
  106255. /** Defines the number of octaves to process */
  106256. octaves: number;
  106257. /** Defines the level of persistence (0.8 by default) */
  106258. persistence: number;
  106259. /** Gets or sets animation speed factor (default is 1) */
  106260. animationSpeedFactor: number;
  106261. /**
  106262. * Creates a new NoiseProceduralTexture
  106263. * @param name defines the name fo the texture
  106264. * @param size defines the size of the texture (default is 256)
  106265. * @param scene defines the hosting scene
  106266. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  106267. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  106268. */
  106269. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106270. private _updateShaderUniforms;
  106271. protected _getDefines(): string;
  106272. /** Generate the current state of the procedural texture */
  106273. render(useCameraPostProcess?: boolean): void;
  106274. /**
  106275. * Serializes this noise procedural texture
  106276. * @returns a serialized noise procedural texture object
  106277. */
  106278. serialize(): any;
  106279. /**
  106280. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  106281. * @param parsedTexture defines parsed texture data
  106282. * @param scene defines the current scene
  106283. * @param rootUrl defines the root URL containing noise procedural texture information
  106284. * @returns a parsed NoiseProceduralTexture
  106285. */
  106286. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  106287. }
  106288. }
  106289. declare module BABYLON {
  106290. /**
  106291. * Raw cube texture where the raw buffers are passed in
  106292. */
  106293. export class RawCubeTexture extends CubeTexture {
  106294. /**
  106295. * Creates a cube texture where the raw buffers are passed in.
  106296. * @param scene defines the scene the texture is attached to
  106297. * @param data defines the array of data to use to create each face
  106298. * @param size defines the size of the textures
  106299. * @param format defines the format of the data
  106300. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106301. * @param generateMipMaps defines if the engine should generate the mip levels
  106302. * @param invertY defines if data must be stored with Y axis inverted
  106303. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106304. * @param compression defines the compression used (null by default)
  106305. */
  106306. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  106307. /**
  106308. * Updates the raw cube texture.
  106309. * @param data defines the data to store
  106310. * @param format defines the data format
  106311. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106312. * @param invertY defines if data must be stored with Y axis inverted
  106313. * @param compression defines the compression used (null by default)
  106314. * @param level defines which level of the texture to update
  106315. */
  106316. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  106317. /**
  106318. * Updates a raw cube texture with RGBD encoded data.
  106319. * @param data defines the array of data [mipmap][face] to use to create each face
  106320. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  106321. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  106322. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  106323. * @returns a promsie that resolves when the operation is complete
  106324. */
  106325. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  106326. /**
  106327. * Clones the raw cube texture.
  106328. * @return a new cube texture
  106329. */
  106330. clone(): CubeTexture;
  106331. /** @hidden */
  106332. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106333. }
  106334. }
  106335. declare module BABYLON {
  106336. /**
  106337. * Class used to store 3D textures containing user data
  106338. */
  106339. export class RawTexture3D extends Texture {
  106340. /** Gets or sets the texture format to use */
  106341. format: number;
  106342. private _engine;
  106343. /**
  106344. * Create a new RawTexture3D
  106345. * @param data defines the data of the texture
  106346. * @param width defines the width of the texture
  106347. * @param height defines the height of the texture
  106348. * @param depth defines the depth of the texture
  106349. * @param format defines the texture format to use
  106350. * @param scene defines the hosting scene
  106351. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  106352. * @param invertY defines if texture must be stored with Y axis inverted
  106353. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  106354. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  106355. */
  106356. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  106357. /** Gets or sets the texture format to use */
  106358. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  106359. /**
  106360. * Update the texture with new data
  106361. * @param data defines the data to store in the texture
  106362. */
  106363. update(data: ArrayBufferView): void;
  106364. }
  106365. }
  106366. declare module BABYLON {
  106367. /**
  106368. * Creates a refraction texture used by refraction channel of the standard material.
  106369. * It is like a mirror but to see through a material.
  106370. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106371. */
  106372. export class RefractionTexture extends RenderTargetTexture {
  106373. /**
  106374. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  106375. * 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.
  106376. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106377. */
  106378. refractionPlane: Plane;
  106379. /**
  106380. * Define how deep under the surface we should see.
  106381. */
  106382. depth: number;
  106383. /**
  106384. * Creates a refraction texture used by refraction channel of the standard material.
  106385. * It is like a mirror but to see through a material.
  106386. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106387. * @param name Define the texture name
  106388. * @param size Define the size of the underlying texture
  106389. * @param scene Define the scene the refraction belongs to
  106390. * @param generateMipMaps Define if we need to generate mips level for the refraction
  106391. */
  106392. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  106393. /**
  106394. * Clone the refraction texture.
  106395. * @returns the cloned texture
  106396. */
  106397. clone(): RefractionTexture;
  106398. /**
  106399. * Serialize the texture to a JSON representation you could use in Parse later on
  106400. * @returns the serialized JSON representation
  106401. */
  106402. serialize(): any;
  106403. }
  106404. }
  106405. declare module BABYLON {
  106406. /**
  106407. * Configuration for Draco compression
  106408. */
  106409. export interface IDracoCompressionConfiguration {
  106410. /**
  106411. * Configuration for the decoder.
  106412. */
  106413. decoder?: {
  106414. /**
  106415. * The url to the WebAssembly module.
  106416. */
  106417. wasmUrl?: string;
  106418. /**
  106419. * The url to the WebAssembly binary.
  106420. */
  106421. wasmBinaryUrl?: string;
  106422. /**
  106423. * The url to the fallback JavaScript module.
  106424. */
  106425. fallbackUrl?: string;
  106426. };
  106427. }
  106428. /**
  106429. * Draco compression (https://google.github.io/draco/)
  106430. *
  106431. * This class wraps the Draco module.
  106432. *
  106433. * **Encoder**
  106434. *
  106435. * The encoder is not currently implemented.
  106436. *
  106437. * **Decoder**
  106438. *
  106439. * 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.
  106440. *
  106441. * To update the configuration, use the following code:
  106442. * ```javascript
  106443. * DracoCompression.Configuration = {
  106444. * decoder: {
  106445. * wasmUrl: "<url to the WebAssembly library>",
  106446. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  106447. * fallbackUrl: "<url to the fallback JavaScript library>",
  106448. * }
  106449. * };
  106450. * ```
  106451. *
  106452. * 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.
  106453. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  106454. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  106455. *
  106456. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  106457. * ```javascript
  106458. * var dracoCompression = new DracoCompression();
  106459. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  106460. * [VertexBuffer.PositionKind]: 0
  106461. * });
  106462. * ```
  106463. *
  106464. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  106465. */
  106466. export class DracoCompression implements IDisposable {
  106467. private static _DecoderModulePromise;
  106468. /**
  106469. * The configuration. Defaults to the following urls:
  106470. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  106471. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  106472. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  106473. */
  106474. static Configuration: IDracoCompressionConfiguration;
  106475. /**
  106476. * Returns true if the decoder is available.
  106477. */
  106478. static readonly DecoderAvailable: boolean;
  106479. /**
  106480. * Constructor
  106481. */
  106482. constructor();
  106483. /**
  106484. * Stop all async operations and release resources.
  106485. */
  106486. dispose(): void;
  106487. /**
  106488. * Decode Draco compressed mesh data to vertex data.
  106489. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  106490. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  106491. * @returns A promise that resolves with the decoded vertex data
  106492. */
  106493. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  106494. [kind: string]: number;
  106495. }): Promise<VertexData>;
  106496. private static _GetDecoderModule;
  106497. private static _LoadScriptAsync;
  106498. private static _LoadFileAsync;
  106499. }
  106500. }
  106501. declare module BABYLON {
  106502. /**
  106503. * Class for building Constructive Solid Geometry
  106504. */
  106505. export class CSG {
  106506. private polygons;
  106507. /**
  106508. * The world matrix
  106509. */
  106510. matrix: Matrix;
  106511. /**
  106512. * Stores the position
  106513. */
  106514. position: Vector3;
  106515. /**
  106516. * Stores the rotation
  106517. */
  106518. rotation: Vector3;
  106519. /**
  106520. * Stores the rotation quaternion
  106521. */
  106522. rotationQuaternion: Nullable<Quaternion>;
  106523. /**
  106524. * Stores the scaling vector
  106525. */
  106526. scaling: Vector3;
  106527. /**
  106528. * Convert the Mesh to CSG
  106529. * @param mesh The Mesh to convert to CSG
  106530. * @returns A new CSG from the Mesh
  106531. */
  106532. static FromMesh(mesh: Mesh): CSG;
  106533. /**
  106534. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  106535. * @param polygons Polygons used to construct a CSG solid
  106536. */
  106537. private static FromPolygons;
  106538. /**
  106539. * Clones, or makes a deep copy, of the CSG
  106540. * @returns A new CSG
  106541. */
  106542. clone(): CSG;
  106543. /**
  106544. * Unions this CSG with another CSG
  106545. * @param csg The CSG to union against this CSG
  106546. * @returns The unioned CSG
  106547. */
  106548. union(csg: CSG): CSG;
  106549. /**
  106550. * Unions this CSG with another CSG in place
  106551. * @param csg The CSG to union against this CSG
  106552. */
  106553. unionInPlace(csg: CSG): void;
  106554. /**
  106555. * Subtracts this CSG with another CSG
  106556. * @param csg The CSG to subtract against this CSG
  106557. * @returns A new CSG
  106558. */
  106559. subtract(csg: CSG): CSG;
  106560. /**
  106561. * Subtracts this CSG with another CSG in place
  106562. * @param csg The CSG to subtact against this CSG
  106563. */
  106564. subtractInPlace(csg: CSG): void;
  106565. /**
  106566. * Intersect this CSG with another CSG
  106567. * @param csg The CSG to intersect against this CSG
  106568. * @returns A new CSG
  106569. */
  106570. intersect(csg: CSG): CSG;
  106571. /**
  106572. * Intersects this CSG with another CSG in place
  106573. * @param csg The CSG to intersect against this CSG
  106574. */
  106575. intersectInPlace(csg: CSG): void;
  106576. /**
  106577. * Return a new CSG solid with solid and empty space switched. This solid is
  106578. * not modified.
  106579. * @returns A new CSG solid with solid and empty space switched
  106580. */
  106581. inverse(): CSG;
  106582. /**
  106583. * Inverses the CSG in place
  106584. */
  106585. inverseInPlace(): void;
  106586. /**
  106587. * This is used to keep meshes transformations so they can be restored
  106588. * when we build back a Babylon Mesh
  106589. * NB : All CSG operations are performed in world coordinates
  106590. * @param csg The CSG to copy the transform attributes from
  106591. * @returns This CSG
  106592. */
  106593. copyTransformAttributes(csg: CSG): CSG;
  106594. /**
  106595. * Build Raw mesh from CSG
  106596. * Coordinates here are in world space
  106597. * @param name The name of the mesh geometry
  106598. * @param scene The Scene
  106599. * @param keepSubMeshes Specifies if the submeshes should be kept
  106600. * @returns A new Mesh
  106601. */
  106602. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  106603. /**
  106604. * Build Mesh from CSG taking material and transforms into account
  106605. * @param name The name of the Mesh
  106606. * @param material The material of the Mesh
  106607. * @param scene The Scene
  106608. * @param keepSubMeshes Specifies if submeshes should be kept
  106609. * @returns The new Mesh
  106610. */
  106611. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  106612. }
  106613. }
  106614. declare module BABYLON {
  106615. /**
  106616. * Class used to create a trail following a mesh
  106617. */
  106618. export class TrailMesh extends Mesh {
  106619. private _generator;
  106620. private _autoStart;
  106621. private _running;
  106622. private _diameter;
  106623. private _length;
  106624. private _sectionPolygonPointsCount;
  106625. private _sectionVectors;
  106626. private _sectionNormalVectors;
  106627. private _beforeRenderObserver;
  106628. /**
  106629. * @constructor
  106630. * @param name The value used by scene.getMeshByName() to do a lookup.
  106631. * @param generator The mesh to generate a trail.
  106632. * @param scene The scene to add this mesh to.
  106633. * @param diameter Diameter of trailing mesh. Default is 1.
  106634. * @param length Length of trailing mesh. Default is 60.
  106635. * @param autoStart Automatically start trailing mesh. Default true.
  106636. */
  106637. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  106638. /**
  106639. * "TrailMesh"
  106640. * @returns "TrailMesh"
  106641. */
  106642. getClassName(): string;
  106643. private _createMesh;
  106644. /**
  106645. * Start trailing mesh.
  106646. */
  106647. start(): void;
  106648. /**
  106649. * Stop trailing mesh.
  106650. */
  106651. stop(): void;
  106652. /**
  106653. * Update trailing mesh geometry.
  106654. */
  106655. update(): void;
  106656. /**
  106657. * Returns a new TrailMesh object.
  106658. * @param name is a string, the name given to the new mesh
  106659. * @param newGenerator use new generator object for cloned trail mesh
  106660. * @returns a new mesh
  106661. */
  106662. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  106663. /**
  106664. * Serializes this trail mesh
  106665. * @param serializationObject object to write serialization to
  106666. */
  106667. serialize(serializationObject: any): void;
  106668. /**
  106669. * Parses a serialized trail mesh
  106670. * @param parsedMesh the serialized mesh
  106671. * @param scene the scene to create the trail mesh in
  106672. * @returns the created trail mesh
  106673. */
  106674. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  106675. }
  106676. }
  106677. declare module BABYLON {
  106678. /**
  106679. * Class containing static functions to help procedurally build meshes
  106680. */
  106681. export class RibbonBuilder {
  106682. /**
  106683. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106684. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106685. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106686. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106687. * * 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
  106688. * * 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
  106689. * * 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
  106690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106692. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106693. * * 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
  106694. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106695. * * 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
  106696. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106698. * @param name defines the name of the mesh
  106699. * @param options defines the options used to create the mesh
  106700. * @param scene defines the hosting scene
  106701. * @returns the ribbon mesh
  106702. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106703. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106704. */
  106705. static CreateRibbon(name: string, options: {
  106706. pathArray: Vector3[][];
  106707. closeArray?: boolean;
  106708. closePath?: boolean;
  106709. offset?: number;
  106710. updatable?: boolean;
  106711. sideOrientation?: number;
  106712. frontUVs?: Vector4;
  106713. backUVs?: Vector4;
  106714. instance?: Mesh;
  106715. invertUV?: boolean;
  106716. uvs?: Vector2[];
  106717. colors?: Color4[];
  106718. }, scene?: Nullable<Scene>): Mesh;
  106719. }
  106720. }
  106721. declare module BABYLON {
  106722. /**
  106723. * Class containing static functions to help procedurally build meshes
  106724. */
  106725. export class TorusKnotBuilder {
  106726. /**
  106727. * Creates a torus knot mesh
  106728. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106729. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106730. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106731. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106735. * @param name defines the name of the mesh
  106736. * @param options defines the options used to create the mesh
  106737. * @param scene defines the hosting scene
  106738. * @returns the torus knot mesh
  106739. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106740. */
  106741. static CreateTorusKnot(name: string, options: {
  106742. radius?: number;
  106743. tube?: number;
  106744. radialSegments?: number;
  106745. tubularSegments?: number;
  106746. p?: number;
  106747. q?: number;
  106748. updatable?: boolean;
  106749. sideOrientation?: number;
  106750. frontUVs?: Vector4;
  106751. backUVs?: Vector4;
  106752. }, scene: any): Mesh;
  106753. }
  106754. }
  106755. declare module BABYLON {
  106756. /**
  106757. * Polygon
  106758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106759. */
  106760. export class Polygon {
  106761. /**
  106762. * Creates a rectangle
  106763. * @param xmin bottom X coord
  106764. * @param ymin bottom Y coord
  106765. * @param xmax top X coord
  106766. * @param ymax top Y coord
  106767. * @returns points that make the resulting rectation
  106768. */
  106769. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  106770. /**
  106771. * Creates a circle
  106772. * @param radius radius of circle
  106773. * @param cx scale in x
  106774. * @param cy scale in y
  106775. * @param numberOfSides number of sides that make up the circle
  106776. * @returns points that make the resulting circle
  106777. */
  106778. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  106779. /**
  106780. * Creates a polygon from input string
  106781. * @param input Input polygon data
  106782. * @returns the parsed points
  106783. */
  106784. static Parse(input: string): Vector2[];
  106785. /**
  106786. * Starts building a polygon from x and y coordinates
  106787. * @param x x coordinate
  106788. * @param y y coordinate
  106789. * @returns the started path2
  106790. */
  106791. static StartingAt(x: number, y: number): Path2;
  106792. }
  106793. /**
  106794. * Builds a polygon
  106795. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  106796. */
  106797. export class PolygonMeshBuilder {
  106798. private _points;
  106799. private _outlinepoints;
  106800. private _holes;
  106801. private _name;
  106802. private _scene;
  106803. private _epoints;
  106804. private _eholes;
  106805. private _addToepoint;
  106806. /**
  106807. * Babylon reference to the earcut plugin.
  106808. */
  106809. bjsEarcut: any;
  106810. /**
  106811. * Creates a PolygonMeshBuilder
  106812. * @param name name of the builder
  106813. * @param contours Path of the polygon
  106814. * @param scene scene to add to when creating the mesh
  106815. * @param earcutInjection can be used to inject your own earcut reference
  106816. */
  106817. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  106818. /**
  106819. * Adds a whole within the polygon
  106820. * @param hole Array of points defining the hole
  106821. * @returns this
  106822. */
  106823. addHole(hole: Vector2[]): PolygonMeshBuilder;
  106824. /**
  106825. * Creates the polygon
  106826. * @param updatable If the mesh should be updatable
  106827. * @param depth The depth of the mesh created
  106828. * @returns the created mesh
  106829. */
  106830. build(updatable?: boolean, depth?: number): Mesh;
  106831. /**
  106832. * Creates the polygon
  106833. * @param depth The depth of the mesh created
  106834. * @returns the created VertexData
  106835. */
  106836. buildVertexData(depth?: number): VertexData;
  106837. /**
  106838. * Adds a side to the polygon
  106839. * @param positions points that make the polygon
  106840. * @param normals normals of the polygon
  106841. * @param uvs uvs of the polygon
  106842. * @param indices indices of the polygon
  106843. * @param bounds bounds of the polygon
  106844. * @param points points of the polygon
  106845. * @param depth depth of the polygon
  106846. * @param flip flip of the polygon
  106847. */
  106848. private addSide;
  106849. }
  106850. }
  106851. declare module BABYLON {
  106852. /**
  106853. * Class containing static functions to help procedurally build meshes
  106854. */
  106855. export class PolygonBuilder {
  106856. /**
  106857. * Creates a polygon mesh
  106858. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106859. * * 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
  106860. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106863. * * Remember you can only change the shape positions, not their number when updating a polygon
  106864. * @param name defines the name of the mesh
  106865. * @param options defines the options used to create the mesh
  106866. * @param scene defines the hosting scene
  106867. * @param earcutInjection can be used to inject your own earcut reference
  106868. * @returns the polygon mesh
  106869. */
  106870. static CreatePolygon(name: string, options: {
  106871. shape: Vector3[];
  106872. holes?: Vector3[][];
  106873. depth?: number;
  106874. faceUV?: Vector4[];
  106875. faceColors?: Color4[];
  106876. updatable?: boolean;
  106877. sideOrientation?: number;
  106878. frontUVs?: Vector4;
  106879. backUVs?: Vector4;
  106880. }, scene: Scene, earcutInjection?: any): Mesh;
  106881. /**
  106882. * Creates an extruded polygon mesh, with depth in the Y direction.
  106883. * * 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)
  106884. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106885. * @param name defines the name of the mesh
  106886. * @param options defines the options used to create the mesh
  106887. * @param scene defines the hosting scene
  106888. * @param earcutInjection can be used to inject your own earcut reference
  106889. * @returns the polygon mesh
  106890. */
  106891. static ExtrudePolygon(name: string, options: {
  106892. shape: Vector3[];
  106893. holes?: Vector3[][];
  106894. depth?: number;
  106895. faceUV?: Vector4[];
  106896. faceColors?: Color4[];
  106897. updatable?: boolean;
  106898. sideOrientation?: number;
  106899. frontUVs?: Vector4;
  106900. backUVs?: Vector4;
  106901. }, scene: Scene, earcutInjection?: any): Mesh;
  106902. }
  106903. }
  106904. declare module BABYLON {
  106905. /**
  106906. * Class containing static functions to help procedurally build meshes
  106907. */
  106908. export class ShapeBuilder {
  106909. /**
  106910. * 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.
  106911. * * 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.
  106912. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106913. * * 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.
  106914. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106915. * * 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
  106916. * * 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
  106917. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106920. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106922. * @param name defines the name of the mesh
  106923. * @param options defines the options used to create the mesh
  106924. * @param scene defines the hosting scene
  106925. * @returns the extruded shape mesh
  106926. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106928. */
  106929. static ExtrudeShape(name: string, options: {
  106930. shape: Vector3[];
  106931. path: Vector3[];
  106932. scale?: number;
  106933. rotation?: number;
  106934. cap?: number;
  106935. updatable?: boolean;
  106936. sideOrientation?: number;
  106937. frontUVs?: Vector4;
  106938. backUVs?: Vector4;
  106939. instance?: Mesh;
  106940. invertUV?: boolean;
  106941. }, scene?: Nullable<Scene>): Mesh;
  106942. /**
  106943. * Creates an custom extruded shape mesh.
  106944. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106945. * * 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.
  106946. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106947. * * 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
  106948. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106949. * * 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
  106950. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106951. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106952. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106953. * * 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
  106954. * * 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
  106955. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106958. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the custom extruded shape mesh
  106964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106965. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106967. */
  106968. static ExtrudeShapeCustom(name: string, options: {
  106969. shape: Vector3[];
  106970. path: Vector3[];
  106971. scaleFunction?: any;
  106972. rotationFunction?: any;
  106973. ribbonCloseArray?: boolean;
  106974. ribbonClosePath?: boolean;
  106975. cap?: number;
  106976. updatable?: boolean;
  106977. sideOrientation?: number;
  106978. frontUVs?: Vector4;
  106979. backUVs?: Vector4;
  106980. instance?: Mesh;
  106981. invertUV?: boolean;
  106982. }, scene: Scene): Mesh;
  106983. private static _ExtrudeShapeGeneric;
  106984. }
  106985. }
  106986. declare module BABYLON {
  106987. /**
  106988. * Class containing static functions to help procedurally build meshes
  106989. */
  106990. export class LatheBuilder {
  106991. /**
  106992. * Creates lathe mesh.
  106993. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106994. * * 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
  106995. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106996. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106997. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106998. * * 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
  106999. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107000. * * 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
  107001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107003. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107005. * @param name defines the name of the mesh
  107006. * @param options defines the options used to create the mesh
  107007. * @param scene defines the hosting scene
  107008. * @returns the lathe mesh
  107009. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107010. */
  107011. static CreateLathe(name: string, options: {
  107012. shape: Vector3[];
  107013. radius?: number;
  107014. tessellation?: number;
  107015. clip?: number;
  107016. arc?: number;
  107017. closed?: boolean;
  107018. updatable?: boolean;
  107019. sideOrientation?: number;
  107020. frontUVs?: Vector4;
  107021. backUVs?: Vector4;
  107022. cap?: number;
  107023. invertUV?: boolean;
  107024. }, scene: Scene): Mesh;
  107025. }
  107026. }
  107027. declare module BABYLON {
  107028. /**
  107029. * Class containing static functions to help procedurally build meshes
  107030. */
  107031. export class TubeBuilder {
  107032. /**
  107033. * Creates a tube mesh.
  107034. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107035. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107036. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107037. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107038. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107039. * * 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)
  107040. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107041. * * 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
  107042. * * 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
  107043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107045. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107047. * @param name defines the name of the mesh
  107048. * @param options defines the options used to create the mesh
  107049. * @param scene defines the hosting scene
  107050. * @returns the tube mesh
  107051. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107052. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107053. */
  107054. static CreateTube(name: string, options: {
  107055. path: Vector3[];
  107056. radius?: number;
  107057. tessellation?: number;
  107058. radiusFunction?: {
  107059. (i: number, distance: number): number;
  107060. };
  107061. cap?: number;
  107062. arc?: number;
  107063. updatable?: boolean;
  107064. sideOrientation?: number;
  107065. frontUVs?: Vector4;
  107066. backUVs?: Vector4;
  107067. instance?: Mesh;
  107068. invertUV?: boolean;
  107069. }, scene: Scene): Mesh;
  107070. }
  107071. }
  107072. declare module BABYLON {
  107073. /**
  107074. * Class containing static functions to help procedurally build meshes
  107075. */
  107076. export class IcoSphereBuilder {
  107077. /**
  107078. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107079. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107080. * * 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`)
  107081. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107082. * * 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
  107083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107086. * @param name defines the name of the mesh
  107087. * @param options defines the options used to create the mesh
  107088. * @param scene defines the hosting scene
  107089. * @returns the icosahedron mesh
  107090. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107091. */
  107092. static CreateIcoSphere(name: string, options: {
  107093. radius?: number;
  107094. radiusX?: number;
  107095. radiusY?: number;
  107096. radiusZ?: number;
  107097. flat?: boolean;
  107098. subdivisions?: number;
  107099. sideOrientation?: number;
  107100. frontUVs?: Vector4;
  107101. backUVs?: Vector4;
  107102. updatable?: boolean;
  107103. }, scene: Scene): Mesh;
  107104. }
  107105. }
  107106. declare module BABYLON {
  107107. /**
  107108. * Class containing static functions to help procedurally build meshes
  107109. */
  107110. export class DecalBuilder {
  107111. /**
  107112. * Creates a decal mesh.
  107113. * 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
  107114. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107115. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107116. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107117. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107118. * @param name defines the name of the mesh
  107119. * @param sourceMesh defines the mesh where the decal must be applied
  107120. * @param options defines the options used to create the mesh
  107121. * @param scene defines the hosting scene
  107122. * @returns the decal mesh
  107123. * @see https://doc.babylonjs.com/how_to/decals
  107124. */
  107125. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107126. position?: Vector3;
  107127. normal?: Vector3;
  107128. size?: Vector3;
  107129. angle?: number;
  107130. }): Mesh;
  107131. }
  107132. }
  107133. declare module BABYLON {
  107134. /**
  107135. * Class containing static functions to help procedurally build meshes
  107136. */
  107137. export class MeshBuilder {
  107138. /**
  107139. * Creates a box mesh
  107140. * * The parameter `size` sets the size (float) of each box side (default 1)
  107141. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107142. * * 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)
  107143. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107147. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107148. * @param name defines the name of the mesh
  107149. * @param options defines the options used to create the mesh
  107150. * @param scene defines the hosting scene
  107151. * @returns the box mesh
  107152. */
  107153. static CreateBox(name: string, options: {
  107154. size?: number;
  107155. width?: number;
  107156. height?: number;
  107157. depth?: number;
  107158. faceUV?: Vector4[];
  107159. faceColors?: Color4[];
  107160. sideOrientation?: number;
  107161. frontUVs?: Vector4;
  107162. backUVs?: Vector4;
  107163. updatable?: boolean;
  107164. }, scene?: Nullable<Scene>): Mesh;
  107165. /**
  107166. * Creates a sphere mesh
  107167. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107168. * * 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`)
  107169. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107170. * * 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
  107171. * * 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)
  107172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107175. * @param name defines the name of the mesh
  107176. * @param options defines the options used to create the mesh
  107177. * @param scene defines the hosting scene
  107178. * @returns the sphere mesh
  107179. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107180. */
  107181. static CreateSphere(name: string, options: {
  107182. segments?: number;
  107183. diameter?: number;
  107184. diameterX?: number;
  107185. diameterY?: number;
  107186. diameterZ?: number;
  107187. arc?: number;
  107188. slice?: number;
  107189. sideOrientation?: number;
  107190. frontUVs?: Vector4;
  107191. backUVs?: Vector4;
  107192. updatable?: boolean;
  107193. }, scene: any): Mesh;
  107194. /**
  107195. * Creates a plane polygonal mesh. By default, this is a disc
  107196. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107197. * * 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
  107198. * * 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
  107199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107202. * @param name defines the name of the mesh
  107203. * @param options defines the options used to create the mesh
  107204. * @param scene defines the hosting scene
  107205. * @returns the plane polygonal mesh
  107206. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107207. */
  107208. static CreateDisc(name: string, options: {
  107209. radius?: number;
  107210. tessellation?: number;
  107211. arc?: number;
  107212. updatable?: boolean;
  107213. sideOrientation?: number;
  107214. frontUVs?: Vector4;
  107215. backUVs?: Vector4;
  107216. }, scene?: Nullable<Scene>): Mesh;
  107217. /**
  107218. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107219. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107220. * * 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`)
  107221. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107222. * * 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
  107223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107226. * @param name defines the name of the mesh
  107227. * @param options defines the options used to create the mesh
  107228. * @param scene defines the hosting scene
  107229. * @returns the icosahedron mesh
  107230. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107231. */
  107232. static CreateIcoSphere(name: string, options: {
  107233. radius?: number;
  107234. radiusX?: number;
  107235. radiusY?: number;
  107236. radiusZ?: number;
  107237. flat?: boolean;
  107238. subdivisions?: number;
  107239. sideOrientation?: number;
  107240. frontUVs?: Vector4;
  107241. backUVs?: Vector4;
  107242. updatable?: boolean;
  107243. }, scene: Scene): Mesh;
  107244. /**
  107245. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107246. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107247. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107248. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107249. * * 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
  107250. * * 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
  107251. * * 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
  107252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107255. * * 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
  107256. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107257. * * 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
  107258. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107260. * @param name defines the name of the mesh
  107261. * @param options defines the options used to create the mesh
  107262. * @param scene defines the hosting scene
  107263. * @returns the ribbon mesh
  107264. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107265. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107266. */
  107267. static CreateRibbon(name: string, options: {
  107268. pathArray: Vector3[][];
  107269. closeArray?: boolean;
  107270. closePath?: boolean;
  107271. offset?: number;
  107272. updatable?: boolean;
  107273. sideOrientation?: number;
  107274. frontUVs?: Vector4;
  107275. backUVs?: Vector4;
  107276. instance?: Mesh;
  107277. invertUV?: boolean;
  107278. uvs?: Vector2[];
  107279. colors?: Color4[];
  107280. }, scene?: Nullable<Scene>): Mesh;
  107281. /**
  107282. * Creates a cylinder or a cone mesh
  107283. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107284. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107285. * * 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.
  107286. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107287. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107288. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107289. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107290. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107291. * * 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).
  107292. * * 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
  107293. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107294. * * 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
  107295. * * 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.
  107296. * * If `enclose` is false, a ring surface is one element.
  107297. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107298. * * 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
  107299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107302. * @param name defines the name of the mesh
  107303. * @param options defines the options used to create the mesh
  107304. * @param scene defines the hosting scene
  107305. * @returns the cylinder mesh
  107306. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107307. */
  107308. static CreateCylinder(name: string, options: {
  107309. height?: number;
  107310. diameterTop?: number;
  107311. diameterBottom?: number;
  107312. diameter?: number;
  107313. tessellation?: number;
  107314. subdivisions?: number;
  107315. arc?: number;
  107316. faceColors?: Color4[];
  107317. faceUV?: Vector4[];
  107318. updatable?: boolean;
  107319. hasRings?: boolean;
  107320. enclose?: boolean;
  107321. sideOrientation?: number;
  107322. frontUVs?: Vector4;
  107323. backUVs?: Vector4;
  107324. }, scene: any): Mesh;
  107325. /**
  107326. * Creates a torus mesh
  107327. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107328. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107329. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107333. * @param name defines the name of the mesh
  107334. * @param options defines the options used to create the mesh
  107335. * @param scene defines the hosting scene
  107336. * @returns the torus mesh
  107337. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107338. */
  107339. static CreateTorus(name: string, options: {
  107340. diameter?: number;
  107341. thickness?: number;
  107342. tessellation?: number;
  107343. updatable?: boolean;
  107344. sideOrientation?: number;
  107345. frontUVs?: Vector4;
  107346. backUVs?: Vector4;
  107347. }, scene: any): Mesh;
  107348. /**
  107349. * Creates a torus knot mesh
  107350. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  107351. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  107352. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  107353. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  107354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107357. * @param name defines the name of the mesh
  107358. * @param options defines the options used to create the mesh
  107359. * @param scene defines the hosting scene
  107360. * @returns the torus knot mesh
  107361. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  107362. */
  107363. static CreateTorusKnot(name: string, options: {
  107364. radius?: number;
  107365. tube?: number;
  107366. radialSegments?: number;
  107367. tubularSegments?: number;
  107368. p?: number;
  107369. q?: number;
  107370. updatable?: boolean;
  107371. sideOrientation?: number;
  107372. frontUVs?: Vector4;
  107373. backUVs?: Vector4;
  107374. }, scene: any): Mesh;
  107375. /**
  107376. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107377. * * 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
  107378. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107379. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107380. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107381. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107382. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107383. * * 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
  107384. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107387. * @param name defines the name of the new line system
  107388. * @param options defines the options used to create the line system
  107389. * @param scene defines the hosting scene
  107390. * @returns a new line system mesh
  107391. */
  107392. static CreateLineSystem(name: string, options: {
  107393. lines: Vector3[][];
  107394. updatable?: boolean;
  107395. instance?: Nullable<LinesMesh>;
  107396. colors?: Nullable<Color4[][]>;
  107397. useVertexAlpha?: boolean;
  107398. }, scene: Nullable<Scene>): LinesMesh;
  107399. /**
  107400. * Creates a line mesh
  107401. * 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
  107402. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107403. * * The parameter `points` is an array successive Vector3
  107404. * * 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
  107405. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107406. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107407. * * When updating an instance, remember that only point positions can change, not the number of points
  107408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107410. * @param name defines the name of the new line system
  107411. * @param options defines the options used to create the line system
  107412. * @param scene defines the hosting scene
  107413. * @returns a new line mesh
  107414. */
  107415. static CreateLines(name: string, options: {
  107416. points: Vector3[];
  107417. updatable?: boolean;
  107418. instance?: Nullable<LinesMesh>;
  107419. colors?: Color4[];
  107420. useVertexAlpha?: boolean;
  107421. }, scene?: Nullable<Scene>): LinesMesh;
  107422. /**
  107423. * Creates a dashed line mesh
  107424. * * 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
  107425. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107426. * * The parameter `points` is an array successive Vector3
  107427. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107428. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107429. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107430. * * 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
  107431. * * When updating an instance, remember that only point positions can change, not the number of points
  107432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107433. * @param name defines the name of the mesh
  107434. * @param options defines the options used to create the mesh
  107435. * @param scene defines the hosting scene
  107436. * @returns the dashed line mesh
  107437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107438. */
  107439. static CreateDashedLines(name: string, options: {
  107440. points: Vector3[];
  107441. dashSize?: number;
  107442. gapSize?: number;
  107443. dashNb?: number;
  107444. updatable?: boolean;
  107445. instance?: LinesMesh;
  107446. }, scene?: Nullable<Scene>): LinesMesh;
  107447. /**
  107448. * 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.
  107449. * * 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.
  107450. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107451. * * 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.
  107452. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107453. * * 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
  107454. * * 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
  107455. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107460. * @param name defines the name of the mesh
  107461. * @param options defines the options used to create the mesh
  107462. * @param scene defines the hosting scene
  107463. * @returns the extruded shape mesh
  107464. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107466. */
  107467. static ExtrudeShape(name: string, options: {
  107468. shape: Vector3[];
  107469. path: Vector3[];
  107470. scale?: number;
  107471. rotation?: number;
  107472. cap?: number;
  107473. updatable?: boolean;
  107474. sideOrientation?: number;
  107475. frontUVs?: Vector4;
  107476. backUVs?: Vector4;
  107477. instance?: Mesh;
  107478. invertUV?: boolean;
  107479. }, scene?: Nullable<Scene>): Mesh;
  107480. /**
  107481. * Creates an custom extruded shape mesh.
  107482. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107483. * * 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.
  107484. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107485. * * 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
  107486. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107487. * * 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
  107488. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107489. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107490. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107491. * * 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
  107492. * * 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
  107493. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107498. * @param name defines the name of the mesh
  107499. * @param options defines the options used to create the mesh
  107500. * @param scene defines the hosting scene
  107501. * @returns the custom extruded shape mesh
  107502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107503. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107505. */
  107506. static ExtrudeShapeCustom(name: string, options: {
  107507. shape: Vector3[];
  107508. path: Vector3[];
  107509. scaleFunction?: any;
  107510. rotationFunction?: any;
  107511. ribbonCloseArray?: boolean;
  107512. ribbonClosePath?: boolean;
  107513. cap?: number;
  107514. updatable?: boolean;
  107515. sideOrientation?: number;
  107516. frontUVs?: Vector4;
  107517. backUVs?: Vector4;
  107518. instance?: Mesh;
  107519. invertUV?: boolean;
  107520. }, scene: Scene): Mesh;
  107521. /**
  107522. * Creates lathe mesh.
  107523. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107524. * * 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
  107525. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107526. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107527. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107528. * * 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
  107529. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107530. * * 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
  107531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107535. * @param name defines the name of the mesh
  107536. * @param options defines the options used to create the mesh
  107537. * @param scene defines the hosting scene
  107538. * @returns the lathe mesh
  107539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107540. */
  107541. static CreateLathe(name: string, options: {
  107542. shape: Vector3[];
  107543. radius?: number;
  107544. tessellation?: number;
  107545. clip?: number;
  107546. arc?: number;
  107547. closed?: boolean;
  107548. updatable?: boolean;
  107549. sideOrientation?: number;
  107550. frontUVs?: Vector4;
  107551. backUVs?: Vector4;
  107552. cap?: number;
  107553. invertUV?: boolean;
  107554. }, scene: Scene): Mesh;
  107555. /**
  107556. * Creates a plane mesh
  107557. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107558. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107559. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107561. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107563. * @param name defines the name of the mesh
  107564. * @param options defines the options used to create the mesh
  107565. * @param scene defines the hosting scene
  107566. * @returns the plane mesh
  107567. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107568. */
  107569. static CreatePlane(name: string, options: {
  107570. size?: number;
  107571. width?: number;
  107572. height?: number;
  107573. sideOrientation?: number;
  107574. frontUVs?: Vector4;
  107575. backUVs?: Vector4;
  107576. updatable?: boolean;
  107577. sourcePlane?: Plane;
  107578. }, scene: Scene): Mesh;
  107579. /**
  107580. * Creates a ground mesh
  107581. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107582. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107584. * @param name defines the name of the mesh
  107585. * @param options defines the options used to create the mesh
  107586. * @param scene defines the hosting scene
  107587. * @returns the ground mesh
  107588. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107589. */
  107590. static CreateGround(name: string, options: {
  107591. width?: number;
  107592. height?: number;
  107593. subdivisions?: number;
  107594. subdivisionsX?: number;
  107595. subdivisionsY?: number;
  107596. updatable?: boolean;
  107597. }, scene: any): Mesh;
  107598. /**
  107599. * Creates a tiled ground mesh
  107600. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107601. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107602. * * 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
  107603. * * 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
  107604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107605. * @param name defines the name of the mesh
  107606. * @param options defines the options used to create the mesh
  107607. * @param scene defines the hosting scene
  107608. * @returns the tiled ground mesh
  107609. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107610. */
  107611. static CreateTiledGround(name: string, options: {
  107612. xmin: number;
  107613. zmin: number;
  107614. xmax: number;
  107615. zmax: number;
  107616. subdivisions?: {
  107617. w: number;
  107618. h: number;
  107619. };
  107620. precision?: {
  107621. w: number;
  107622. h: number;
  107623. };
  107624. updatable?: boolean;
  107625. }, scene: Scene): Mesh;
  107626. /**
  107627. * Creates a ground mesh from a height map
  107628. * * The parameter `url` sets the URL of the height map image resource.
  107629. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107630. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107631. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107632. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107633. * * 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.
  107634. * * 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).
  107635. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107637. * @param name defines the name of the mesh
  107638. * @param url defines the url to the height map
  107639. * @param options defines the options used to create the mesh
  107640. * @param scene defines the hosting scene
  107641. * @returns the ground mesh
  107642. * @see https://doc.babylonjs.com/babylon101/height_map
  107643. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107644. */
  107645. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107646. width?: number;
  107647. height?: number;
  107648. subdivisions?: number;
  107649. minHeight?: number;
  107650. maxHeight?: number;
  107651. colorFilter?: Color3;
  107652. alphaFilter?: number;
  107653. updatable?: boolean;
  107654. onReady?: (mesh: GroundMesh) => void;
  107655. }, scene: Scene): GroundMesh;
  107656. /**
  107657. * Creates a polygon mesh
  107658. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  107659. * * 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
  107660. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  107663. * * Remember you can only change the shape positions, not their number when updating a polygon
  107664. * @param name defines the name of the mesh
  107665. * @param options defines the options used to create the mesh
  107666. * @param scene defines the hosting scene
  107667. * @param earcutInjection can be used to inject your own earcut reference
  107668. * @returns the polygon mesh
  107669. */
  107670. static CreatePolygon(name: string, options: {
  107671. shape: Vector3[];
  107672. holes?: Vector3[][];
  107673. depth?: number;
  107674. faceUV?: Vector4[];
  107675. faceColors?: Color4[];
  107676. updatable?: boolean;
  107677. sideOrientation?: number;
  107678. frontUVs?: Vector4;
  107679. backUVs?: Vector4;
  107680. }, scene: Scene, earcutInjection?: any): Mesh;
  107681. /**
  107682. * Creates an extruded polygon mesh, with depth in the Y direction.
  107683. * * 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)
  107684. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107685. * @param name defines the name of the mesh
  107686. * @param options defines the options used to create the mesh
  107687. * @param scene defines the hosting scene
  107688. * @param earcutInjection can be used to inject your own earcut reference
  107689. * @returns the polygon mesh
  107690. */
  107691. static ExtrudePolygon(name: string, options: {
  107692. shape: Vector3[];
  107693. holes?: Vector3[][];
  107694. depth?: number;
  107695. faceUV?: Vector4[];
  107696. faceColors?: Color4[];
  107697. updatable?: boolean;
  107698. sideOrientation?: number;
  107699. frontUVs?: Vector4;
  107700. backUVs?: Vector4;
  107701. }, scene: Scene, earcutInjection?: any): Mesh;
  107702. /**
  107703. * Creates a tube mesh.
  107704. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107705. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107706. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107707. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107708. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107709. * * 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)
  107710. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107711. * * 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
  107712. * * 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
  107713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107715. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107717. * @param name defines the name of the mesh
  107718. * @param options defines the options used to create the mesh
  107719. * @param scene defines the hosting scene
  107720. * @returns the tube mesh
  107721. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107722. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107723. */
  107724. static CreateTube(name: string, options: {
  107725. path: Vector3[];
  107726. radius?: number;
  107727. tessellation?: number;
  107728. radiusFunction?: {
  107729. (i: number, distance: number): number;
  107730. };
  107731. cap?: number;
  107732. arc?: number;
  107733. updatable?: boolean;
  107734. sideOrientation?: number;
  107735. frontUVs?: Vector4;
  107736. backUVs?: Vector4;
  107737. instance?: Mesh;
  107738. invertUV?: boolean;
  107739. }, scene: Scene): Mesh;
  107740. /**
  107741. * Creates a polyhedron mesh
  107742. * * 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
  107743. * * The parameter `size` (positive float, default 1) sets the polygon size
  107744. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107745. * * 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`
  107746. * * 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
  107747. * * 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)`)
  107748. * * 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
  107749. * * 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
  107750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107753. * @param name defines the name of the mesh
  107754. * @param options defines the options used to create the mesh
  107755. * @param scene defines the hosting scene
  107756. * @returns the polyhedron mesh
  107757. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107758. */
  107759. static CreatePolyhedron(name: string, options: {
  107760. type?: number;
  107761. size?: number;
  107762. sizeX?: number;
  107763. sizeY?: number;
  107764. sizeZ?: number;
  107765. custom?: any;
  107766. faceUV?: Vector4[];
  107767. faceColors?: Color4[];
  107768. flat?: boolean;
  107769. updatable?: boolean;
  107770. sideOrientation?: number;
  107771. frontUVs?: Vector4;
  107772. backUVs?: Vector4;
  107773. }, scene: Scene): Mesh;
  107774. /**
  107775. * Creates a decal mesh.
  107776. * 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
  107777. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107778. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107779. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107780. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107781. * @param name defines the name of the mesh
  107782. * @param sourceMesh defines the mesh where the decal must be applied
  107783. * @param options defines the options used to create the mesh
  107784. * @param scene defines the hosting scene
  107785. * @returns the decal mesh
  107786. * @see https://doc.babylonjs.com/how_to/decals
  107787. */
  107788. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107789. position?: Vector3;
  107790. normal?: Vector3;
  107791. size?: Vector3;
  107792. angle?: number;
  107793. }): Mesh;
  107794. }
  107795. }
  107796. declare module BABYLON {
  107797. /**
  107798. * A simplifier interface for future simplification implementations
  107799. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107800. */
  107801. export interface ISimplifier {
  107802. /**
  107803. * Simplification of a given mesh according to the given settings.
  107804. * Since this requires computation, it is assumed that the function runs async.
  107805. * @param settings The settings of the simplification, including quality and distance
  107806. * @param successCallback A callback that will be called after the mesh was simplified.
  107807. * @param errorCallback in case of an error, this callback will be called. optional.
  107808. */
  107809. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  107810. }
  107811. /**
  107812. * Expected simplification settings.
  107813. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  107814. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107815. */
  107816. export interface ISimplificationSettings {
  107817. /**
  107818. * Gets or sets the expected quality
  107819. */
  107820. quality: number;
  107821. /**
  107822. * Gets or sets the distance when this optimized version should be used
  107823. */
  107824. distance: number;
  107825. /**
  107826. * Gets an already optimized mesh
  107827. */
  107828. optimizeMesh?: boolean;
  107829. }
  107830. /**
  107831. * Class used to specify simplification options
  107832. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107833. */
  107834. export class SimplificationSettings implements ISimplificationSettings {
  107835. /** expected quality */
  107836. quality: number;
  107837. /** distance when this optimized version should be used */
  107838. distance: number;
  107839. /** already optimized mesh */
  107840. optimizeMesh?: boolean | undefined;
  107841. /**
  107842. * Creates a SimplificationSettings
  107843. * @param quality expected quality
  107844. * @param distance distance when this optimized version should be used
  107845. * @param optimizeMesh already optimized mesh
  107846. */
  107847. constructor(
  107848. /** expected quality */
  107849. quality: number,
  107850. /** distance when this optimized version should be used */
  107851. distance: number,
  107852. /** already optimized mesh */
  107853. optimizeMesh?: boolean | undefined);
  107854. }
  107855. /**
  107856. * Interface used to define a simplification task
  107857. */
  107858. export interface ISimplificationTask {
  107859. /**
  107860. * Array of settings
  107861. */
  107862. settings: Array<ISimplificationSettings>;
  107863. /**
  107864. * Simplification type
  107865. */
  107866. simplificationType: SimplificationType;
  107867. /**
  107868. * Mesh to simplify
  107869. */
  107870. mesh: Mesh;
  107871. /**
  107872. * Callback called on success
  107873. */
  107874. successCallback?: () => void;
  107875. /**
  107876. * Defines if parallel processing can be used
  107877. */
  107878. parallelProcessing: boolean;
  107879. }
  107880. /**
  107881. * Queue used to order the simplification tasks
  107882. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107883. */
  107884. export class SimplificationQueue {
  107885. private _simplificationArray;
  107886. /**
  107887. * Gets a boolean indicating that the process is still running
  107888. */
  107889. running: boolean;
  107890. /**
  107891. * Creates a new queue
  107892. */
  107893. constructor();
  107894. /**
  107895. * Adds a new simplification task
  107896. * @param task defines a task to add
  107897. */
  107898. addTask(task: ISimplificationTask): void;
  107899. /**
  107900. * Execute next task
  107901. */
  107902. executeNext(): void;
  107903. /**
  107904. * Execute a simplification task
  107905. * @param task defines the task to run
  107906. */
  107907. runSimplification(task: ISimplificationTask): void;
  107908. private getSimplifier;
  107909. }
  107910. /**
  107911. * The implemented types of simplification
  107912. * At the moment only Quadratic Error Decimation is implemented
  107913. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107914. */
  107915. export enum SimplificationType {
  107916. /** Quadratic error decimation */
  107917. QUADRATIC = 0
  107918. }
  107919. }
  107920. declare module BABYLON {
  107921. interface Scene {
  107922. /** @hidden (Backing field) */
  107923. _simplificationQueue: SimplificationQueue;
  107924. /**
  107925. * Gets or sets the simplification queue attached to the scene
  107926. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107927. */
  107928. simplificationQueue: SimplificationQueue;
  107929. }
  107930. interface Mesh {
  107931. /**
  107932. * Simplify the mesh according to the given array of settings.
  107933. * Function will return immediately and will simplify async
  107934. * @param settings a collection of simplification settings
  107935. * @param parallelProcessing should all levels calculate parallel or one after the other
  107936. * @param simplificationType the type of simplification to run
  107937. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  107938. * @returns the current mesh
  107939. */
  107940. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  107941. }
  107942. /**
  107943. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  107944. * created in a scene
  107945. */
  107946. export class SimplicationQueueSceneComponent implements ISceneComponent {
  107947. /**
  107948. * The component name helpfull to identify the component in the list of scene components.
  107949. */
  107950. readonly name: string;
  107951. /**
  107952. * The scene the component belongs to.
  107953. */
  107954. scene: Scene;
  107955. /**
  107956. * Creates a new instance of the component for the given scene
  107957. * @param scene Defines the scene to register the component in
  107958. */
  107959. constructor(scene: Scene);
  107960. /**
  107961. * Registers the component in a given scene
  107962. */
  107963. register(): void;
  107964. /**
  107965. * Rebuilds the elements related to this component in case of
  107966. * context lost for instance.
  107967. */
  107968. rebuild(): void;
  107969. /**
  107970. * Disposes the component and the associated ressources
  107971. */
  107972. dispose(): void;
  107973. private _beforeCameraUpdate;
  107974. }
  107975. }
  107976. declare module BABYLON {
  107977. /**
  107978. * Class used to enable access to IndexedDB
  107979. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  107980. */
  107981. export class Database implements IOfflineProvider {
  107982. private _callbackManifestChecked;
  107983. private _currentSceneUrl;
  107984. private _db;
  107985. private _enableSceneOffline;
  107986. private _enableTexturesOffline;
  107987. private _manifestVersionFound;
  107988. private _mustUpdateRessources;
  107989. private _hasReachedQuota;
  107990. private _isSupported;
  107991. private _idbFactory;
  107992. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  107993. private static IsUASupportingBlobStorage;
  107994. /**
  107995. * Gets a boolean indicating if Database storate is enabled (off by default)
  107996. */
  107997. static IDBStorageEnabled: boolean;
  107998. /**
  107999. * Gets a boolean indicating if scene must be saved in the database
  108000. */
  108001. readonly enableSceneOffline: boolean;
  108002. /**
  108003. * Gets a boolean indicating if textures must be saved in the database
  108004. */
  108005. readonly enableTexturesOffline: boolean;
  108006. /**
  108007. * Creates a new Database
  108008. * @param urlToScene defines the url to load the scene
  108009. * @param callbackManifestChecked defines the callback to use when manifest is checked
  108010. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  108011. */
  108012. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  108013. private static _ParseURL;
  108014. private static _ReturnFullUrlLocation;
  108015. private _checkManifestFile;
  108016. /**
  108017. * Open the database and make it available
  108018. * @param successCallback defines the callback to call on success
  108019. * @param errorCallback defines the callback to call on error
  108020. */
  108021. open(successCallback: () => void, errorCallback: () => void): void;
  108022. /**
  108023. * Loads an image from the database
  108024. * @param url defines the url to load from
  108025. * @param image defines the target DOM image
  108026. */
  108027. loadImage(url: string, image: HTMLImageElement): void;
  108028. private _loadImageFromDBAsync;
  108029. private _saveImageIntoDBAsync;
  108030. private _checkVersionFromDB;
  108031. private _loadVersionFromDBAsync;
  108032. private _saveVersionIntoDBAsync;
  108033. /**
  108034. * Loads a file from database
  108035. * @param url defines the URL to load from
  108036. * @param sceneLoaded defines a callback to call on success
  108037. * @param progressCallBack defines a callback to call when progress changed
  108038. * @param errorCallback defines a callback to call on error
  108039. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  108040. */
  108041. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  108042. private _loadFileAsync;
  108043. private _saveFileAsync;
  108044. /**
  108045. * Validates if xhr data is correct
  108046. * @param xhr defines the request to validate
  108047. * @param dataType defines the expected data type
  108048. * @returns true if data is correct
  108049. */
  108050. private static _ValidateXHRData;
  108051. }
  108052. }
  108053. declare module BABYLON {
  108054. /** @hidden */
  108055. export var gpuUpdateParticlesPixelShader: {
  108056. name: string;
  108057. shader: string;
  108058. };
  108059. }
  108060. declare module BABYLON {
  108061. /** @hidden */
  108062. export var gpuUpdateParticlesVertexShader: {
  108063. name: string;
  108064. shader: string;
  108065. };
  108066. }
  108067. declare module BABYLON {
  108068. /** @hidden */
  108069. export var clipPlaneFragmentDeclaration2: {
  108070. name: string;
  108071. shader: string;
  108072. };
  108073. }
  108074. declare module BABYLON {
  108075. /** @hidden */
  108076. export var gpuRenderParticlesPixelShader: {
  108077. name: string;
  108078. shader: string;
  108079. };
  108080. }
  108081. declare module BABYLON {
  108082. /** @hidden */
  108083. export var clipPlaneVertexDeclaration2: {
  108084. name: string;
  108085. shader: string;
  108086. };
  108087. }
  108088. declare module BABYLON {
  108089. /** @hidden */
  108090. export var gpuRenderParticlesVertexShader: {
  108091. name: string;
  108092. shader: string;
  108093. };
  108094. }
  108095. declare module BABYLON {
  108096. /**
  108097. * This represents a GPU particle system in Babylon
  108098. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108099. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108100. */
  108101. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  108102. /**
  108103. * The layer mask we are rendering the particles through.
  108104. */
  108105. layerMask: number;
  108106. private _capacity;
  108107. private _activeCount;
  108108. private _currentActiveCount;
  108109. private _accumulatedCount;
  108110. private _renderEffect;
  108111. private _updateEffect;
  108112. private _buffer0;
  108113. private _buffer1;
  108114. private _spriteBuffer;
  108115. private _updateVAO;
  108116. private _renderVAO;
  108117. private _targetIndex;
  108118. private _sourceBuffer;
  108119. private _targetBuffer;
  108120. private _engine;
  108121. private _currentRenderId;
  108122. private _started;
  108123. private _stopped;
  108124. private _timeDelta;
  108125. private _randomTexture;
  108126. private _randomTexture2;
  108127. private _attributesStrideSize;
  108128. private _updateEffectOptions;
  108129. private _randomTextureSize;
  108130. private _actualFrame;
  108131. private readonly _rawTextureWidth;
  108132. /**
  108133. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108134. */
  108135. static readonly IsSupported: boolean;
  108136. /**
  108137. * An event triggered when the system is disposed.
  108138. */
  108139. onDisposeObservable: Observable<GPUParticleSystem>;
  108140. /**
  108141. * Gets the maximum number of particles active at the same time.
  108142. * @returns The max number of active particles.
  108143. */
  108144. getCapacity(): number;
  108145. /**
  108146. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108147. * to override the particles.
  108148. */
  108149. forceDepthWrite: boolean;
  108150. /**
  108151. * Gets or set the number of active particles
  108152. */
  108153. activeParticleCount: number;
  108154. private _preWarmDone;
  108155. /**
  108156. * Is this system ready to be used/rendered
  108157. * @return true if the system is ready
  108158. */
  108159. isReady(): boolean;
  108160. /**
  108161. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108162. * @returns True if it has been started, otherwise false.
  108163. */
  108164. isStarted(): boolean;
  108165. /**
  108166. * Starts the particle system and begins to emit
  108167. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108168. */
  108169. start(delay?: number): void;
  108170. /**
  108171. * Stops the particle system.
  108172. */
  108173. stop(): void;
  108174. /**
  108175. * Remove all active particles
  108176. */
  108177. reset(): void;
  108178. /**
  108179. * Returns the string "GPUParticleSystem"
  108180. * @returns a string containing the class name
  108181. */
  108182. getClassName(): string;
  108183. private _colorGradientsTexture;
  108184. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  108185. /**
  108186. * Adds a new color gradient
  108187. * @param gradient defines the gradient to use (between 0 and 1)
  108188. * @param color1 defines the color to affect to the specified gradient
  108189. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108190. * @returns the current particle system
  108191. */
  108192. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  108193. /**
  108194. * Remove a specific color gradient
  108195. * @param gradient defines the gradient to remove
  108196. * @returns the current particle system
  108197. */
  108198. removeColorGradient(gradient: number): GPUParticleSystem;
  108199. private _angularSpeedGradientsTexture;
  108200. private _sizeGradientsTexture;
  108201. private _velocityGradientsTexture;
  108202. private _limitVelocityGradientsTexture;
  108203. private _dragGradientsTexture;
  108204. private _addFactorGradient;
  108205. /**
  108206. * Adds a new size gradient
  108207. * @param gradient defines the gradient to use (between 0 and 1)
  108208. * @param factor defines the size factor to affect to the specified gradient
  108209. * @returns the current particle system
  108210. */
  108211. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  108212. /**
  108213. * Remove a specific size gradient
  108214. * @param gradient defines the gradient to remove
  108215. * @returns the current particle system
  108216. */
  108217. removeSizeGradient(gradient: number): GPUParticleSystem;
  108218. /**
  108219. * Adds a new angular speed gradient
  108220. * @param gradient defines the gradient to use (between 0 and 1)
  108221. * @param factor defines the angular speed to affect to the specified gradient
  108222. * @returns the current particle system
  108223. */
  108224. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  108225. /**
  108226. * Remove a specific angular speed gradient
  108227. * @param gradient defines the gradient to remove
  108228. * @returns the current particle system
  108229. */
  108230. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  108231. /**
  108232. * Adds a new velocity gradient
  108233. * @param gradient defines the gradient to use (between 0 and 1)
  108234. * @param factor defines the velocity to affect to the specified gradient
  108235. * @returns the current particle system
  108236. */
  108237. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108238. /**
  108239. * Remove a specific velocity gradient
  108240. * @param gradient defines the gradient to remove
  108241. * @returns the current particle system
  108242. */
  108243. removeVelocityGradient(gradient: number): GPUParticleSystem;
  108244. /**
  108245. * Adds a new limit velocity gradient
  108246. * @param gradient defines the gradient to use (between 0 and 1)
  108247. * @param factor defines the limit velocity value to affect to the specified gradient
  108248. * @returns the current particle system
  108249. */
  108250. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108251. /**
  108252. * Remove a specific limit velocity gradient
  108253. * @param gradient defines the gradient to remove
  108254. * @returns the current particle system
  108255. */
  108256. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  108257. /**
  108258. * Adds a new drag gradient
  108259. * @param gradient defines the gradient to use (between 0 and 1)
  108260. * @param factor defines the drag value to affect to the specified gradient
  108261. * @returns the current particle system
  108262. */
  108263. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  108264. /**
  108265. * Remove a specific drag gradient
  108266. * @param gradient defines the gradient to remove
  108267. * @returns the current particle system
  108268. */
  108269. removeDragGradient(gradient: number): GPUParticleSystem;
  108270. /**
  108271. * Not supported by GPUParticleSystem
  108272. * @param gradient defines the gradient to use (between 0 and 1)
  108273. * @param factor defines the emit rate value to affect to the specified gradient
  108274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108275. * @returns the current particle system
  108276. */
  108277. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108278. /**
  108279. * Not supported by GPUParticleSystem
  108280. * @param gradient defines the gradient to remove
  108281. * @returns the current particle system
  108282. */
  108283. removeEmitRateGradient(gradient: number): IParticleSystem;
  108284. /**
  108285. * Not supported by GPUParticleSystem
  108286. * @param gradient defines the gradient to use (between 0 and 1)
  108287. * @param factor defines the start size value to affect to the specified gradient
  108288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108289. * @returns the current particle system
  108290. */
  108291. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108292. /**
  108293. * Not supported by GPUParticleSystem
  108294. * @param gradient defines the gradient to remove
  108295. * @returns the current particle system
  108296. */
  108297. removeStartSizeGradient(gradient: number): IParticleSystem;
  108298. /**
  108299. * Not supported by GPUParticleSystem
  108300. * @param gradient defines the gradient to use (between 0 and 1)
  108301. * @param min defines the color remap minimal range
  108302. * @param max defines the color remap maximal range
  108303. * @returns the current particle system
  108304. */
  108305. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108306. /**
  108307. * Not supported by GPUParticleSystem
  108308. * @param gradient defines the gradient to remove
  108309. * @returns the current particle system
  108310. */
  108311. removeColorRemapGradient(): IParticleSystem;
  108312. /**
  108313. * Not supported by GPUParticleSystem
  108314. * @param gradient defines the gradient to use (between 0 and 1)
  108315. * @param min defines the alpha remap minimal range
  108316. * @param max defines the alpha remap maximal range
  108317. * @returns the current particle system
  108318. */
  108319. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108320. /**
  108321. * Not supported by GPUParticleSystem
  108322. * @param gradient defines the gradient to remove
  108323. * @returns the current particle system
  108324. */
  108325. removeAlphaRemapGradient(): IParticleSystem;
  108326. /**
  108327. * Not supported by GPUParticleSystem
  108328. * @param gradient defines the gradient to use (between 0 and 1)
  108329. * @param color defines the color to affect to the specified gradient
  108330. * @returns the current particle system
  108331. */
  108332. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  108333. /**
  108334. * Not supported by GPUParticleSystem
  108335. * @param gradient defines the gradient to remove
  108336. * @returns the current particle system
  108337. */
  108338. removeRampGradient(): IParticleSystem;
  108339. /**
  108340. * Not supported by GPUParticleSystem
  108341. * @returns the list of ramp gradients
  108342. */
  108343. getRampGradients(): Nullable<Array<Color3Gradient>>;
  108344. /**
  108345. * Not supported by GPUParticleSystem
  108346. * Gets or sets a boolean indicating that ramp gradients must be used
  108347. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108348. */
  108349. useRampGradients: boolean;
  108350. /**
  108351. * Not supported by GPUParticleSystem
  108352. * @param gradient defines the gradient to use (between 0 and 1)
  108353. * @param factor defines the life time factor to affect to the specified gradient
  108354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108355. * @returns the current particle system
  108356. */
  108357. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108358. /**
  108359. * Not supported by GPUParticleSystem
  108360. * @param gradient defines the gradient to remove
  108361. * @returns the current particle system
  108362. */
  108363. removeLifeTimeGradient(gradient: number): IParticleSystem;
  108364. /**
  108365. * Instantiates a GPU particle system.
  108366. * 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.
  108367. * @param name The name of the particle system
  108368. * @param options The options used to create the system
  108369. * @param scene The scene the particle system belongs to
  108370. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108371. */
  108372. constructor(name: string, options: Partial<{
  108373. capacity: number;
  108374. randomTextureSize: number;
  108375. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  108376. protected _reset(): void;
  108377. private _createUpdateVAO;
  108378. private _createRenderVAO;
  108379. private _initialize;
  108380. /** @hidden */
  108381. _recreateUpdateEffect(): void;
  108382. /** @hidden */
  108383. _recreateRenderEffect(): void;
  108384. /**
  108385. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108386. * @param preWarm defines if we are in the pre-warmimg phase
  108387. */
  108388. animate(preWarm?: boolean): void;
  108389. private _createFactorGradientTexture;
  108390. private _createSizeGradientTexture;
  108391. private _createAngularSpeedGradientTexture;
  108392. private _createVelocityGradientTexture;
  108393. private _createLimitVelocityGradientTexture;
  108394. private _createDragGradientTexture;
  108395. private _createColorGradientTexture;
  108396. /**
  108397. * Renders the particle system in its current state
  108398. * @param preWarm defines if the system should only update the particles but not render them
  108399. * @returns the current number of particles
  108400. */
  108401. render(preWarm?: boolean): number;
  108402. /**
  108403. * Rebuilds the particle system
  108404. */
  108405. rebuild(): void;
  108406. private _releaseBuffers;
  108407. private _releaseVAOs;
  108408. /**
  108409. * Disposes the particle system and free the associated resources
  108410. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108411. */
  108412. dispose(disposeTexture?: boolean): void;
  108413. /**
  108414. * Clones the particle system.
  108415. * @param name The name of the cloned object
  108416. * @param newEmitter The new emitter to use
  108417. * @returns the cloned particle system
  108418. */
  108419. clone(name: string, newEmitter: any): GPUParticleSystem;
  108420. /**
  108421. * Serializes the particle system to a JSON object.
  108422. * @returns the JSON object
  108423. */
  108424. serialize(): any;
  108425. /**
  108426. * Parses a JSON object to create a GPU particle system.
  108427. * @param parsedParticleSystem The JSON object to parse
  108428. * @param scene The scene to create the particle system in
  108429. * @param rootUrl The root url to use to load external dependencies like texture
  108430. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108431. * @returns the parsed GPU particle system
  108432. */
  108433. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  108434. }
  108435. }
  108436. declare module BABYLON {
  108437. /**
  108438. * Represents a set of particle systems working together to create a specific effect
  108439. */
  108440. export class ParticleSystemSet implements IDisposable {
  108441. private _emitterCreationOptions;
  108442. private _emitterNode;
  108443. /**
  108444. * Gets the particle system list
  108445. */
  108446. systems: IParticleSystem[];
  108447. /**
  108448. * Gets the emitter node used with this set
  108449. */
  108450. readonly emitterNode: Nullable<TransformNode>;
  108451. /**
  108452. * Creates a new emitter mesh as a sphere
  108453. * @param options defines the options used to create the sphere
  108454. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  108455. * @param scene defines the hosting scene
  108456. */
  108457. setEmitterAsSphere(options: {
  108458. diameter: number;
  108459. segments: number;
  108460. color: Color3;
  108461. }, renderingGroupId: number, scene: Scene): void;
  108462. /**
  108463. * Starts all particle systems of the set
  108464. * @param emitter defines an optional mesh to use as emitter for the particle systems
  108465. */
  108466. start(emitter?: AbstractMesh): void;
  108467. /**
  108468. * Release all associated resources
  108469. */
  108470. dispose(): void;
  108471. /**
  108472. * Serialize the set into a JSON compatible object
  108473. * @returns a JSON compatible representation of the set
  108474. */
  108475. serialize(): any;
  108476. /**
  108477. * Parse a new ParticleSystemSet from a serialized source
  108478. * @param data defines a JSON compatible representation of the set
  108479. * @param scene defines the hosting scene
  108480. * @param gpu defines if we want GPU particles or CPU particles
  108481. * @returns a new ParticleSystemSet
  108482. */
  108483. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  108484. }
  108485. }
  108486. declare module BABYLON {
  108487. /**
  108488. * This class is made for on one-liner static method to help creating particle system set.
  108489. */
  108490. export class ParticleHelper {
  108491. /**
  108492. * Gets or sets base Assets URL
  108493. */
  108494. static BaseAssetsUrl: string;
  108495. /**
  108496. * Create a default particle system that you can tweak
  108497. * @param emitter defines the emitter to use
  108498. * @param capacity defines the system capacity (default is 500 particles)
  108499. * @param scene defines the hosting scene
  108500. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108501. * @returns the new Particle system
  108502. */
  108503. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  108504. /**
  108505. * This is the main static method (one-liner) of this helper to create different particle systems
  108506. * @param type This string represents the type to the particle system to create
  108507. * @param scene The scene where the particle system should live
  108508. * @param gpu If the system will use gpu
  108509. * @returns the ParticleSystemSet created
  108510. */
  108511. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  108512. /**
  108513. * Static function used to export a particle system to a ParticleSystemSet variable.
  108514. * Please note that the emitter shape is not exported
  108515. * @param systems defines the particle systems to export
  108516. * @returns the created particle system set
  108517. */
  108518. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  108519. }
  108520. }
  108521. declare module BABYLON {
  108522. interface Engine {
  108523. /**
  108524. * Create an effect to use with particle systems.
  108525. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  108526. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  108527. * @param uniformsNames defines a list of attribute names
  108528. * @param samplers defines an array of string used to represent textures
  108529. * @param defines defines the string containing the defines to use to compile the shaders
  108530. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108531. * @param onCompiled defines a function to call when the effect creation is successful
  108532. * @param onError defines a function to call when the effect creation has failed
  108533. * @returns the new Effect
  108534. */
  108535. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  108536. }
  108537. interface Mesh {
  108538. /**
  108539. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  108540. * @returns an array of IParticleSystem
  108541. */
  108542. getEmittedParticleSystems(): IParticleSystem[];
  108543. /**
  108544. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  108545. * @returns an array of IParticleSystem
  108546. */
  108547. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  108548. }
  108549. /**
  108550. * @hidden
  108551. */
  108552. export var _IDoNeedToBeInTheBuild: number;
  108553. }
  108554. declare module BABYLON {
  108555. interface Scene {
  108556. /** @hidden (Backing field) */
  108557. _physicsEngine: Nullable<IPhysicsEngine>;
  108558. /**
  108559. * Gets the current physics engine
  108560. * @returns a IPhysicsEngine or null if none attached
  108561. */
  108562. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  108563. /**
  108564. * Enables physics to the current scene
  108565. * @param gravity defines the scene's gravity for the physics engine
  108566. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  108567. * @return a boolean indicating if the physics engine was initialized
  108568. */
  108569. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  108570. /**
  108571. * Disables and disposes the physics engine associated with the scene
  108572. */
  108573. disablePhysicsEngine(): void;
  108574. /**
  108575. * Gets a boolean indicating if there is an active physics engine
  108576. * @returns a boolean indicating if there is an active physics engine
  108577. */
  108578. isPhysicsEnabled(): boolean;
  108579. /**
  108580. * Deletes a physics compound impostor
  108581. * @param compound defines the compound to delete
  108582. */
  108583. deleteCompoundImpostor(compound: any): void;
  108584. /**
  108585. * An event triggered when physic simulation is about to be run
  108586. */
  108587. onBeforePhysicsObservable: Observable<Scene>;
  108588. /**
  108589. * An event triggered when physic simulation has been done
  108590. */
  108591. onAfterPhysicsObservable: Observable<Scene>;
  108592. }
  108593. interface AbstractMesh {
  108594. /** @hidden */
  108595. _physicsImpostor: Nullable<PhysicsImpostor>;
  108596. /**
  108597. * Gets or sets impostor used for physic simulation
  108598. * @see http://doc.babylonjs.com/features/physics_engine
  108599. */
  108600. physicsImpostor: Nullable<PhysicsImpostor>;
  108601. /**
  108602. * Gets the current physics impostor
  108603. * @see http://doc.babylonjs.com/features/physics_engine
  108604. * @returns a physics impostor or null
  108605. */
  108606. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  108607. /** Apply a physic impulse to the mesh
  108608. * @param force defines the force to apply
  108609. * @param contactPoint defines where to apply the force
  108610. * @returns the current mesh
  108611. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108612. */
  108613. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  108614. /**
  108615. * Creates a physic joint between two meshes
  108616. * @param otherMesh defines the other mesh to use
  108617. * @param pivot1 defines the pivot to use on this mesh
  108618. * @param pivot2 defines the pivot to use on the other mesh
  108619. * @param options defines additional options (can be plugin dependent)
  108620. * @returns the current mesh
  108621. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  108622. */
  108623. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  108624. /** @hidden */
  108625. _disposePhysicsObserver: Nullable<Observer<Node>>;
  108626. }
  108627. /**
  108628. * Defines the physics engine scene component responsible to manage a physics engine
  108629. */
  108630. export class PhysicsEngineSceneComponent implements ISceneComponent {
  108631. /**
  108632. * The component name helpful to identify the component in the list of scene components.
  108633. */
  108634. readonly name: string;
  108635. /**
  108636. * The scene the component belongs to.
  108637. */
  108638. scene: Scene;
  108639. /**
  108640. * Creates a new instance of the component for the given scene
  108641. * @param scene Defines the scene to register the component in
  108642. */
  108643. constructor(scene: Scene);
  108644. /**
  108645. * Registers the component in a given scene
  108646. */
  108647. register(): void;
  108648. /**
  108649. * Rebuilds the elements related to this component in case of
  108650. * context lost for instance.
  108651. */
  108652. rebuild(): void;
  108653. /**
  108654. * Disposes the component and the associated ressources
  108655. */
  108656. dispose(): void;
  108657. }
  108658. }
  108659. declare module BABYLON {
  108660. /**
  108661. * A helper for physics simulations
  108662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108663. */
  108664. export class PhysicsHelper {
  108665. private _scene;
  108666. private _physicsEngine;
  108667. /**
  108668. * Initializes the Physics helper
  108669. * @param scene Babylon.js scene
  108670. */
  108671. constructor(scene: Scene);
  108672. /**
  108673. * Applies a radial explosion impulse
  108674. * @param origin the origin of the explosion
  108675. * @param radiusOrEventOptions the radius or the options of radial explosion
  108676. * @param strength the explosion strength
  108677. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108678. * @returns A physics radial explosion event, or null
  108679. */
  108680. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108681. /**
  108682. * Applies a radial explosion force
  108683. * @param origin the origin of the explosion
  108684. * @param radiusOrEventOptions the radius or the options of radial explosion
  108685. * @param strength the explosion strength
  108686. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108687. * @returns A physics radial explosion event, or null
  108688. */
  108689. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108690. /**
  108691. * Creates a gravitational field
  108692. * @param origin the origin of the explosion
  108693. * @param radiusOrEventOptions the radius or the options of radial explosion
  108694. * @param strength the explosion strength
  108695. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108696. * @returns A physics gravitational field event, or null
  108697. */
  108698. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  108699. /**
  108700. * Creates a physics updraft event
  108701. * @param origin the origin of the updraft
  108702. * @param radiusOrEventOptions the radius or the options of the updraft
  108703. * @param strength the strength of the updraft
  108704. * @param height the height of the updraft
  108705. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  108706. * @returns A physics updraft event, or null
  108707. */
  108708. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  108709. /**
  108710. * Creates a physics vortex event
  108711. * @param origin the of the vortex
  108712. * @param radiusOrEventOptions the radius or the options of the vortex
  108713. * @param strength the strength of the vortex
  108714. * @param height the height of the vortex
  108715. * @returns a Physics vortex event, or null
  108716. * A physics vortex event or null
  108717. */
  108718. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  108719. }
  108720. /**
  108721. * Represents a physics radial explosion event
  108722. */
  108723. class PhysicsRadialExplosionEvent {
  108724. private _scene;
  108725. private _options;
  108726. private _sphere;
  108727. private _dataFetched;
  108728. /**
  108729. * Initializes a radial explosioin event
  108730. * @param _scene BabylonJS scene
  108731. * @param _options The options for the vortex event
  108732. */
  108733. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  108734. /**
  108735. * Returns the data related to the radial explosion event (sphere).
  108736. * @returns The radial explosion event data
  108737. */
  108738. getData(): PhysicsRadialExplosionEventData;
  108739. /**
  108740. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  108741. * @param impostor A physics imposter
  108742. * @param origin the origin of the explosion
  108743. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  108744. */
  108745. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  108746. /**
  108747. * Disposes the sphere.
  108748. * @param force Specifies if the sphere should be disposed by force
  108749. */
  108750. dispose(force?: boolean): void;
  108751. /*** Helpers ***/
  108752. private _prepareSphere;
  108753. private _intersectsWithSphere;
  108754. }
  108755. /**
  108756. * Represents a gravitational field event
  108757. */
  108758. class PhysicsGravitationalFieldEvent {
  108759. private _physicsHelper;
  108760. private _scene;
  108761. private _origin;
  108762. private _options;
  108763. private _tickCallback;
  108764. private _sphere;
  108765. private _dataFetched;
  108766. /**
  108767. * Initializes the physics gravitational field event
  108768. * @param _physicsHelper A physics helper
  108769. * @param _scene BabylonJS scene
  108770. * @param _origin The origin position of the gravitational field event
  108771. * @param _options The options for the vortex event
  108772. */
  108773. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  108774. /**
  108775. * Returns the data related to the gravitational field event (sphere).
  108776. * @returns A gravitational field event
  108777. */
  108778. getData(): PhysicsGravitationalFieldEventData;
  108779. /**
  108780. * Enables the gravitational field.
  108781. */
  108782. enable(): void;
  108783. /**
  108784. * Disables the gravitational field.
  108785. */
  108786. disable(): void;
  108787. /**
  108788. * Disposes the sphere.
  108789. * @param force The force to dispose from the gravitational field event
  108790. */
  108791. dispose(force?: boolean): void;
  108792. private _tick;
  108793. }
  108794. /**
  108795. * Represents a physics updraft event
  108796. */
  108797. class PhysicsUpdraftEvent {
  108798. private _scene;
  108799. private _origin;
  108800. private _options;
  108801. private _physicsEngine;
  108802. private _originTop;
  108803. private _originDirection;
  108804. private _tickCallback;
  108805. private _cylinder;
  108806. private _cylinderPosition;
  108807. private _dataFetched;
  108808. /**
  108809. * Initializes the physics updraft event
  108810. * @param _scene BabylonJS scene
  108811. * @param _origin The origin position of the updraft
  108812. * @param _options The options for the updraft event
  108813. */
  108814. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  108815. /**
  108816. * Returns the data related to the updraft event (cylinder).
  108817. * @returns A physics updraft event
  108818. */
  108819. getData(): PhysicsUpdraftEventData;
  108820. /**
  108821. * Enables the updraft.
  108822. */
  108823. enable(): void;
  108824. /**
  108825. * Disables the updraft.
  108826. */
  108827. disable(): void;
  108828. /**
  108829. * Disposes the cylinder.
  108830. * @param force Specifies if the updraft should be disposed by force
  108831. */
  108832. dispose(force?: boolean): void;
  108833. private getImpostorForceAndContactPoint;
  108834. private _tick;
  108835. /*** Helpers ***/
  108836. private _prepareCylinder;
  108837. private _intersectsWithCylinder;
  108838. }
  108839. /**
  108840. * Represents a physics vortex event
  108841. */
  108842. class PhysicsVortexEvent {
  108843. private _scene;
  108844. private _origin;
  108845. private _options;
  108846. private _physicsEngine;
  108847. private _originTop;
  108848. private _tickCallback;
  108849. private _cylinder;
  108850. private _cylinderPosition;
  108851. private _dataFetched;
  108852. /**
  108853. * Initializes the physics vortex event
  108854. * @param _scene The BabylonJS scene
  108855. * @param _origin The origin position of the vortex
  108856. * @param _options The options for the vortex event
  108857. */
  108858. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  108859. /**
  108860. * Returns the data related to the vortex event (cylinder).
  108861. * @returns The physics vortex event data
  108862. */
  108863. getData(): PhysicsVortexEventData;
  108864. /**
  108865. * Enables the vortex.
  108866. */
  108867. enable(): void;
  108868. /**
  108869. * Disables the cortex.
  108870. */
  108871. disable(): void;
  108872. /**
  108873. * Disposes the sphere.
  108874. * @param force
  108875. */
  108876. dispose(force?: boolean): void;
  108877. private getImpostorForceAndContactPoint;
  108878. private _tick;
  108879. /*** Helpers ***/
  108880. private _prepareCylinder;
  108881. private _intersectsWithCylinder;
  108882. }
  108883. /**
  108884. * Options fot the radial explosion event
  108885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108886. */
  108887. export class PhysicsRadialExplosionEventOptions {
  108888. /**
  108889. * The radius of the sphere for the radial explosion.
  108890. */
  108891. radius: number;
  108892. /**
  108893. * The strenth of the explosion.
  108894. */
  108895. strength: number;
  108896. /**
  108897. * The strenght of the force in correspondence to the distance of the affected object
  108898. */
  108899. falloff: PhysicsRadialImpulseFalloff;
  108900. /**
  108901. * Sphere options for the radial explosion.
  108902. */
  108903. sphere: {
  108904. segments: number;
  108905. diameter: number;
  108906. };
  108907. }
  108908. /**
  108909. * Options fot the updraft event
  108910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108911. */
  108912. export class PhysicsUpdraftEventOptions {
  108913. /**
  108914. * The radius of the cylinder for the vortex
  108915. */
  108916. radius: number;
  108917. /**
  108918. * The strenth of the updraft.
  108919. */
  108920. strength: number;
  108921. /**
  108922. * The height of the cylinder for the updraft.
  108923. */
  108924. height: number;
  108925. /**
  108926. * The mode for the the updraft.
  108927. */
  108928. updraftMode: PhysicsUpdraftMode;
  108929. }
  108930. /**
  108931. * Options fot the vortex event
  108932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108933. */
  108934. export class PhysicsVortexEventOptions {
  108935. /**
  108936. * The radius of the cylinder for the vortex
  108937. */
  108938. radius: number;
  108939. /**
  108940. * The strenth of the vortex.
  108941. */
  108942. strength: number;
  108943. /**
  108944. * The height of the cylinder for the vortex.
  108945. */
  108946. height: number;
  108947. /**
  108948. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  108949. */
  108950. centripetalForceThreshold: number;
  108951. /**
  108952. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  108953. */
  108954. centripetalForceMultiplier: number;
  108955. /**
  108956. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  108957. */
  108958. centrifugalForceMultiplier: number;
  108959. /**
  108960. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  108961. */
  108962. updraftForceMultiplier: number;
  108963. }
  108964. /**
  108965. * The strenght of the force in correspondence to the distance of the affected object
  108966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108967. */
  108968. export enum PhysicsRadialImpulseFalloff {
  108969. /** Defines that impulse is constant in strength across it's whole radius */
  108970. Constant = 0,
  108971. /** Defines that impulse gets weaker if it's further from the origin */
  108972. Linear = 1
  108973. }
  108974. /**
  108975. * The strength of the force in correspondence to the distance of the affected object
  108976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108977. */
  108978. export enum PhysicsUpdraftMode {
  108979. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  108980. Center = 0,
  108981. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  108982. Perpendicular = 1
  108983. }
  108984. /**
  108985. * Interface for a physics force and contact point
  108986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108987. */
  108988. export interface PhysicsForceAndContactPoint {
  108989. /**
  108990. * The force applied at the contact point
  108991. */
  108992. force: Vector3;
  108993. /**
  108994. * The contact point
  108995. */
  108996. contactPoint: Vector3;
  108997. }
  108998. /**
  108999. * Interface for radial explosion event data
  109000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109001. */
  109002. export interface PhysicsRadialExplosionEventData {
  109003. /**
  109004. * A sphere used for the radial explosion event
  109005. */
  109006. sphere: Mesh;
  109007. }
  109008. /**
  109009. * Interface for gravitational field event data
  109010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109011. */
  109012. export interface PhysicsGravitationalFieldEventData {
  109013. /**
  109014. * A sphere mesh used for the gravitational field event
  109015. */
  109016. sphere: Mesh;
  109017. }
  109018. /**
  109019. * Interface for updraft event data
  109020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109021. */
  109022. export interface PhysicsUpdraftEventData {
  109023. /**
  109024. * A cylinder used for the updraft event
  109025. */
  109026. cylinder: Mesh;
  109027. }
  109028. /**
  109029. * Interface for vortex event data
  109030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109031. */
  109032. export interface PhysicsVortexEventData {
  109033. /**
  109034. * A cylinder used for the vortex event
  109035. */
  109036. cylinder: Mesh;
  109037. }
  109038. }
  109039. declare module BABYLON {
  109040. /**
  109041. * AmmoJS Physics plugin
  109042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109043. * @see https://github.com/kripken/ammo.js/
  109044. */
  109045. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  109046. private _useDeltaForWorldStep;
  109047. /**
  109048. * Reference to the Ammo library
  109049. */
  109050. bjsAMMO: any;
  109051. /**
  109052. * Created ammoJS world which physics bodies are added to
  109053. */
  109054. world: any;
  109055. /**
  109056. * Name of the plugin
  109057. */
  109058. name: string;
  109059. private _timeStep;
  109060. private _fixedTimeStep;
  109061. private _maxSteps;
  109062. private _tmpQuaternion;
  109063. private _tmpAmmoTransform;
  109064. private _tmpAmmoQuaternion;
  109065. private _tmpAmmoConcreteContactResultCallback;
  109066. private _collisionConfiguration;
  109067. private _dispatcher;
  109068. private _overlappingPairCache;
  109069. private _solver;
  109070. private _softBodySolver;
  109071. private _tmpAmmoVectorA;
  109072. private _tmpAmmoVectorB;
  109073. private _tmpAmmoVectorC;
  109074. private _tmpAmmoVectorD;
  109075. private _tmpContactCallbackResult;
  109076. private _tmpAmmoVectorRCA;
  109077. private _tmpAmmoVectorRCB;
  109078. private _raycastResult;
  109079. private static readonly DISABLE_COLLISION_FLAG;
  109080. private static readonly KINEMATIC_FLAG;
  109081. private static readonly DISABLE_DEACTIVATION_FLAG;
  109082. /**
  109083. * Initializes the ammoJS plugin
  109084. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109085. * @param ammoInjection can be used to inject your own ammo reference
  109086. */
  109087. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  109088. /**
  109089. * Sets the gravity of the physics world (m/(s^2))
  109090. * @param gravity Gravity to set
  109091. */
  109092. setGravity(gravity: Vector3): void;
  109093. /**
  109094. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109095. * @param timeStep timestep to use in seconds
  109096. */
  109097. setTimeStep(timeStep: number): void;
  109098. /**
  109099. * 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)
  109100. * @param fixedTimeStep fixedTimeStep to use in seconds
  109101. */
  109102. setFixedTimeStep(fixedTimeStep: number): void;
  109103. /**
  109104. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109105. * @param maxSteps the maximum number of steps by the physics engine per frame
  109106. */
  109107. setMaxSteps(maxSteps: number): void;
  109108. /**
  109109. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109110. * @returns the current timestep in seconds
  109111. */
  109112. getTimeStep(): number;
  109113. private _isImpostorInContact;
  109114. private _isImpostorPairInContact;
  109115. private _stepSimulation;
  109116. /**
  109117. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109118. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109119. * After the step the babylon meshes are set to the position of the physics imposters
  109120. * @param delta amount of time to step forward
  109121. * @param impostors array of imposters to update before/after the step
  109122. */
  109123. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  109124. /**
  109125. * Update babylon mesh vertices vertices to match physics world object
  109126. * @param impostor imposter to match
  109127. */
  109128. afterSoftStep(impostor: PhysicsImpostor): void;
  109129. private _tmpVector;
  109130. private _tmpMatrix;
  109131. /**
  109132. * Applies an impulse on the imposter
  109133. * @param impostor imposter to apply impulse to
  109134. * @param force amount of force to be applied to the imposter
  109135. * @param contactPoint the location to apply the impulse on the imposter
  109136. */
  109137. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109138. /**
  109139. * Applies a force on the imposter
  109140. * @param impostor imposter to apply force
  109141. * @param force amount of force to be applied to the imposter
  109142. * @param contactPoint the location to apply the force on the imposter
  109143. */
  109144. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109145. /**
  109146. * Creates a physics body using the plugin
  109147. * @param impostor the imposter to create the physics body on
  109148. */
  109149. generatePhysicsBody(impostor: PhysicsImpostor): void;
  109150. /**
  109151. * Removes the physics body from the imposter and disposes of the body's memory
  109152. * @param impostor imposter to remove the physics body from
  109153. */
  109154. removePhysicsBody(impostor: PhysicsImpostor): void;
  109155. /**
  109156. * Generates a joint
  109157. * @param impostorJoint the imposter joint to create the joint with
  109158. */
  109159. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  109160. /**
  109161. * Removes a joint
  109162. * @param impostorJoint the imposter joint to remove the joint from
  109163. */
  109164. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  109165. private _addMeshVerts;
  109166. /**
  109167. * Initialise the soft body vertices to match its object's (mesh) vertices
  109168. * Softbody vertices (nodes) are in world space and to match this
  109169. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  109170. * @param impostor to create the softbody for
  109171. */
  109172. private _softVertexData;
  109173. /**
  109174. * Create an impostor's soft body
  109175. * @param impostor to create the softbody for
  109176. */
  109177. private _createSoftbody;
  109178. /**
  109179. * Create cloth for an impostor
  109180. * @param impostor to create the softbody for
  109181. */
  109182. private _createCloth;
  109183. private _addHullVerts;
  109184. private _createShape;
  109185. /**
  109186. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109187. * @param impostor imposter containing the physics body and babylon object
  109188. */
  109189. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  109190. /**
  109191. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109192. * @param impostor imposter containing the physics body and babylon object
  109193. * @param newPosition new position
  109194. * @param newRotation new rotation
  109195. */
  109196. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  109197. /**
  109198. * If this plugin is supported
  109199. * @returns true if its supported
  109200. */
  109201. isSupported(): boolean;
  109202. /**
  109203. * Sets the linear velocity of the physics body
  109204. * @param impostor imposter to set the velocity on
  109205. * @param velocity velocity to set
  109206. */
  109207. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109208. /**
  109209. * Sets the angular velocity of the physics body
  109210. * @param impostor imposter to set the velocity on
  109211. * @param velocity velocity to set
  109212. */
  109213. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109214. /**
  109215. * gets the linear velocity
  109216. * @param impostor imposter to get linear velocity from
  109217. * @returns linear velocity
  109218. */
  109219. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109220. /**
  109221. * gets the angular velocity
  109222. * @param impostor imposter to get angular velocity from
  109223. * @returns angular velocity
  109224. */
  109225. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109226. /**
  109227. * Sets the mass of physics body
  109228. * @param impostor imposter to set the mass on
  109229. * @param mass mass to set
  109230. */
  109231. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  109232. /**
  109233. * Gets the mass of the physics body
  109234. * @param impostor imposter to get the mass from
  109235. * @returns mass
  109236. */
  109237. getBodyMass(impostor: PhysicsImpostor): number;
  109238. /**
  109239. * Gets friction of the impostor
  109240. * @param impostor impostor to get friction from
  109241. * @returns friction value
  109242. */
  109243. getBodyFriction(impostor: PhysicsImpostor): number;
  109244. /**
  109245. * Sets friction of the impostor
  109246. * @param impostor impostor to set friction on
  109247. * @param friction friction value
  109248. */
  109249. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  109250. /**
  109251. * Gets restitution of the impostor
  109252. * @param impostor impostor to get restitution from
  109253. * @returns restitution value
  109254. */
  109255. getBodyRestitution(impostor: PhysicsImpostor): number;
  109256. /**
  109257. * Sets resitution of the impostor
  109258. * @param impostor impostor to set resitution on
  109259. * @param restitution resitution value
  109260. */
  109261. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  109262. /**
  109263. * Gets pressure inside the impostor
  109264. * @param impostor impostor to get pressure from
  109265. * @returns pressure value
  109266. */
  109267. getBodyPressure(impostor: PhysicsImpostor): number;
  109268. /**
  109269. * Sets pressure inside a soft body impostor
  109270. * Cloth and rope must remain 0 pressure
  109271. * @param impostor impostor to set pressure on
  109272. * @param pressure pressure value
  109273. */
  109274. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  109275. /**
  109276. * Gets stiffness of the impostor
  109277. * @param impostor impostor to get stiffness from
  109278. * @returns pressure value
  109279. */
  109280. getBodyStiffness(impostor: PhysicsImpostor): number;
  109281. /**
  109282. * Sets stiffness of the impostor
  109283. * @param impostor impostor to set stiffness on
  109284. * @param stiffness stiffness value from 0 to 1
  109285. */
  109286. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  109287. /**
  109288. * Gets velocityIterations of the impostor
  109289. * @param impostor impostor to get velocity iterations from
  109290. * @returns velocityIterations value
  109291. */
  109292. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  109293. /**
  109294. * Sets velocityIterations of the impostor
  109295. * @param impostor impostor to set velocity iterations on
  109296. * @param velocityIterations velocityIterations value
  109297. */
  109298. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  109299. /**
  109300. * Gets positionIterations of the impostor
  109301. * @param impostor impostor to get position iterations from
  109302. * @returns positionIterations value
  109303. */
  109304. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  109305. /**
  109306. * Sets positionIterations of the impostor
  109307. * @param impostor impostor to set position on
  109308. * @param positionIterations positionIterations value
  109309. */
  109310. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  109311. /**
  109312. * Append an anchor to a soft object
  109313. * @param impostor soft impostor to add anchor to
  109314. * @param otherImpostor rigid impostor as the anchor
  109315. * @param width ratio across width from 0 to 1
  109316. * @param height ratio up height from 0 to 1
  109317. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, no strech
  109318. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  109319. */
  109320. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  109321. /**
  109322. * Sleeps the physics body and stops it from being active
  109323. * @param impostor impostor to sleep
  109324. */
  109325. sleepBody(impostor: PhysicsImpostor): void;
  109326. /**
  109327. * Activates the physics body
  109328. * @param impostor impostor to activate
  109329. */
  109330. wakeUpBody(impostor: PhysicsImpostor): void;
  109331. /**
  109332. * Updates the distance parameters of the joint
  109333. * @param joint joint to update
  109334. * @param maxDistance maximum distance of the joint
  109335. * @param minDistance minimum distance of the joint
  109336. */
  109337. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  109338. /**
  109339. * Sets a motor on the joint
  109340. * @param joint joint to set motor on
  109341. * @param speed speed of the motor
  109342. * @param maxForce maximum force of the motor
  109343. * @param motorIndex index of the motor
  109344. */
  109345. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  109346. /**
  109347. * Sets the motors limit
  109348. * @param joint joint to set limit on
  109349. * @param upperLimit upper limit
  109350. * @param lowerLimit lower limit
  109351. */
  109352. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  109353. /**
  109354. * Syncs the position and rotation of a mesh with the impostor
  109355. * @param mesh mesh to sync
  109356. * @param impostor impostor to update the mesh with
  109357. */
  109358. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  109359. /**
  109360. * Gets the radius of the impostor
  109361. * @param impostor impostor to get radius from
  109362. * @returns the radius
  109363. */
  109364. getRadius(impostor: PhysicsImpostor): number;
  109365. /**
  109366. * Gets the box size of the impostor
  109367. * @param impostor impostor to get box size from
  109368. * @param result the resulting box size
  109369. */
  109370. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  109371. /**
  109372. * Disposes of the impostor
  109373. */
  109374. dispose(): void;
  109375. /**
  109376. * Does a raycast in the physics world
  109377. * @param from when should the ray start?
  109378. * @param to when should the ray end?
  109379. * @returns PhysicsRaycastResult
  109380. */
  109381. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  109382. }
  109383. }
  109384. declare module BABYLON {
  109385. /** @hidden */
  109386. export var blackAndWhitePixelShader: {
  109387. name: string;
  109388. shader: string;
  109389. };
  109390. }
  109391. declare module BABYLON {
  109392. /**
  109393. * Post process used to render in black and white
  109394. */
  109395. export class BlackAndWhitePostProcess extends PostProcess {
  109396. /**
  109397. * Linear about to convert he result to black and white (default: 1)
  109398. */
  109399. degree: number;
  109400. /**
  109401. * Creates a black and white post process
  109402. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  109403. * @param name The name of the effect.
  109404. * @param options The required width/height ratio to downsize to before computing the render pass.
  109405. * @param camera The camera to apply the render pass to.
  109406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109407. * @param engine The engine which the post process will be applied. (default: current engine)
  109408. * @param reusable If the post process can be reused on the same frame. (default: false)
  109409. */
  109410. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109411. }
  109412. }
  109413. declare module BABYLON {
  109414. /**
  109415. * This represents a set of one or more post processes in Babylon.
  109416. * A post process can be used to apply a shader to a texture after it is rendered.
  109417. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109418. */
  109419. export class PostProcessRenderEffect {
  109420. private _postProcesses;
  109421. private _getPostProcesses;
  109422. private _singleInstance;
  109423. private _cameras;
  109424. private _indicesForCamera;
  109425. /**
  109426. * Name of the effect
  109427. * @hidden
  109428. */
  109429. _name: string;
  109430. /**
  109431. * Instantiates a post process render effect.
  109432. * A post process can be used to apply a shader to a texture after it is rendered.
  109433. * @param engine The engine the effect is tied to
  109434. * @param name The name of the effect
  109435. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  109436. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  109437. */
  109438. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  109439. /**
  109440. * Checks if all the post processes in the effect are supported.
  109441. */
  109442. readonly isSupported: boolean;
  109443. /**
  109444. * Updates the current state of the effect
  109445. * @hidden
  109446. */
  109447. _update(): void;
  109448. /**
  109449. * Attaches the effect on cameras
  109450. * @param cameras The camera to attach to.
  109451. * @hidden
  109452. */
  109453. _attachCameras(cameras: Camera): void;
  109454. /**
  109455. * Attaches the effect on cameras
  109456. * @param cameras The camera to attach to.
  109457. * @hidden
  109458. */
  109459. _attachCameras(cameras: Camera[]): void;
  109460. /**
  109461. * Detatches the effect on cameras
  109462. * @param cameras The camera to detatch from.
  109463. * @hidden
  109464. */
  109465. _detachCameras(cameras: Camera): void;
  109466. /**
  109467. * Detatches the effect on cameras
  109468. * @param cameras The camera to detatch from.
  109469. * @hidden
  109470. */
  109471. _detachCameras(cameras: Camera[]): void;
  109472. /**
  109473. * Enables the effect on given cameras
  109474. * @param cameras The camera to enable.
  109475. * @hidden
  109476. */
  109477. _enable(cameras: Camera): void;
  109478. /**
  109479. * Enables the effect on given cameras
  109480. * @param cameras The camera to enable.
  109481. * @hidden
  109482. */
  109483. _enable(cameras: Nullable<Camera[]>): void;
  109484. /**
  109485. * Disables the effect on the given cameras
  109486. * @param cameras The camera to disable.
  109487. * @hidden
  109488. */
  109489. _disable(cameras: Camera): void;
  109490. /**
  109491. * Disables the effect on the given cameras
  109492. * @param cameras The camera to disable.
  109493. * @hidden
  109494. */
  109495. _disable(cameras: Nullable<Camera[]>): void;
  109496. /**
  109497. * Gets a list of the post processes contained in the effect.
  109498. * @param camera The camera to get the post processes on.
  109499. * @returns The list of the post processes in the effect.
  109500. */
  109501. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  109502. }
  109503. }
  109504. declare module BABYLON {
  109505. /** @hidden */
  109506. export var extractHighlightsPixelShader: {
  109507. name: string;
  109508. shader: string;
  109509. };
  109510. }
  109511. declare module BABYLON {
  109512. /**
  109513. * 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.
  109514. */
  109515. export class ExtractHighlightsPostProcess extends PostProcess {
  109516. /**
  109517. * The luminance threshold, pixels below this value will be set to black.
  109518. */
  109519. threshold: number;
  109520. /** @hidden */
  109521. _exposure: number;
  109522. /**
  109523. * Post process which has the input texture to be used when performing highlight extraction
  109524. * @hidden
  109525. */
  109526. _inputPostProcess: Nullable<PostProcess>;
  109527. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109528. }
  109529. }
  109530. declare module BABYLON {
  109531. /** @hidden */
  109532. export var bloomMergePixelShader: {
  109533. name: string;
  109534. shader: string;
  109535. };
  109536. }
  109537. declare module BABYLON {
  109538. /**
  109539. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109540. */
  109541. export class BloomMergePostProcess extends PostProcess {
  109542. /** Weight of the bloom to be added to the original input. */
  109543. weight: number;
  109544. /**
  109545. * Creates a new instance of @see BloomMergePostProcess
  109546. * @param name The name of the effect.
  109547. * @param originalFromInput Post process which's input will be used for the merge.
  109548. * @param blurred Blurred highlights post process which's output will be used.
  109549. * @param weight Weight of the bloom to be added to the original input.
  109550. * @param options The required width/height ratio to downsize to before computing the render pass.
  109551. * @param camera The camera to apply the render pass to.
  109552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109553. * @param engine The engine which the post process will be applied. (default: current engine)
  109554. * @param reusable If the post process can be reused on the same frame. (default: false)
  109555. * @param textureType Type of textures used when performing the post process. (default: 0)
  109556. * @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)
  109557. */
  109558. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  109559. /** Weight of the bloom to be added to the original input. */
  109560. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109561. }
  109562. }
  109563. declare module BABYLON {
  109564. /**
  109565. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  109566. */
  109567. export class BloomEffect extends PostProcessRenderEffect {
  109568. private bloomScale;
  109569. /**
  109570. * @hidden Internal
  109571. */
  109572. _effects: Array<PostProcess>;
  109573. /**
  109574. * @hidden Internal
  109575. */
  109576. _downscale: ExtractHighlightsPostProcess;
  109577. private _blurX;
  109578. private _blurY;
  109579. private _merge;
  109580. /**
  109581. * The luminance threshold to find bright areas of the image to bloom.
  109582. */
  109583. threshold: number;
  109584. /**
  109585. * The strength of the bloom.
  109586. */
  109587. weight: number;
  109588. /**
  109589. * Specifies the size of the bloom blur kernel, relative to the final output size
  109590. */
  109591. kernel: number;
  109592. /**
  109593. * Creates a new instance of @see BloomEffect
  109594. * @param scene The scene the effect belongs to.
  109595. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  109596. * @param bloomKernel The size of the kernel to be used when applying the blur.
  109597. * @param bloomWeight The the strength of bloom.
  109598. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  109599. * @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)
  109600. */
  109601. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  109602. /**
  109603. * Disposes each of the internal effects for a given camera.
  109604. * @param camera The camera to dispose the effect on.
  109605. */
  109606. disposeEffects(camera: Camera): void;
  109607. /**
  109608. * @hidden Internal
  109609. */
  109610. _updateEffects(): void;
  109611. /**
  109612. * Internal
  109613. * @returns if all the contained post processes are ready.
  109614. * @hidden
  109615. */
  109616. _isReady(): boolean;
  109617. }
  109618. }
  109619. declare module BABYLON {
  109620. /** @hidden */
  109621. export var chromaticAberrationPixelShader: {
  109622. name: string;
  109623. shader: string;
  109624. };
  109625. }
  109626. declare module BABYLON {
  109627. /**
  109628. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  109629. */
  109630. export class ChromaticAberrationPostProcess extends PostProcess {
  109631. /**
  109632. * The amount of seperation of rgb channels (default: 30)
  109633. */
  109634. aberrationAmount: number;
  109635. /**
  109636. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  109637. */
  109638. radialIntensity: number;
  109639. /**
  109640. * 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))
  109641. */
  109642. direction: Vector2;
  109643. /**
  109644. * 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))
  109645. */
  109646. centerPosition: Vector2;
  109647. /**
  109648. * Creates a new instance ChromaticAberrationPostProcess
  109649. * @param name The name of the effect.
  109650. * @param screenWidth The width of the screen to apply the effect on.
  109651. * @param screenHeight The height of the screen to apply the effect on.
  109652. * @param options The required width/height ratio to downsize to before computing the render pass.
  109653. * @param camera The camera to apply the render pass to.
  109654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109655. * @param engine The engine which the post process will be applied. (default: current engine)
  109656. * @param reusable If the post process can be reused on the same frame. (default: false)
  109657. * @param textureType Type of textures used when performing the post process. (default: 0)
  109658. * @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)
  109659. */
  109660. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109661. }
  109662. }
  109663. declare module BABYLON {
  109664. /** @hidden */
  109665. export var circleOfConfusionPixelShader: {
  109666. name: string;
  109667. shader: string;
  109668. };
  109669. }
  109670. declare module BABYLON {
  109671. /**
  109672. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  109673. */
  109674. export class CircleOfConfusionPostProcess extends PostProcess {
  109675. /**
  109676. * 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.
  109677. */
  109678. lensSize: number;
  109679. /**
  109680. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  109681. */
  109682. fStop: number;
  109683. /**
  109684. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  109685. */
  109686. focusDistance: number;
  109687. /**
  109688. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  109689. */
  109690. focalLength: number;
  109691. private _depthTexture;
  109692. /**
  109693. * Creates a new instance CircleOfConfusionPostProcess
  109694. * @param name The name of the effect.
  109695. * @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.
  109696. * @param options The required width/height ratio to downsize to before computing the render pass.
  109697. * @param camera The camera to apply the render pass to.
  109698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109699. * @param engine The engine which the post process will be applied. (default: current engine)
  109700. * @param reusable If the post process can be reused on the same frame. (default: false)
  109701. * @param textureType Type of textures used when performing the post process. (default: 0)
  109702. * @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)
  109703. */
  109704. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109705. /**
  109706. * 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.
  109707. */
  109708. depthTexture: RenderTargetTexture;
  109709. }
  109710. }
  109711. declare module BABYLON {
  109712. /** @hidden */
  109713. export var colorCorrectionPixelShader: {
  109714. name: string;
  109715. shader: string;
  109716. };
  109717. }
  109718. declare module BABYLON {
  109719. /**
  109720. *
  109721. * This post-process allows the modification of rendered colors by using
  109722. * a 'look-up table' (LUT). This effect is also called Color Grading.
  109723. *
  109724. * The object needs to be provided an url to a texture containing the color
  109725. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  109726. * Use an image editing software to tweak the LUT to match your needs.
  109727. *
  109728. * For an example of a color LUT, see here:
  109729. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  109730. * For explanations on color grading, see here:
  109731. * @see http://udn.epicgames.com/Three/ColorGrading.html
  109732. *
  109733. */
  109734. export class ColorCorrectionPostProcess extends PostProcess {
  109735. private _colorTableTexture;
  109736. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109737. }
  109738. }
  109739. declare module BABYLON {
  109740. /** @hidden */
  109741. export var convolutionPixelShader: {
  109742. name: string;
  109743. shader: string;
  109744. };
  109745. }
  109746. declare module BABYLON {
  109747. /**
  109748. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  109749. * input texture to perform effects such as edge detection or sharpening
  109750. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109751. */
  109752. export class ConvolutionPostProcess extends PostProcess {
  109753. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109754. kernel: number[];
  109755. /**
  109756. * Creates a new instance ConvolutionPostProcess
  109757. * @param name The name of the effect.
  109758. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  109759. * @param options The required width/height ratio to downsize to before computing the render pass.
  109760. * @param camera The camera to apply the render pass to.
  109761. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109762. * @param engine The engine which the post process will be applied. (default: current engine)
  109763. * @param reusable If the post process can be reused on the same frame. (default: false)
  109764. * @param textureType Type of textures used when performing the post process. (default: 0)
  109765. */
  109766. constructor(name: string,
  109767. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109768. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109769. /**
  109770. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109771. */
  109772. static EdgeDetect0Kernel: number[];
  109773. /**
  109774. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109775. */
  109776. static EdgeDetect1Kernel: number[];
  109777. /**
  109778. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109779. */
  109780. static EdgeDetect2Kernel: number[];
  109781. /**
  109782. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109783. */
  109784. static SharpenKernel: number[];
  109785. /**
  109786. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109787. */
  109788. static EmbossKernel: number[];
  109789. /**
  109790. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109791. */
  109792. static GaussianKernel: number[];
  109793. }
  109794. }
  109795. declare module BABYLON {
  109796. /**
  109797. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  109798. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  109799. * based on samples that have a large difference in distance than the center pixel.
  109800. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  109801. */
  109802. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  109803. direction: Vector2;
  109804. /**
  109805. * Creates a new instance CircleOfConfusionPostProcess
  109806. * @param name The name of the effect.
  109807. * @param scene The scene the effect belongs to.
  109808. * @param direction The direction the blur should be applied.
  109809. * @param kernel The size of the kernel used to blur.
  109810. * @param options The required width/height ratio to downsize to before computing the render pass.
  109811. * @param camera The camera to apply the render pass to.
  109812. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  109813. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  109814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109815. * @param engine The engine which the post process will be applied. (default: current engine)
  109816. * @param reusable If the post process can be reused on the same frame. (default: false)
  109817. * @param textureType Type of textures used when performing the post process. (default: 0)
  109818. * @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)
  109819. */
  109820. 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);
  109821. }
  109822. }
  109823. declare module BABYLON {
  109824. /** @hidden */
  109825. export var depthOfFieldMergePixelShader: {
  109826. name: string;
  109827. shader: string;
  109828. };
  109829. }
  109830. declare module BABYLON {
  109831. /**
  109832. * Options to be set when merging outputs from the default pipeline.
  109833. */
  109834. export class DepthOfFieldMergePostProcessOptions {
  109835. /**
  109836. * The original image to merge on top of
  109837. */
  109838. originalFromInput: PostProcess;
  109839. /**
  109840. * Parameters to perform the merge of the depth of field effect
  109841. */
  109842. depthOfField?: {
  109843. circleOfConfusion: PostProcess;
  109844. blurSteps: Array<PostProcess>;
  109845. };
  109846. /**
  109847. * Parameters to perform the merge of bloom effect
  109848. */
  109849. bloom?: {
  109850. blurred: PostProcess;
  109851. weight: number;
  109852. };
  109853. }
  109854. /**
  109855. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109856. */
  109857. export class DepthOfFieldMergePostProcess extends PostProcess {
  109858. private blurSteps;
  109859. /**
  109860. * Creates a new instance of DepthOfFieldMergePostProcess
  109861. * @param name The name of the effect.
  109862. * @param originalFromInput Post process which's input will be used for the merge.
  109863. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  109864. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  109865. * @param options The required width/height ratio to downsize to before computing the render pass.
  109866. * @param camera The camera to apply the render pass to.
  109867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109868. * @param engine The engine which the post process will be applied. (default: current engine)
  109869. * @param reusable If the post process can be reused on the same frame. (default: false)
  109870. * @param textureType Type of textures used when performing the post process. (default: 0)
  109871. * @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)
  109872. */
  109873. 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);
  109874. /**
  109875. * Updates the effect with the current post process compile time values and recompiles the shader.
  109876. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109877. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109878. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109879. * @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
  109880. * @param onCompiled Called when the shader has been compiled.
  109881. * @param onError Called if there is an error when compiling a shader.
  109882. */
  109883. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109884. }
  109885. }
  109886. declare module BABYLON {
  109887. /**
  109888. * Specifies the level of max blur that should be applied when using the depth of field effect
  109889. */
  109890. export enum DepthOfFieldEffectBlurLevel {
  109891. /**
  109892. * Subtle blur
  109893. */
  109894. Low = 0,
  109895. /**
  109896. * Medium blur
  109897. */
  109898. Medium = 1,
  109899. /**
  109900. * Large blur
  109901. */
  109902. High = 2
  109903. }
  109904. /**
  109905. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  109906. */
  109907. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  109908. private _circleOfConfusion;
  109909. /**
  109910. * @hidden Internal, blurs from high to low
  109911. */
  109912. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  109913. private _depthOfFieldBlurY;
  109914. private _dofMerge;
  109915. /**
  109916. * @hidden Internal post processes in depth of field effect
  109917. */
  109918. _effects: Array<PostProcess>;
  109919. /**
  109920. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  109921. */
  109922. focalLength: number;
  109923. /**
  109924. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  109925. */
  109926. fStop: number;
  109927. /**
  109928. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  109929. */
  109930. focusDistance: number;
  109931. /**
  109932. * 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.
  109933. */
  109934. lensSize: number;
  109935. /**
  109936. * Creates a new instance DepthOfFieldEffect
  109937. * @param scene The scene the effect belongs to.
  109938. * @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.
  109939. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  109940. * @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)
  109941. */
  109942. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  109943. /**
  109944. * 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.
  109945. */
  109946. depthTexture: RenderTargetTexture;
  109947. /**
  109948. * Disposes each of the internal effects for a given camera.
  109949. * @param camera The camera to dispose the effect on.
  109950. */
  109951. disposeEffects(camera: Camera): void;
  109952. /**
  109953. * @hidden Internal
  109954. */
  109955. _updateEffects(): void;
  109956. /**
  109957. * Internal
  109958. * @returns if all the contained post processes are ready.
  109959. * @hidden
  109960. */
  109961. _isReady(): boolean;
  109962. }
  109963. }
  109964. declare module BABYLON {
  109965. /** @hidden */
  109966. export var displayPassPixelShader: {
  109967. name: string;
  109968. shader: string;
  109969. };
  109970. }
  109971. declare module BABYLON {
  109972. /**
  109973. * DisplayPassPostProcess which produces an output the same as it's input
  109974. */
  109975. export class DisplayPassPostProcess extends PostProcess {
  109976. /**
  109977. * Creates the DisplayPassPostProcess
  109978. * @param name The name of the effect.
  109979. * @param options The required width/height ratio to downsize to before computing the render pass.
  109980. * @param camera The camera to apply the render pass to.
  109981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109982. * @param engine The engine which the post process will be applied. (default: current engine)
  109983. * @param reusable If the post process can be reused on the same frame. (default: false)
  109984. */
  109985. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109986. }
  109987. }
  109988. declare module BABYLON {
  109989. /** @hidden */
  109990. export var filterPixelShader: {
  109991. name: string;
  109992. shader: string;
  109993. };
  109994. }
  109995. declare module BABYLON {
  109996. /**
  109997. * Applies a kernel filter to the image
  109998. */
  109999. export class FilterPostProcess extends PostProcess {
  110000. /** The matrix to be applied to the image */
  110001. kernelMatrix: Matrix;
  110002. /**
  110003. *
  110004. * @param name The name of the effect.
  110005. * @param kernelMatrix The matrix to be applied to the image
  110006. * @param options The required width/height ratio to downsize to before computing the render pass.
  110007. * @param camera The camera to apply the render pass to.
  110008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110009. * @param engine The engine which the post process will be applied. (default: current engine)
  110010. * @param reusable If the post process can be reused on the same frame. (default: false)
  110011. */
  110012. constructor(name: string,
  110013. /** The matrix to be applied to the image */
  110014. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110015. }
  110016. }
  110017. declare module BABYLON {
  110018. /** @hidden */
  110019. export var fxaaPixelShader: {
  110020. name: string;
  110021. shader: string;
  110022. };
  110023. }
  110024. declare module BABYLON {
  110025. /** @hidden */
  110026. export var fxaaVertexShader: {
  110027. name: string;
  110028. shader: string;
  110029. };
  110030. }
  110031. declare module BABYLON {
  110032. /**
  110033. * Fxaa post process
  110034. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  110035. */
  110036. export class FxaaPostProcess extends PostProcess {
  110037. /** @hidden */
  110038. texelWidth: number;
  110039. /** @hidden */
  110040. texelHeight: number;
  110041. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110042. private _getDefines;
  110043. }
  110044. }
  110045. declare module BABYLON {
  110046. /** @hidden */
  110047. export var grainPixelShader: {
  110048. name: string;
  110049. shader: string;
  110050. };
  110051. }
  110052. declare module BABYLON {
  110053. /**
  110054. * The GrainPostProcess adds noise to the image at mid luminance levels
  110055. */
  110056. export class GrainPostProcess extends PostProcess {
  110057. /**
  110058. * The intensity of the grain added (default: 30)
  110059. */
  110060. intensity: number;
  110061. /**
  110062. * If the grain should be randomized on every frame
  110063. */
  110064. animated: boolean;
  110065. /**
  110066. * Creates a new instance of @see GrainPostProcess
  110067. * @param name The name of the effect.
  110068. * @param options The required width/height ratio to downsize to before computing the render pass.
  110069. * @param camera The camera to apply the render pass to.
  110070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110071. * @param engine The engine which the post process will be applied. (default: current engine)
  110072. * @param reusable If the post process can be reused on the same frame. (default: false)
  110073. * @param textureType Type of textures used when performing the post process. (default: 0)
  110074. * @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)
  110075. */
  110076. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110077. }
  110078. }
  110079. declare module BABYLON {
  110080. /** @hidden */
  110081. export var highlightsPixelShader: {
  110082. name: string;
  110083. shader: string;
  110084. };
  110085. }
  110086. declare module BABYLON {
  110087. /**
  110088. * Extracts highlights from the image
  110089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110090. */
  110091. export class HighlightsPostProcess extends PostProcess {
  110092. /**
  110093. * Extracts highlights from the image
  110094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110095. * @param name The name of the effect.
  110096. * @param options The required width/height ratio to downsize to before computing the render pass.
  110097. * @param camera The camera to apply the render pass to.
  110098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110099. * @param engine The engine which the post process will be applied. (default: current engine)
  110100. * @param reusable If the post process can be reused on the same frame. (default: false)
  110101. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  110102. */
  110103. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110104. }
  110105. }
  110106. declare module BABYLON {
  110107. /** @hidden */
  110108. export var mrtFragmentDeclaration: {
  110109. name: string;
  110110. shader: string;
  110111. };
  110112. }
  110113. declare module BABYLON {
  110114. /** @hidden */
  110115. export var geometryPixelShader: {
  110116. name: string;
  110117. shader: string;
  110118. };
  110119. }
  110120. declare module BABYLON {
  110121. /** @hidden */
  110122. export var geometryVertexShader: {
  110123. name: string;
  110124. shader: string;
  110125. };
  110126. }
  110127. declare module BABYLON {
  110128. /**
  110129. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  110130. */
  110131. export class GeometryBufferRenderer {
  110132. /**
  110133. * Constant used to retrieve the position texture index in the G-Buffer textures array
  110134. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  110135. */
  110136. static readonly POSITION_TEXTURE_TYPE: number;
  110137. /**
  110138. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  110139. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  110140. */
  110141. static readonly VELOCITY_TEXTURE_TYPE: number;
  110142. /**
  110143. * Dictionary used to store the previous transformation matrices of each rendered mesh
  110144. * in order to compute objects velocities when enableVelocity is set to "true"
  110145. * @hidden
  110146. */
  110147. _previousTransformationMatrices: {
  110148. [index: number]: Matrix;
  110149. };
  110150. private _scene;
  110151. private _multiRenderTarget;
  110152. private _ratio;
  110153. private _enablePosition;
  110154. private _enableVelocity;
  110155. private _positionIndex;
  110156. private _velocityIndex;
  110157. protected _effect: Effect;
  110158. protected _cachedDefines: string;
  110159. /**
  110160. * Set the render list (meshes to be rendered) used in the G buffer.
  110161. */
  110162. renderList: Mesh[];
  110163. /**
  110164. * Gets wether or not G buffer are supported by the running hardware.
  110165. * This requires draw buffer supports
  110166. */
  110167. readonly isSupported: boolean;
  110168. /**
  110169. * Returns the index of the given texture type in the G-Buffer textures array
  110170. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  110171. * @returns the index of the given texture type in the G-Buffer textures array
  110172. */
  110173. getTextureIndex(textureType: number): number;
  110174. /**
  110175. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  110176. */
  110177. /**
  110178. * Sets whether or not objects positions are enabled for the G buffer.
  110179. */
  110180. enablePosition: boolean;
  110181. /**
  110182. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  110183. */
  110184. /**
  110185. * Sets wether or not objects velocities are enabled for the G buffer.
  110186. */
  110187. enableVelocity: boolean;
  110188. /**
  110189. * Gets the scene associated with the buffer.
  110190. */
  110191. readonly scene: Scene;
  110192. /**
  110193. * Gets the ratio used by the buffer during its creation.
  110194. * How big is the buffer related to the main canvas.
  110195. */
  110196. readonly ratio: number;
  110197. /** @hidden */
  110198. static _SceneComponentInitialization: (scene: Scene) => void;
  110199. /**
  110200. * Creates a new G Buffer for the scene
  110201. * @param scene The scene the buffer belongs to
  110202. * @param ratio How big is the buffer related to the main canvas.
  110203. */
  110204. constructor(scene: Scene, ratio?: number);
  110205. /**
  110206. * Checks wether everything is ready to render a submesh to the G buffer.
  110207. * @param subMesh the submesh to check readiness for
  110208. * @param useInstances is the mesh drawn using instance or not
  110209. * @returns true if ready otherwise false
  110210. */
  110211. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110212. /**
  110213. * Gets the current underlying G Buffer.
  110214. * @returns the buffer
  110215. */
  110216. getGBuffer(): MultiRenderTarget;
  110217. /**
  110218. * Gets the number of samples used to render the buffer (anti aliasing).
  110219. */
  110220. /**
  110221. * Sets the number of samples used to render the buffer (anti aliasing).
  110222. */
  110223. samples: number;
  110224. /**
  110225. * Disposes the renderer and frees up associated resources.
  110226. */
  110227. dispose(): void;
  110228. protected _createRenderTargets(): void;
  110229. }
  110230. }
  110231. declare module BABYLON {
  110232. interface Scene {
  110233. /** @hidden (Backing field) */
  110234. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110235. /**
  110236. * Gets or Sets the current geometry buffer associated to the scene.
  110237. */
  110238. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110239. /**
  110240. * Enables a GeometryBufferRender and associates it with the scene
  110241. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  110242. * @returns the GeometryBufferRenderer
  110243. */
  110244. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  110245. /**
  110246. * Disables the GeometryBufferRender associated with the scene
  110247. */
  110248. disableGeometryBufferRenderer(): void;
  110249. }
  110250. /**
  110251. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  110252. * in several rendering techniques.
  110253. */
  110254. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  110255. /**
  110256. * The component name helpful to identify the component in the list of scene components.
  110257. */
  110258. readonly name: string;
  110259. /**
  110260. * The scene the component belongs to.
  110261. */
  110262. scene: Scene;
  110263. /**
  110264. * Creates a new instance of the component for the given scene
  110265. * @param scene Defines the scene to register the component in
  110266. */
  110267. constructor(scene: Scene);
  110268. /**
  110269. * Registers the component in a given scene
  110270. */
  110271. register(): void;
  110272. /**
  110273. * Rebuilds the elements related to this component in case of
  110274. * context lost for instance.
  110275. */
  110276. rebuild(): void;
  110277. /**
  110278. * Disposes the component and the associated ressources
  110279. */
  110280. dispose(): void;
  110281. private _gatherRenderTargets;
  110282. }
  110283. }
  110284. declare module BABYLON {
  110285. /** @hidden */
  110286. export var motionBlurPixelShader: {
  110287. name: string;
  110288. shader: string;
  110289. };
  110290. }
  110291. declare module BABYLON {
  110292. /**
  110293. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  110294. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  110295. * As an example, all you have to do is to create the post-process:
  110296. * var mb = new BABYLON.MotionBlurPostProcess(
  110297. * 'mb', // The name of the effect.
  110298. * scene, // The scene containing the objects to blur according to their velocity.
  110299. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  110300. * camera // The camera to apply the render pass to.
  110301. * );
  110302. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  110303. */
  110304. export class MotionBlurPostProcess extends PostProcess {
  110305. /**
  110306. * Defines how much the image is blurred by the movement. Default value is equal to 1
  110307. */
  110308. motionStrength: number;
  110309. /**
  110310. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  110311. */
  110312. /**
  110313. * Sets the number of iterations to be used for motion blur quality
  110314. */
  110315. motionBlurSamples: number;
  110316. private _motionBlurSamples;
  110317. private _geometryBufferRenderer;
  110318. /**
  110319. * Creates a new instance MotionBlurPostProcess
  110320. * @param name The name of the effect.
  110321. * @param scene The scene containing the objects to blur according to their velocity.
  110322. * @param options The required width/height ratio to downsize to before computing the render pass.
  110323. * @param camera The camera to apply the render pass to.
  110324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110325. * @param engine The engine which the post process will be applied. (default: current engine)
  110326. * @param reusable If the post process can be reused on the same frame. (default: false)
  110327. * @param textureType Type of textures used when performing the post process. (default: 0)
  110328. * @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)
  110329. */
  110330. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110331. /**
  110332. * Disposes the post process.
  110333. * @param camera The camera to dispose the post process on.
  110334. */
  110335. dispose(camera?: Camera): void;
  110336. }
  110337. }
  110338. declare module BABYLON {
  110339. /** @hidden */
  110340. export var refractionPixelShader: {
  110341. name: string;
  110342. shader: string;
  110343. };
  110344. }
  110345. declare module BABYLON {
  110346. /**
  110347. * Post process which applies a refractin texture
  110348. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110349. */
  110350. export class RefractionPostProcess extends PostProcess {
  110351. /** the base color of the refraction (used to taint the rendering) */
  110352. color: Color3;
  110353. /** simulated refraction depth */
  110354. depth: number;
  110355. /** the coefficient of the base color (0 to remove base color tainting) */
  110356. colorLevel: number;
  110357. private _refTexture;
  110358. private _ownRefractionTexture;
  110359. /**
  110360. * Gets or sets the refraction texture
  110361. * Please note that you are responsible for disposing the texture if you set it manually
  110362. */
  110363. refractionTexture: Texture;
  110364. /**
  110365. * Initializes the RefractionPostProcess
  110366. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110367. * @param name The name of the effect.
  110368. * @param refractionTextureUrl Url of the refraction texture to use
  110369. * @param color the base color of the refraction (used to taint the rendering)
  110370. * @param depth simulated refraction depth
  110371. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  110372. * @param camera The camera to apply the render pass to.
  110373. * @param options The required width/height ratio to downsize to before computing the render pass.
  110374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110375. * @param engine The engine which the post process will be applied. (default: current engine)
  110376. * @param reusable If the post process can be reused on the same frame. (default: false)
  110377. */
  110378. constructor(name: string, refractionTextureUrl: string,
  110379. /** the base color of the refraction (used to taint the rendering) */
  110380. color: Color3,
  110381. /** simulated refraction depth */
  110382. depth: number,
  110383. /** the coefficient of the base color (0 to remove base color tainting) */
  110384. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110385. /**
  110386. * Disposes of the post process
  110387. * @param camera Camera to dispose post process on
  110388. */
  110389. dispose(camera: Camera): void;
  110390. }
  110391. }
  110392. declare module BABYLON {
  110393. /** @hidden */
  110394. export var sharpenPixelShader: {
  110395. name: string;
  110396. shader: string;
  110397. };
  110398. }
  110399. declare module BABYLON {
  110400. /**
  110401. * The SharpenPostProcess applies a sharpen kernel to every pixel
  110402. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110403. */
  110404. export class SharpenPostProcess extends PostProcess {
  110405. /**
  110406. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  110407. */
  110408. colorAmount: number;
  110409. /**
  110410. * How much sharpness should be applied (default: 0.3)
  110411. */
  110412. edgeAmount: number;
  110413. /**
  110414. * Creates a new instance ConvolutionPostProcess
  110415. * @param name The name of the effect.
  110416. * @param options The required width/height ratio to downsize to before computing the render pass.
  110417. * @param camera The camera to apply the render pass to.
  110418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110419. * @param engine The engine which the post process will be applied. (default: current engine)
  110420. * @param reusable If the post process can be reused on the same frame. (default: false)
  110421. * @param textureType Type of textures used when performing the post process. (default: 0)
  110422. * @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)
  110423. */
  110424. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110425. }
  110426. }
  110427. declare module BABYLON {
  110428. /**
  110429. * PostProcessRenderPipeline
  110430. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110431. */
  110432. export class PostProcessRenderPipeline {
  110433. private engine;
  110434. private _renderEffects;
  110435. private _renderEffectsForIsolatedPass;
  110436. /**
  110437. * List of inspectable custom properties (used by the Inspector)
  110438. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110439. */
  110440. inspectableCustomProperties: IInspectable[];
  110441. /**
  110442. * @hidden
  110443. */
  110444. protected _cameras: Camera[];
  110445. /** @hidden */
  110446. _name: string;
  110447. /**
  110448. * Gets pipeline name
  110449. */
  110450. readonly name: string;
  110451. /**
  110452. * Initializes a PostProcessRenderPipeline
  110453. * @param engine engine to add the pipeline to
  110454. * @param name name of the pipeline
  110455. */
  110456. constructor(engine: Engine, name: string);
  110457. /**
  110458. * Gets the class name
  110459. * @returns "PostProcessRenderPipeline"
  110460. */
  110461. getClassName(): string;
  110462. /**
  110463. * If all the render effects in the pipeline are supported
  110464. */
  110465. readonly isSupported: boolean;
  110466. /**
  110467. * Adds an effect to the pipeline
  110468. * @param renderEffect the effect to add
  110469. */
  110470. addEffect(renderEffect: PostProcessRenderEffect): void;
  110471. /** @hidden */
  110472. _rebuild(): void;
  110473. /** @hidden */
  110474. _enableEffect(renderEffectName: string, cameras: Camera): void;
  110475. /** @hidden */
  110476. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  110477. /** @hidden */
  110478. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110479. /** @hidden */
  110480. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110481. /** @hidden */
  110482. _attachCameras(cameras: Camera, unique: boolean): void;
  110483. /** @hidden */
  110484. _attachCameras(cameras: Camera[], unique: boolean): void;
  110485. /** @hidden */
  110486. _detachCameras(cameras: Camera): void;
  110487. /** @hidden */
  110488. _detachCameras(cameras: Nullable<Camera[]>): void;
  110489. /** @hidden */
  110490. _update(): void;
  110491. /** @hidden */
  110492. _reset(): void;
  110493. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  110494. /**
  110495. * Disposes of the pipeline
  110496. */
  110497. dispose(): void;
  110498. }
  110499. }
  110500. declare module BABYLON {
  110501. /**
  110502. * PostProcessRenderPipelineManager class
  110503. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110504. */
  110505. export class PostProcessRenderPipelineManager {
  110506. private _renderPipelines;
  110507. /**
  110508. * Initializes a PostProcessRenderPipelineManager
  110509. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110510. */
  110511. constructor();
  110512. /**
  110513. * Gets the list of supported render pipelines
  110514. */
  110515. readonly supportedPipelines: PostProcessRenderPipeline[];
  110516. /**
  110517. * Adds a pipeline to the manager
  110518. * @param renderPipeline The pipeline to add
  110519. */
  110520. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  110521. /**
  110522. * Attaches a camera to the pipeline
  110523. * @param renderPipelineName The name of the pipeline to attach to
  110524. * @param cameras the camera to attach
  110525. * @param unique if the camera can be attached multiple times to the pipeline
  110526. */
  110527. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  110528. /**
  110529. * Detaches a camera from the pipeline
  110530. * @param renderPipelineName The name of the pipeline to detach from
  110531. * @param cameras the camera to detach
  110532. */
  110533. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  110534. /**
  110535. * Enables an effect by name on a pipeline
  110536. * @param renderPipelineName the name of the pipeline to enable the effect in
  110537. * @param renderEffectName the name of the effect to enable
  110538. * @param cameras the cameras that the effect should be enabled on
  110539. */
  110540. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110541. /**
  110542. * Disables an effect by name on a pipeline
  110543. * @param renderPipelineName the name of the pipeline to disable the effect in
  110544. * @param renderEffectName the name of the effect to disable
  110545. * @param cameras the cameras that the effect should be disabled on
  110546. */
  110547. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110548. /**
  110549. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  110550. */
  110551. update(): void;
  110552. /** @hidden */
  110553. _rebuild(): void;
  110554. /**
  110555. * Disposes of the manager and pipelines
  110556. */
  110557. dispose(): void;
  110558. }
  110559. }
  110560. declare module BABYLON {
  110561. interface Scene {
  110562. /** @hidden (Backing field) */
  110563. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110564. /**
  110565. * Gets the postprocess render pipeline manager
  110566. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110567. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110568. */
  110569. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110570. }
  110571. /**
  110572. * Defines the Render Pipeline scene component responsible to rendering pipelines
  110573. */
  110574. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  110575. /**
  110576. * The component name helpfull to identify the component in the list of scene components.
  110577. */
  110578. readonly name: string;
  110579. /**
  110580. * The scene the component belongs to.
  110581. */
  110582. scene: Scene;
  110583. /**
  110584. * Creates a new instance of the component for the given scene
  110585. * @param scene Defines the scene to register the component in
  110586. */
  110587. constructor(scene: Scene);
  110588. /**
  110589. * Registers the component in a given scene
  110590. */
  110591. register(): void;
  110592. /**
  110593. * Rebuilds the elements related to this component in case of
  110594. * context lost for instance.
  110595. */
  110596. rebuild(): void;
  110597. /**
  110598. * Disposes the component and the associated ressources
  110599. */
  110600. dispose(): void;
  110601. private _gatherRenderTargets;
  110602. }
  110603. }
  110604. declare module BABYLON {
  110605. /**
  110606. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  110607. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110608. */
  110609. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  110610. private _scene;
  110611. private _camerasToBeAttached;
  110612. /**
  110613. * ID of the sharpen post process,
  110614. */
  110615. private readonly SharpenPostProcessId;
  110616. /**
  110617. * @ignore
  110618. * ID of the image processing post process;
  110619. */
  110620. readonly ImageProcessingPostProcessId: string;
  110621. /**
  110622. * @ignore
  110623. * ID of the Fast Approximate Anti-Aliasing post process;
  110624. */
  110625. readonly FxaaPostProcessId: string;
  110626. /**
  110627. * ID of the chromatic aberration post process,
  110628. */
  110629. private readonly ChromaticAberrationPostProcessId;
  110630. /**
  110631. * ID of the grain post process
  110632. */
  110633. private readonly GrainPostProcessId;
  110634. /**
  110635. * Sharpen post process which will apply a sharpen convolution to enhance edges
  110636. */
  110637. sharpen: SharpenPostProcess;
  110638. private _sharpenEffect;
  110639. private bloom;
  110640. /**
  110641. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  110642. */
  110643. depthOfField: DepthOfFieldEffect;
  110644. /**
  110645. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  110646. */
  110647. fxaa: FxaaPostProcess;
  110648. /**
  110649. * Image post processing pass used to perform operations such as tone mapping or color grading.
  110650. */
  110651. imageProcessing: ImageProcessingPostProcess;
  110652. /**
  110653. * Chromatic aberration post process which will shift rgb colors in the image
  110654. */
  110655. chromaticAberration: ChromaticAberrationPostProcess;
  110656. private _chromaticAberrationEffect;
  110657. /**
  110658. * Grain post process which add noise to the image
  110659. */
  110660. grain: GrainPostProcess;
  110661. private _grainEffect;
  110662. /**
  110663. * Glow post process which adds a glow to emissive areas of the image
  110664. */
  110665. private _glowLayer;
  110666. /**
  110667. * Animations which can be used to tweak settings over a period of time
  110668. */
  110669. animations: Animation[];
  110670. private _imageProcessingConfigurationObserver;
  110671. private _sharpenEnabled;
  110672. private _bloomEnabled;
  110673. private _depthOfFieldEnabled;
  110674. private _depthOfFieldBlurLevel;
  110675. private _fxaaEnabled;
  110676. private _imageProcessingEnabled;
  110677. private _defaultPipelineTextureType;
  110678. private _bloomScale;
  110679. private _chromaticAberrationEnabled;
  110680. private _grainEnabled;
  110681. private _buildAllowed;
  110682. /**
  110683. * Gets active scene
  110684. */
  110685. readonly scene: Scene;
  110686. /**
  110687. * Enable or disable the sharpen process from the pipeline
  110688. */
  110689. sharpenEnabled: boolean;
  110690. private _resizeObserver;
  110691. private _hardwareScaleLevel;
  110692. private _bloomKernel;
  110693. /**
  110694. * Specifies the size of the bloom blur kernel, relative to the final output size
  110695. */
  110696. bloomKernel: number;
  110697. /**
  110698. * Specifies the weight of the bloom in the final rendering
  110699. */
  110700. private _bloomWeight;
  110701. /**
  110702. * Specifies the luma threshold for the area that will be blurred by the bloom
  110703. */
  110704. private _bloomThreshold;
  110705. private _hdr;
  110706. /**
  110707. * The strength of the bloom.
  110708. */
  110709. bloomWeight: number;
  110710. /**
  110711. * The strength of the bloom.
  110712. */
  110713. bloomThreshold: number;
  110714. /**
  110715. * The scale of the bloom, lower value will provide better performance.
  110716. */
  110717. bloomScale: number;
  110718. /**
  110719. * Enable or disable the bloom from the pipeline
  110720. */
  110721. bloomEnabled: boolean;
  110722. private _rebuildBloom;
  110723. /**
  110724. * If the depth of field is enabled.
  110725. */
  110726. depthOfFieldEnabled: boolean;
  110727. /**
  110728. * Blur level of the depth of field effect. (Higher blur will effect performance)
  110729. */
  110730. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  110731. /**
  110732. * If the anti aliasing is enabled.
  110733. */
  110734. fxaaEnabled: boolean;
  110735. private _samples;
  110736. /**
  110737. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110738. */
  110739. samples: number;
  110740. /**
  110741. * If image processing is enabled.
  110742. */
  110743. imageProcessingEnabled: boolean;
  110744. /**
  110745. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  110746. */
  110747. glowLayerEnabled: boolean;
  110748. /**
  110749. * Enable or disable the chromaticAberration process from the pipeline
  110750. */
  110751. chromaticAberrationEnabled: boolean;
  110752. /**
  110753. * Enable or disable the grain process from the pipeline
  110754. */
  110755. grainEnabled: boolean;
  110756. /**
  110757. * @constructor
  110758. * @param name - The rendering pipeline name (default: "")
  110759. * @param hdr - If high dynamic range textures should be used (default: true)
  110760. * @param scene - The scene linked to this pipeline (default: the last created scene)
  110761. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  110762. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  110763. */
  110764. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  110765. /**
  110766. * Get the class name
  110767. * @returns "DefaultRenderingPipeline"
  110768. */
  110769. getClassName(): string;
  110770. /**
  110771. * Force the compilation of the entire pipeline.
  110772. */
  110773. prepare(): void;
  110774. private _hasCleared;
  110775. private _prevPostProcess;
  110776. private _prevPrevPostProcess;
  110777. private _setAutoClearAndTextureSharing;
  110778. private _depthOfFieldSceneObserver;
  110779. private _buildPipeline;
  110780. private _disposePostProcesses;
  110781. /**
  110782. * Adds a camera to the pipeline
  110783. * @param camera the camera to be added
  110784. */
  110785. addCamera(camera: Camera): void;
  110786. /**
  110787. * Removes a camera from the pipeline
  110788. * @param camera the camera to remove
  110789. */
  110790. removeCamera(camera: Camera): void;
  110791. /**
  110792. * Dispose of the pipeline and stop all post processes
  110793. */
  110794. dispose(): void;
  110795. /**
  110796. * Serialize the rendering pipeline (Used when exporting)
  110797. * @returns the serialized object
  110798. */
  110799. serialize(): any;
  110800. /**
  110801. * Parse the serialized pipeline
  110802. * @param source Source pipeline.
  110803. * @param scene The scene to load the pipeline to.
  110804. * @param rootUrl The URL of the serialized pipeline.
  110805. * @returns An instantiated pipeline from the serialized object.
  110806. */
  110807. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  110808. }
  110809. }
  110810. declare module BABYLON {
  110811. /** @hidden */
  110812. export var lensHighlightsPixelShader: {
  110813. name: string;
  110814. shader: string;
  110815. };
  110816. }
  110817. declare module BABYLON {
  110818. /** @hidden */
  110819. export var depthOfFieldPixelShader: {
  110820. name: string;
  110821. shader: string;
  110822. };
  110823. }
  110824. declare module BABYLON {
  110825. /**
  110826. * BABYLON.JS Chromatic Aberration GLSL Shader
  110827. * Author: Olivier Guyot
  110828. * Separates very slightly R, G and B colors on the edges of the screen
  110829. * Inspired by Francois Tarlier & Martins Upitis
  110830. */
  110831. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  110832. /**
  110833. * @ignore
  110834. * The chromatic aberration PostProcess id in the pipeline
  110835. */
  110836. LensChromaticAberrationEffect: string;
  110837. /**
  110838. * @ignore
  110839. * The highlights enhancing PostProcess id in the pipeline
  110840. */
  110841. HighlightsEnhancingEffect: string;
  110842. /**
  110843. * @ignore
  110844. * The depth-of-field PostProcess id in the pipeline
  110845. */
  110846. LensDepthOfFieldEffect: string;
  110847. private _scene;
  110848. private _depthTexture;
  110849. private _grainTexture;
  110850. private _chromaticAberrationPostProcess;
  110851. private _highlightsPostProcess;
  110852. private _depthOfFieldPostProcess;
  110853. private _edgeBlur;
  110854. private _grainAmount;
  110855. private _chromaticAberration;
  110856. private _distortion;
  110857. private _highlightsGain;
  110858. private _highlightsThreshold;
  110859. private _dofDistance;
  110860. private _dofAperture;
  110861. private _dofDarken;
  110862. private _dofPentagon;
  110863. private _blurNoise;
  110864. /**
  110865. * @constructor
  110866. *
  110867. * Effect parameters are as follow:
  110868. * {
  110869. * chromatic_aberration: number; // from 0 to x (1 for realism)
  110870. * edge_blur: number; // from 0 to x (1 for realism)
  110871. * distortion: number; // from 0 to x (1 for realism)
  110872. * grain_amount: number; // from 0 to 1
  110873. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  110874. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  110875. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  110876. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  110877. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  110878. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  110879. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  110880. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  110881. * }
  110882. * Note: if an effect parameter is unset, effect is disabled
  110883. *
  110884. * @param name The rendering pipeline name
  110885. * @param parameters - An object containing all parameters (see above)
  110886. * @param scene The scene linked to this pipeline
  110887. * @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)
  110888. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110889. */
  110890. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  110891. /**
  110892. * Get the class name
  110893. * @returns "LensRenderingPipeline"
  110894. */
  110895. getClassName(): string;
  110896. /**
  110897. * Gets associated scene
  110898. */
  110899. readonly scene: Scene;
  110900. /**
  110901. * Gets or sets the edge blur
  110902. */
  110903. edgeBlur: number;
  110904. /**
  110905. * Gets or sets the grain amount
  110906. */
  110907. grainAmount: number;
  110908. /**
  110909. * Gets or sets the chromatic aberration amount
  110910. */
  110911. chromaticAberration: number;
  110912. /**
  110913. * Gets or sets the depth of field aperture
  110914. */
  110915. dofAperture: number;
  110916. /**
  110917. * Gets or sets the edge distortion
  110918. */
  110919. edgeDistortion: number;
  110920. /**
  110921. * Gets or sets the depth of field distortion
  110922. */
  110923. dofDistortion: number;
  110924. /**
  110925. * Gets or sets the darken out of focus amount
  110926. */
  110927. darkenOutOfFocus: number;
  110928. /**
  110929. * Gets or sets a boolean indicating if blur noise is enabled
  110930. */
  110931. blurNoise: boolean;
  110932. /**
  110933. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  110934. */
  110935. pentagonBokeh: boolean;
  110936. /**
  110937. * Gets or sets the highlight grain amount
  110938. */
  110939. highlightsGain: number;
  110940. /**
  110941. * Gets or sets the highlight threshold
  110942. */
  110943. highlightsThreshold: number;
  110944. /**
  110945. * Sets the amount of blur at the edges
  110946. * @param amount blur amount
  110947. */
  110948. setEdgeBlur(amount: number): void;
  110949. /**
  110950. * Sets edge blur to 0
  110951. */
  110952. disableEdgeBlur(): void;
  110953. /**
  110954. * Sets the amout of grain
  110955. * @param amount Amount of grain
  110956. */
  110957. setGrainAmount(amount: number): void;
  110958. /**
  110959. * Set grain amount to 0
  110960. */
  110961. disableGrain(): void;
  110962. /**
  110963. * Sets the chromatic aberration amount
  110964. * @param amount amount of chromatic aberration
  110965. */
  110966. setChromaticAberration(amount: number): void;
  110967. /**
  110968. * Sets chromatic aberration amount to 0
  110969. */
  110970. disableChromaticAberration(): void;
  110971. /**
  110972. * Sets the EdgeDistortion amount
  110973. * @param amount amount of EdgeDistortion
  110974. */
  110975. setEdgeDistortion(amount: number): void;
  110976. /**
  110977. * Sets edge distortion to 0
  110978. */
  110979. disableEdgeDistortion(): void;
  110980. /**
  110981. * Sets the FocusDistance amount
  110982. * @param amount amount of FocusDistance
  110983. */
  110984. setFocusDistance(amount: number): void;
  110985. /**
  110986. * Disables depth of field
  110987. */
  110988. disableDepthOfField(): void;
  110989. /**
  110990. * Sets the Aperture amount
  110991. * @param amount amount of Aperture
  110992. */
  110993. setAperture(amount: number): void;
  110994. /**
  110995. * Sets the DarkenOutOfFocus amount
  110996. * @param amount amount of DarkenOutOfFocus
  110997. */
  110998. setDarkenOutOfFocus(amount: number): void;
  110999. private _pentagonBokehIsEnabled;
  111000. /**
  111001. * Creates a pentagon bokeh effect
  111002. */
  111003. enablePentagonBokeh(): void;
  111004. /**
  111005. * Disables the pentagon bokeh effect
  111006. */
  111007. disablePentagonBokeh(): void;
  111008. /**
  111009. * Enables noise blur
  111010. */
  111011. enableNoiseBlur(): void;
  111012. /**
  111013. * Disables noise blur
  111014. */
  111015. disableNoiseBlur(): void;
  111016. /**
  111017. * Sets the HighlightsGain amount
  111018. * @param amount amount of HighlightsGain
  111019. */
  111020. setHighlightsGain(amount: number): void;
  111021. /**
  111022. * Sets the HighlightsThreshold amount
  111023. * @param amount amount of HighlightsThreshold
  111024. */
  111025. setHighlightsThreshold(amount: number): void;
  111026. /**
  111027. * Disables highlights
  111028. */
  111029. disableHighlights(): void;
  111030. /**
  111031. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  111032. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  111033. */
  111034. dispose(disableDepthRender?: boolean): void;
  111035. private _createChromaticAberrationPostProcess;
  111036. private _createHighlightsPostProcess;
  111037. private _createDepthOfFieldPostProcess;
  111038. private _createGrainTexture;
  111039. }
  111040. }
  111041. declare module BABYLON {
  111042. /** @hidden */
  111043. export var ssao2PixelShader: {
  111044. name: string;
  111045. shader: string;
  111046. };
  111047. }
  111048. declare module BABYLON {
  111049. /** @hidden */
  111050. export var ssaoCombinePixelShader: {
  111051. name: string;
  111052. shader: string;
  111053. };
  111054. }
  111055. declare module BABYLON {
  111056. /**
  111057. * Render pipeline to produce ssao effect
  111058. */
  111059. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  111060. /**
  111061. * @ignore
  111062. * The PassPostProcess id in the pipeline that contains the original scene color
  111063. */
  111064. SSAOOriginalSceneColorEffect: string;
  111065. /**
  111066. * @ignore
  111067. * The SSAO PostProcess id in the pipeline
  111068. */
  111069. SSAORenderEffect: string;
  111070. /**
  111071. * @ignore
  111072. * The horizontal blur PostProcess id in the pipeline
  111073. */
  111074. SSAOBlurHRenderEffect: string;
  111075. /**
  111076. * @ignore
  111077. * The vertical blur PostProcess id in the pipeline
  111078. */
  111079. SSAOBlurVRenderEffect: string;
  111080. /**
  111081. * @ignore
  111082. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111083. */
  111084. SSAOCombineRenderEffect: string;
  111085. /**
  111086. * The output strength of the SSAO post-process. Default value is 1.0.
  111087. */
  111088. totalStrength: number;
  111089. /**
  111090. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  111091. */
  111092. maxZ: number;
  111093. /**
  111094. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  111095. */
  111096. minZAspect: number;
  111097. private _samples;
  111098. /**
  111099. * Number of samples used for the SSAO calculations. Default value is 8
  111100. */
  111101. samples: number;
  111102. private _textureSamples;
  111103. /**
  111104. * Number of samples to use for antialiasing
  111105. */
  111106. textureSamples: number;
  111107. /**
  111108. * Ratio object used for SSAO ratio and blur ratio
  111109. */
  111110. private _ratio;
  111111. /**
  111112. * Dynamically generated sphere sampler.
  111113. */
  111114. private _sampleSphere;
  111115. /**
  111116. * Blur filter offsets
  111117. */
  111118. private _samplerOffsets;
  111119. private _expensiveBlur;
  111120. /**
  111121. * If bilateral blur should be used
  111122. */
  111123. expensiveBlur: boolean;
  111124. /**
  111125. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  111126. */
  111127. radius: number;
  111128. /**
  111129. * The base color of the SSAO post-process
  111130. * The final result is "base + ssao" between [0, 1]
  111131. */
  111132. base: number;
  111133. /**
  111134. * Support test.
  111135. */
  111136. static readonly IsSupported: boolean;
  111137. private _scene;
  111138. private _depthTexture;
  111139. private _normalTexture;
  111140. private _randomTexture;
  111141. private _originalColorPostProcess;
  111142. private _ssaoPostProcess;
  111143. private _blurHPostProcess;
  111144. private _blurVPostProcess;
  111145. private _ssaoCombinePostProcess;
  111146. private _firstUpdate;
  111147. /**
  111148. * Gets active scene
  111149. */
  111150. readonly scene: Scene;
  111151. /**
  111152. * @constructor
  111153. * @param name The rendering pipeline name
  111154. * @param scene The scene linked to this pipeline
  111155. * @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 }
  111156. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111157. */
  111158. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111159. /**
  111160. * Get the class name
  111161. * @returns "SSAO2RenderingPipeline"
  111162. */
  111163. getClassName(): string;
  111164. /**
  111165. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111166. */
  111167. dispose(disableGeometryBufferRenderer?: boolean): void;
  111168. private _createBlurPostProcess;
  111169. /** @hidden */
  111170. _rebuild(): void;
  111171. private _bits;
  111172. private _radicalInverse_VdC;
  111173. private _hammersley;
  111174. private _hemisphereSample_uniform;
  111175. private _generateHemisphere;
  111176. private _createSSAOPostProcess;
  111177. private _createSSAOCombinePostProcess;
  111178. private _createRandomTexture;
  111179. /**
  111180. * Serialize the rendering pipeline (Used when exporting)
  111181. * @returns the serialized object
  111182. */
  111183. serialize(): any;
  111184. /**
  111185. * Parse the serialized pipeline
  111186. * @param source Source pipeline.
  111187. * @param scene The scene to load the pipeline to.
  111188. * @param rootUrl The URL of the serialized pipeline.
  111189. * @returns An instantiated pipeline from the serialized object.
  111190. */
  111191. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  111192. }
  111193. }
  111194. declare module BABYLON {
  111195. /** @hidden */
  111196. export var ssaoPixelShader: {
  111197. name: string;
  111198. shader: string;
  111199. };
  111200. }
  111201. declare module BABYLON {
  111202. /**
  111203. * Render pipeline to produce ssao effect
  111204. */
  111205. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  111206. /**
  111207. * @ignore
  111208. * The PassPostProcess id in the pipeline that contains the original scene color
  111209. */
  111210. SSAOOriginalSceneColorEffect: string;
  111211. /**
  111212. * @ignore
  111213. * The SSAO PostProcess id in the pipeline
  111214. */
  111215. SSAORenderEffect: string;
  111216. /**
  111217. * @ignore
  111218. * The horizontal blur PostProcess id in the pipeline
  111219. */
  111220. SSAOBlurHRenderEffect: string;
  111221. /**
  111222. * @ignore
  111223. * The vertical blur PostProcess id in the pipeline
  111224. */
  111225. SSAOBlurVRenderEffect: string;
  111226. /**
  111227. * @ignore
  111228. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111229. */
  111230. SSAOCombineRenderEffect: string;
  111231. /**
  111232. * The output strength of the SSAO post-process. Default value is 1.0.
  111233. */
  111234. totalStrength: number;
  111235. /**
  111236. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  111237. */
  111238. radius: number;
  111239. /**
  111240. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  111241. * Must not be equal to fallOff and superior to fallOff.
  111242. * Default value is 0.0075
  111243. */
  111244. area: number;
  111245. /**
  111246. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  111247. * Must not be equal to area and inferior to area.
  111248. * Default value is 0.000001
  111249. */
  111250. fallOff: number;
  111251. /**
  111252. * The base color of the SSAO post-process
  111253. * The final result is "base + ssao" between [0, 1]
  111254. */
  111255. base: number;
  111256. private _scene;
  111257. private _depthTexture;
  111258. private _randomTexture;
  111259. private _originalColorPostProcess;
  111260. private _ssaoPostProcess;
  111261. private _blurHPostProcess;
  111262. private _blurVPostProcess;
  111263. private _ssaoCombinePostProcess;
  111264. private _firstUpdate;
  111265. /**
  111266. * Gets active scene
  111267. */
  111268. readonly scene: Scene;
  111269. /**
  111270. * @constructor
  111271. * @param name - The rendering pipeline name
  111272. * @param scene - The scene linked to this pipeline
  111273. * @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 }
  111274. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  111275. */
  111276. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111277. /**
  111278. * Get the class name
  111279. * @returns "SSAORenderingPipeline"
  111280. */
  111281. getClassName(): string;
  111282. /**
  111283. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111284. */
  111285. dispose(disableDepthRender?: boolean): void;
  111286. private _createBlurPostProcess;
  111287. /** @hidden */
  111288. _rebuild(): void;
  111289. private _createSSAOPostProcess;
  111290. private _createSSAOCombinePostProcess;
  111291. private _createRandomTexture;
  111292. }
  111293. }
  111294. declare module BABYLON {
  111295. /** @hidden */
  111296. export var standardPixelShader: {
  111297. name: string;
  111298. shader: string;
  111299. };
  111300. }
  111301. declare module BABYLON {
  111302. /**
  111303. * Standard rendering pipeline
  111304. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111305. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  111306. */
  111307. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111308. /**
  111309. * Public members
  111310. */
  111311. /**
  111312. * Post-process which contains the original scene color before the pipeline applies all the effects
  111313. */
  111314. originalPostProcess: Nullable<PostProcess>;
  111315. /**
  111316. * Post-process used to down scale an image x4
  111317. */
  111318. downSampleX4PostProcess: Nullable<PostProcess>;
  111319. /**
  111320. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  111321. */
  111322. brightPassPostProcess: Nullable<PostProcess>;
  111323. /**
  111324. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  111325. */
  111326. blurHPostProcesses: PostProcess[];
  111327. /**
  111328. * Post-process array storing all the vertical blur post-processes used by the pipeline
  111329. */
  111330. blurVPostProcesses: PostProcess[];
  111331. /**
  111332. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  111333. */
  111334. textureAdderPostProcess: Nullable<PostProcess>;
  111335. /**
  111336. * Post-process used to create volumetric lighting effect
  111337. */
  111338. volumetricLightPostProcess: Nullable<PostProcess>;
  111339. /**
  111340. * Post-process used to smooth the previous volumetric light post-process on the X axis
  111341. */
  111342. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  111343. /**
  111344. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  111345. */
  111346. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  111347. /**
  111348. * Post-process used to merge the volumetric light effect and the real scene color
  111349. */
  111350. volumetricLightMergePostProces: Nullable<PostProcess>;
  111351. /**
  111352. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  111353. */
  111354. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  111355. /**
  111356. * Base post-process used to calculate the average luminance of the final image for HDR
  111357. */
  111358. luminancePostProcess: Nullable<PostProcess>;
  111359. /**
  111360. * Post-processes used to create down sample post-processes in order to get
  111361. * the average luminance of the final image for HDR
  111362. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  111363. */
  111364. luminanceDownSamplePostProcesses: PostProcess[];
  111365. /**
  111366. * Post-process used to create a HDR effect (light adaptation)
  111367. */
  111368. hdrPostProcess: Nullable<PostProcess>;
  111369. /**
  111370. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  111371. */
  111372. textureAdderFinalPostProcess: Nullable<PostProcess>;
  111373. /**
  111374. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  111375. */
  111376. lensFlareFinalPostProcess: Nullable<PostProcess>;
  111377. /**
  111378. * Post-process used to merge the final HDR post-process and the real scene color
  111379. */
  111380. hdrFinalPostProcess: Nullable<PostProcess>;
  111381. /**
  111382. * Post-process used to create a lens flare effect
  111383. */
  111384. lensFlarePostProcess: Nullable<PostProcess>;
  111385. /**
  111386. * Post-process that merges the result of the lens flare post-process and the real scene color
  111387. */
  111388. lensFlareComposePostProcess: Nullable<PostProcess>;
  111389. /**
  111390. * Post-process used to create a motion blur effect
  111391. */
  111392. motionBlurPostProcess: Nullable<PostProcess>;
  111393. /**
  111394. * Post-process used to create a depth of field effect
  111395. */
  111396. depthOfFieldPostProcess: Nullable<PostProcess>;
  111397. /**
  111398. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111399. */
  111400. fxaaPostProcess: Nullable<FxaaPostProcess>;
  111401. /**
  111402. * Represents the brightness threshold in order to configure the illuminated surfaces
  111403. */
  111404. brightThreshold: number;
  111405. /**
  111406. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  111407. */
  111408. blurWidth: number;
  111409. /**
  111410. * Sets if the blur for highlighted surfaces must be only horizontal
  111411. */
  111412. horizontalBlur: boolean;
  111413. /**
  111414. * Sets the overall exposure used by the pipeline
  111415. */
  111416. exposure: number;
  111417. /**
  111418. * Texture used typically to simulate "dirty" on camera lens
  111419. */
  111420. lensTexture: Nullable<Texture>;
  111421. /**
  111422. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  111423. */
  111424. volumetricLightCoefficient: number;
  111425. /**
  111426. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  111427. */
  111428. volumetricLightPower: number;
  111429. /**
  111430. * Used the set the blur intensity to smooth the volumetric lights
  111431. */
  111432. volumetricLightBlurScale: number;
  111433. /**
  111434. * Light (spot or directional) used to generate the volumetric lights rays
  111435. * The source light must have a shadow generate so the pipeline can get its
  111436. * depth map
  111437. */
  111438. sourceLight: Nullable<SpotLight | DirectionalLight>;
  111439. /**
  111440. * For eye adaptation, represents the minimum luminance the eye can see
  111441. */
  111442. hdrMinimumLuminance: number;
  111443. /**
  111444. * For eye adaptation, represents the decrease luminance speed
  111445. */
  111446. hdrDecreaseRate: number;
  111447. /**
  111448. * For eye adaptation, represents the increase luminance speed
  111449. */
  111450. hdrIncreaseRate: number;
  111451. /**
  111452. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  111453. */
  111454. lensColorTexture: Nullable<Texture>;
  111455. /**
  111456. * The overall strengh for the lens flare effect
  111457. */
  111458. lensFlareStrength: number;
  111459. /**
  111460. * Dispersion coefficient for lens flare ghosts
  111461. */
  111462. lensFlareGhostDispersal: number;
  111463. /**
  111464. * Main lens flare halo width
  111465. */
  111466. lensFlareHaloWidth: number;
  111467. /**
  111468. * Based on the lens distortion effect, defines how much the lens flare result
  111469. * is distorted
  111470. */
  111471. lensFlareDistortionStrength: number;
  111472. /**
  111473. * Lens star texture must be used to simulate rays on the flares and is available
  111474. * in the documentation
  111475. */
  111476. lensStarTexture: Nullable<Texture>;
  111477. /**
  111478. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  111479. * flare effect by taking account of the dirt texture
  111480. */
  111481. lensFlareDirtTexture: Nullable<Texture>;
  111482. /**
  111483. * Represents the focal length for the depth of field effect
  111484. */
  111485. depthOfFieldDistance: number;
  111486. /**
  111487. * Represents the blur intensity for the blurred part of the depth of field effect
  111488. */
  111489. depthOfFieldBlurWidth: number;
  111490. /**
  111491. * For motion blur, defines how much the image is blurred by the movement
  111492. */
  111493. motionStrength: number;
  111494. /**
  111495. * List of animations for the pipeline (IAnimatable implementation)
  111496. */
  111497. animations: Animation[];
  111498. /**
  111499. * Private members
  111500. */
  111501. private _scene;
  111502. private _currentDepthOfFieldSource;
  111503. private _basePostProcess;
  111504. private _hdrCurrentLuminance;
  111505. private _floatTextureType;
  111506. private _ratio;
  111507. private _bloomEnabled;
  111508. private _depthOfFieldEnabled;
  111509. private _vlsEnabled;
  111510. private _lensFlareEnabled;
  111511. private _hdrEnabled;
  111512. private _motionBlurEnabled;
  111513. private _fxaaEnabled;
  111514. private _motionBlurSamples;
  111515. private _volumetricLightStepsCount;
  111516. private _samples;
  111517. /**
  111518. * @ignore
  111519. * Specifies if the bloom pipeline is enabled
  111520. */
  111521. BloomEnabled: boolean;
  111522. /**
  111523. * @ignore
  111524. * Specifies if the depth of field pipeline is enabed
  111525. */
  111526. DepthOfFieldEnabled: boolean;
  111527. /**
  111528. * @ignore
  111529. * Specifies if the lens flare pipeline is enabed
  111530. */
  111531. LensFlareEnabled: boolean;
  111532. /**
  111533. * @ignore
  111534. * Specifies if the HDR pipeline is enabled
  111535. */
  111536. HDREnabled: boolean;
  111537. /**
  111538. * @ignore
  111539. * Specifies if the volumetric lights scattering effect is enabled
  111540. */
  111541. VLSEnabled: boolean;
  111542. /**
  111543. * @ignore
  111544. * Specifies if the motion blur effect is enabled
  111545. */
  111546. MotionBlurEnabled: boolean;
  111547. /**
  111548. * Specifies if anti-aliasing is enabled
  111549. */
  111550. fxaaEnabled: boolean;
  111551. /**
  111552. * Specifies the number of steps used to calculate the volumetric lights
  111553. * Typically in interval [50, 200]
  111554. */
  111555. volumetricLightStepsCount: number;
  111556. /**
  111557. * Specifies the number of samples used for the motion blur effect
  111558. * Typically in interval [16, 64]
  111559. */
  111560. motionBlurSamples: number;
  111561. /**
  111562. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111563. */
  111564. samples: number;
  111565. /**
  111566. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111567. * @constructor
  111568. * @param name The rendering pipeline name
  111569. * @param scene The scene linked to this pipeline
  111570. * @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)
  111571. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  111572. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111573. */
  111574. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  111575. private _buildPipeline;
  111576. private _createDownSampleX4PostProcess;
  111577. private _createBrightPassPostProcess;
  111578. private _createBlurPostProcesses;
  111579. private _createTextureAdderPostProcess;
  111580. private _createVolumetricLightPostProcess;
  111581. private _createLuminancePostProcesses;
  111582. private _createHdrPostProcess;
  111583. private _createLensFlarePostProcess;
  111584. private _createDepthOfFieldPostProcess;
  111585. private _createMotionBlurPostProcess;
  111586. private _getDepthTexture;
  111587. private _disposePostProcesses;
  111588. /**
  111589. * Dispose of the pipeline and stop all post processes
  111590. */
  111591. dispose(): void;
  111592. /**
  111593. * Serialize the rendering pipeline (Used when exporting)
  111594. * @returns the serialized object
  111595. */
  111596. serialize(): any;
  111597. /**
  111598. * Parse the serialized pipeline
  111599. * @param source Source pipeline.
  111600. * @param scene The scene to load the pipeline to.
  111601. * @param rootUrl The URL of the serialized pipeline.
  111602. * @returns An instantiated pipeline from the serialized object.
  111603. */
  111604. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  111605. /**
  111606. * Luminance steps
  111607. */
  111608. static LuminanceSteps: number;
  111609. }
  111610. }
  111611. declare module BABYLON {
  111612. /** @hidden */
  111613. export var tonemapPixelShader: {
  111614. name: string;
  111615. shader: string;
  111616. };
  111617. }
  111618. declare module BABYLON {
  111619. /** Defines operator used for tonemapping */
  111620. export enum TonemappingOperator {
  111621. /** Hable */
  111622. Hable = 0,
  111623. /** Reinhard */
  111624. Reinhard = 1,
  111625. /** HejiDawson */
  111626. HejiDawson = 2,
  111627. /** Photographic */
  111628. Photographic = 3
  111629. }
  111630. /**
  111631. * Defines a post process to apply tone mapping
  111632. */
  111633. export class TonemapPostProcess extends PostProcess {
  111634. private _operator;
  111635. /** Defines the required exposure adjustement */
  111636. exposureAdjustment: number;
  111637. /**
  111638. * Creates a new TonemapPostProcess
  111639. * @param name defines the name of the postprocess
  111640. * @param _operator defines the operator to use
  111641. * @param exposureAdjustment defines the required exposure adjustement
  111642. * @param camera defines the camera to use (can be null)
  111643. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  111644. * @param engine defines the hosting engine (can be ignore if camera is set)
  111645. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  111646. */
  111647. constructor(name: string, _operator: TonemappingOperator,
  111648. /** Defines the required exposure adjustement */
  111649. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  111650. }
  111651. }
  111652. declare module BABYLON {
  111653. /** @hidden */
  111654. export var depthVertexShader: {
  111655. name: string;
  111656. shader: string;
  111657. };
  111658. }
  111659. declare module BABYLON {
  111660. /** @hidden */
  111661. export var volumetricLightScatteringPixelShader: {
  111662. name: string;
  111663. shader: string;
  111664. };
  111665. }
  111666. declare module BABYLON {
  111667. /** @hidden */
  111668. export var volumetricLightScatteringPassPixelShader: {
  111669. name: string;
  111670. shader: string;
  111671. };
  111672. }
  111673. declare module BABYLON {
  111674. /**
  111675. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  111676. */
  111677. export class VolumetricLightScatteringPostProcess extends PostProcess {
  111678. private _volumetricLightScatteringPass;
  111679. private _volumetricLightScatteringRTT;
  111680. private _viewPort;
  111681. private _screenCoordinates;
  111682. private _cachedDefines;
  111683. /**
  111684. * If not undefined, the mesh position is computed from the attached node position
  111685. */
  111686. attachedNode: {
  111687. position: Vector3;
  111688. };
  111689. /**
  111690. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  111691. */
  111692. customMeshPosition: Vector3;
  111693. /**
  111694. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  111695. */
  111696. useCustomMeshPosition: boolean;
  111697. /**
  111698. * If the post-process should inverse the light scattering direction
  111699. */
  111700. invert: boolean;
  111701. /**
  111702. * The internal mesh used by the post-process
  111703. */
  111704. mesh: Mesh;
  111705. /**
  111706. * @hidden
  111707. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  111708. */
  111709. useDiffuseColor: boolean;
  111710. /**
  111711. * Array containing the excluded meshes not rendered in the internal pass
  111712. */
  111713. excludedMeshes: AbstractMesh[];
  111714. /**
  111715. * Controls the overall intensity of the post-process
  111716. */
  111717. exposure: number;
  111718. /**
  111719. * Dissipates each sample's contribution in range [0, 1]
  111720. */
  111721. decay: number;
  111722. /**
  111723. * Controls the overall intensity of each sample
  111724. */
  111725. weight: number;
  111726. /**
  111727. * Controls the density of each sample
  111728. */
  111729. density: number;
  111730. /**
  111731. * @constructor
  111732. * @param name The post-process name
  111733. * @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)
  111734. * @param camera The camera that the post-process will be attached to
  111735. * @param mesh The mesh used to create the light scattering
  111736. * @param samples The post-process quality, default 100
  111737. * @param samplingModeThe post-process filtering mode
  111738. * @param engine The babylon engine
  111739. * @param reusable If the post-process is reusable
  111740. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  111741. */
  111742. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  111743. /**
  111744. * Returns the string "VolumetricLightScatteringPostProcess"
  111745. * @returns "VolumetricLightScatteringPostProcess"
  111746. */
  111747. getClassName(): string;
  111748. private _isReady;
  111749. /**
  111750. * Sets the new light position for light scattering effect
  111751. * @param position The new custom light position
  111752. */
  111753. setCustomMeshPosition(position: Vector3): void;
  111754. /**
  111755. * Returns the light position for light scattering effect
  111756. * @return Vector3 The custom light position
  111757. */
  111758. getCustomMeshPosition(): Vector3;
  111759. /**
  111760. * Disposes the internal assets and detaches the post-process from the camera
  111761. */
  111762. dispose(camera: Camera): void;
  111763. /**
  111764. * Returns the render target texture used by the post-process
  111765. * @return the render target texture used by the post-process
  111766. */
  111767. getPass(): RenderTargetTexture;
  111768. private _meshExcluded;
  111769. private _createPass;
  111770. private _updateMeshScreenCoordinates;
  111771. /**
  111772. * Creates a default mesh for the Volumeric Light Scattering post-process
  111773. * @param name The mesh name
  111774. * @param scene The scene where to create the mesh
  111775. * @return the default mesh
  111776. */
  111777. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  111778. }
  111779. }
  111780. declare module BABYLON {
  111781. interface Scene {
  111782. /** @hidden (Backing field) */
  111783. _boundingBoxRenderer: BoundingBoxRenderer;
  111784. /** @hidden (Backing field) */
  111785. _forceShowBoundingBoxes: boolean;
  111786. /**
  111787. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  111788. */
  111789. forceShowBoundingBoxes: boolean;
  111790. /**
  111791. * Gets the bounding box renderer associated with the scene
  111792. * @returns a BoundingBoxRenderer
  111793. */
  111794. getBoundingBoxRenderer(): BoundingBoxRenderer;
  111795. }
  111796. interface AbstractMesh {
  111797. /** @hidden (Backing field) */
  111798. _showBoundingBox: boolean;
  111799. /**
  111800. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  111801. */
  111802. showBoundingBox: boolean;
  111803. }
  111804. /**
  111805. * Component responsible of rendering the bounding box of the meshes in a scene.
  111806. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  111807. */
  111808. export class BoundingBoxRenderer implements ISceneComponent {
  111809. /**
  111810. * The component name helpfull to identify the component in the list of scene components.
  111811. */
  111812. readonly name: string;
  111813. /**
  111814. * The scene the component belongs to.
  111815. */
  111816. scene: Scene;
  111817. /**
  111818. * Color of the bounding box lines placed in front of an object
  111819. */
  111820. frontColor: Color3;
  111821. /**
  111822. * Color of the bounding box lines placed behind an object
  111823. */
  111824. backColor: Color3;
  111825. /**
  111826. * Defines if the renderer should show the back lines or not
  111827. */
  111828. showBackLines: boolean;
  111829. /**
  111830. * @hidden
  111831. */
  111832. renderList: SmartArray<BoundingBox>;
  111833. private _colorShader;
  111834. private _vertexBuffers;
  111835. private _indexBuffer;
  111836. /**
  111837. * Instantiates a new bounding box renderer in a scene.
  111838. * @param scene the scene the renderer renders in
  111839. */
  111840. constructor(scene: Scene);
  111841. /**
  111842. * Registers the component in a given scene
  111843. */
  111844. register(): void;
  111845. private _evaluateSubMesh;
  111846. private _activeMesh;
  111847. private _prepareRessources;
  111848. private _createIndexBuffer;
  111849. /**
  111850. * Rebuilds the elements related to this component in case of
  111851. * context lost for instance.
  111852. */
  111853. rebuild(): void;
  111854. /**
  111855. * @hidden
  111856. */
  111857. reset(): void;
  111858. /**
  111859. * Render the bounding boxes of a specific rendering group
  111860. * @param renderingGroupId defines the rendering group to render
  111861. */
  111862. render(renderingGroupId: number): void;
  111863. /**
  111864. * In case of occlusion queries, we can render the occlusion bounding box through this method
  111865. * @param mesh Define the mesh to render the occlusion bounding box for
  111866. */
  111867. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  111868. /**
  111869. * Dispose and release the resources attached to this renderer.
  111870. */
  111871. dispose(): void;
  111872. }
  111873. }
  111874. declare module BABYLON {
  111875. /** @hidden */
  111876. export var depthPixelShader: {
  111877. name: string;
  111878. shader: string;
  111879. };
  111880. }
  111881. declare module BABYLON {
  111882. /**
  111883. * This represents a depth renderer in Babylon.
  111884. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  111885. */
  111886. export class DepthRenderer {
  111887. private _scene;
  111888. private _depthMap;
  111889. private _effect;
  111890. private _cachedDefines;
  111891. private _camera;
  111892. /**
  111893. * Specifiess that the depth renderer will only be used within
  111894. * the camera it is created for.
  111895. * This can help forcing its rendering during the camera processing.
  111896. */
  111897. useOnlyInActiveCamera: boolean;
  111898. /** @hidden */
  111899. static _SceneComponentInitialization: (scene: Scene) => void;
  111900. /**
  111901. * Instantiates a depth renderer
  111902. * @param scene The scene the renderer belongs to
  111903. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  111904. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  111905. */
  111906. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  111907. /**
  111908. * Creates the depth rendering effect and checks if the effect is ready.
  111909. * @param subMesh The submesh to be used to render the depth map of
  111910. * @param useInstances If multiple world instances should be used
  111911. * @returns if the depth renderer is ready to render the depth map
  111912. */
  111913. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111914. /**
  111915. * Gets the texture which the depth map will be written to.
  111916. * @returns The depth map texture
  111917. */
  111918. getDepthMap(): RenderTargetTexture;
  111919. /**
  111920. * Disposes of the depth renderer.
  111921. */
  111922. dispose(): void;
  111923. }
  111924. }
  111925. declare module BABYLON {
  111926. interface Scene {
  111927. /** @hidden (Backing field) */
  111928. _depthRenderer: {
  111929. [id: string]: DepthRenderer;
  111930. };
  111931. /**
  111932. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  111933. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  111934. * @returns the created depth renderer
  111935. */
  111936. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  111937. /**
  111938. * Disables a depth renderer for a given camera
  111939. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  111940. */
  111941. disableDepthRenderer(camera?: Nullable<Camera>): void;
  111942. }
  111943. /**
  111944. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  111945. * in several rendering techniques.
  111946. */
  111947. export class DepthRendererSceneComponent implements ISceneComponent {
  111948. /**
  111949. * The component name helpfull to identify the component in the list of scene components.
  111950. */
  111951. readonly name: string;
  111952. /**
  111953. * The scene the component belongs to.
  111954. */
  111955. scene: Scene;
  111956. /**
  111957. * Creates a new instance of the component for the given scene
  111958. * @param scene Defines the scene to register the component in
  111959. */
  111960. constructor(scene: Scene);
  111961. /**
  111962. * Registers the component in a given scene
  111963. */
  111964. register(): void;
  111965. /**
  111966. * Rebuilds the elements related to this component in case of
  111967. * context lost for instance.
  111968. */
  111969. rebuild(): void;
  111970. /**
  111971. * Disposes the component and the associated ressources
  111972. */
  111973. dispose(): void;
  111974. private _gatherRenderTargets;
  111975. private _gatherActiveCameraRenderTargets;
  111976. }
  111977. }
  111978. declare module BABYLON {
  111979. /** @hidden */
  111980. export var outlinePixelShader: {
  111981. name: string;
  111982. shader: string;
  111983. };
  111984. }
  111985. declare module BABYLON {
  111986. /** @hidden */
  111987. export var outlineVertexShader: {
  111988. name: string;
  111989. shader: string;
  111990. };
  111991. }
  111992. declare module BABYLON {
  111993. interface Scene {
  111994. /** @hidden */
  111995. _outlineRenderer: OutlineRenderer;
  111996. /**
  111997. * Gets the outline renderer associated with the scene
  111998. * @returns a OutlineRenderer
  111999. */
  112000. getOutlineRenderer(): OutlineRenderer;
  112001. }
  112002. interface AbstractMesh {
  112003. /** @hidden (Backing field) */
  112004. _renderOutline: boolean;
  112005. /**
  112006. * Gets or sets a boolean indicating if the outline must be rendered as well
  112007. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  112008. */
  112009. renderOutline: boolean;
  112010. /** @hidden (Backing field) */
  112011. _renderOverlay: boolean;
  112012. /**
  112013. * Gets or sets a boolean indicating if the overlay must be rendered as well
  112014. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  112015. */
  112016. renderOverlay: boolean;
  112017. }
  112018. /**
  112019. * This class is responsible to draw bothe outline/overlay of meshes.
  112020. * It should not be used directly but through the available method on mesh.
  112021. */
  112022. export class OutlineRenderer implements ISceneComponent {
  112023. /**
  112024. * The name of the component. Each component must have a unique name.
  112025. */
  112026. name: string;
  112027. /**
  112028. * The scene the component belongs to.
  112029. */
  112030. scene: Scene;
  112031. /**
  112032. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  112033. */
  112034. zOffset: number;
  112035. private _engine;
  112036. private _effect;
  112037. private _cachedDefines;
  112038. private _savedDepthWrite;
  112039. /**
  112040. * Instantiates a new outline renderer. (There could be only one per scene).
  112041. * @param scene Defines the scene it belongs to
  112042. */
  112043. constructor(scene: Scene);
  112044. /**
  112045. * Register the component to one instance of a scene.
  112046. */
  112047. register(): void;
  112048. /**
  112049. * Rebuilds the elements related to this component in case of
  112050. * context lost for instance.
  112051. */
  112052. rebuild(): void;
  112053. /**
  112054. * Disposes the component and the associated ressources.
  112055. */
  112056. dispose(): void;
  112057. /**
  112058. * Renders the outline in the canvas.
  112059. * @param subMesh Defines the sumesh to render
  112060. * @param batch Defines the batch of meshes in case of instances
  112061. * @param useOverlay Defines if the rendering is for the overlay or the outline
  112062. */
  112063. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  112064. /**
  112065. * Returns whether or not the outline renderer is ready for a given submesh.
  112066. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  112067. * @param subMesh Defines the submesh to check readyness for
  112068. * @param useInstances Defines wheter wee are trying to render instances or not
  112069. * @returns true if ready otherwise false
  112070. */
  112071. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112072. private _beforeRenderingMesh;
  112073. private _afterRenderingMesh;
  112074. }
  112075. }
  112076. declare module BABYLON {
  112077. /**
  112078. * Defines the list of states available for a task inside a AssetsManager
  112079. */
  112080. export enum AssetTaskState {
  112081. /**
  112082. * Initialization
  112083. */
  112084. INIT = 0,
  112085. /**
  112086. * Running
  112087. */
  112088. RUNNING = 1,
  112089. /**
  112090. * Done
  112091. */
  112092. DONE = 2,
  112093. /**
  112094. * Error
  112095. */
  112096. ERROR = 3
  112097. }
  112098. /**
  112099. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  112100. */
  112101. export abstract class AbstractAssetTask {
  112102. /**
  112103. * Task name
  112104. */ name: string;
  112105. /**
  112106. * Callback called when the task is successful
  112107. */
  112108. onSuccess: (task: any) => void;
  112109. /**
  112110. * Callback called when the task is not successful
  112111. */
  112112. onError: (task: any, message?: string, exception?: any) => void;
  112113. /**
  112114. * Creates a new AssetsManager
  112115. * @param name defines the name of the task
  112116. */
  112117. constructor(
  112118. /**
  112119. * Task name
  112120. */ name: string);
  112121. private _isCompleted;
  112122. private _taskState;
  112123. private _errorObject;
  112124. /**
  112125. * Get if the task is completed
  112126. */
  112127. readonly isCompleted: boolean;
  112128. /**
  112129. * Gets the current state of the task
  112130. */
  112131. readonly taskState: AssetTaskState;
  112132. /**
  112133. * Gets the current error object (if task is in error)
  112134. */
  112135. readonly errorObject: {
  112136. message?: string;
  112137. exception?: any;
  112138. };
  112139. /**
  112140. * Internal only
  112141. * @hidden
  112142. */
  112143. _setErrorObject(message?: string, exception?: any): void;
  112144. /**
  112145. * Execute the current task
  112146. * @param scene defines the scene where you want your assets to be loaded
  112147. * @param onSuccess is a callback called when the task is successfully executed
  112148. * @param onError is a callback called if an error occurs
  112149. */
  112150. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112151. /**
  112152. * Execute the current task
  112153. * @param scene defines the scene where you want your assets to be loaded
  112154. * @param onSuccess is a callback called when the task is successfully executed
  112155. * @param onError is a callback called if an error occurs
  112156. */
  112157. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112158. /**
  112159. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  112160. * This can be used with failed tasks that have the reason for failure fixed.
  112161. */
  112162. reset(): void;
  112163. private onErrorCallback;
  112164. private onDoneCallback;
  112165. }
  112166. /**
  112167. * Define the interface used by progress events raised during assets loading
  112168. */
  112169. export interface IAssetsProgressEvent {
  112170. /**
  112171. * Defines the number of remaining tasks to process
  112172. */
  112173. remainingCount: number;
  112174. /**
  112175. * Defines the total number of tasks
  112176. */
  112177. totalCount: number;
  112178. /**
  112179. * Defines the task that was just processed
  112180. */
  112181. task: AbstractAssetTask;
  112182. }
  112183. /**
  112184. * Class used to share progress information about assets loading
  112185. */
  112186. export class AssetsProgressEvent implements IAssetsProgressEvent {
  112187. /**
  112188. * Defines the number of remaining tasks to process
  112189. */
  112190. remainingCount: number;
  112191. /**
  112192. * Defines the total number of tasks
  112193. */
  112194. totalCount: number;
  112195. /**
  112196. * Defines the task that was just processed
  112197. */
  112198. task: AbstractAssetTask;
  112199. /**
  112200. * Creates a AssetsProgressEvent
  112201. * @param remainingCount defines the number of remaining tasks to process
  112202. * @param totalCount defines the total number of tasks
  112203. * @param task defines the task that was just processed
  112204. */
  112205. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  112206. }
  112207. /**
  112208. * Define a task used by AssetsManager to load meshes
  112209. */
  112210. export class MeshAssetTask extends AbstractAssetTask {
  112211. /**
  112212. * Defines the name of the task
  112213. */
  112214. name: string;
  112215. /**
  112216. * Defines the list of mesh's names you want to load
  112217. */
  112218. meshesNames: any;
  112219. /**
  112220. * Defines the root url to use as a base to load your meshes and associated resources
  112221. */
  112222. rootUrl: string;
  112223. /**
  112224. * Defines the filename of the scene to load from
  112225. */
  112226. sceneFilename: string;
  112227. /**
  112228. * Gets the list of loaded meshes
  112229. */
  112230. loadedMeshes: Array<AbstractMesh>;
  112231. /**
  112232. * Gets the list of loaded particle systems
  112233. */
  112234. loadedParticleSystems: Array<IParticleSystem>;
  112235. /**
  112236. * Gets the list of loaded skeletons
  112237. */
  112238. loadedSkeletons: Array<Skeleton>;
  112239. /**
  112240. * Gets the list of loaded animation groups
  112241. */
  112242. loadedAnimationGroups: Array<AnimationGroup>;
  112243. /**
  112244. * Callback called when the task is successful
  112245. */
  112246. onSuccess: (task: MeshAssetTask) => void;
  112247. /**
  112248. * Callback called when the task is successful
  112249. */
  112250. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  112251. /**
  112252. * Creates a new MeshAssetTask
  112253. * @param name defines the name of the task
  112254. * @param meshesNames defines the list of mesh's names you want to load
  112255. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  112256. * @param sceneFilename defines the filename of the scene to load from
  112257. */
  112258. constructor(
  112259. /**
  112260. * Defines the name of the task
  112261. */
  112262. name: string,
  112263. /**
  112264. * Defines the list of mesh's names you want to load
  112265. */
  112266. meshesNames: any,
  112267. /**
  112268. * Defines the root url to use as a base to load your meshes and associated resources
  112269. */
  112270. rootUrl: string,
  112271. /**
  112272. * Defines the filename of the scene to load from
  112273. */
  112274. sceneFilename: string);
  112275. /**
  112276. * Execute the current task
  112277. * @param scene defines the scene where you want your assets to be loaded
  112278. * @param onSuccess is a callback called when the task is successfully executed
  112279. * @param onError is a callback called if an error occurs
  112280. */
  112281. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112282. }
  112283. /**
  112284. * Define a task used by AssetsManager to load text content
  112285. */
  112286. export class TextFileAssetTask extends AbstractAssetTask {
  112287. /**
  112288. * Defines the name of the task
  112289. */
  112290. name: string;
  112291. /**
  112292. * Defines the location of the file to load
  112293. */
  112294. url: string;
  112295. /**
  112296. * Gets the loaded text string
  112297. */
  112298. text: string;
  112299. /**
  112300. * Callback called when the task is successful
  112301. */
  112302. onSuccess: (task: TextFileAssetTask) => void;
  112303. /**
  112304. * Callback called when the task is successful
  112305. */
  112306. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  112307. /**
  112308. * Creates a new TextFileAssetTask object
  112309. * @param name defines the name of the task
  112310. * @param url defines the location of the file to load
  112311. */
  112312. constructor(
  112313. /**
  112314. * Defines the name of the task
  112315. */
  112316. name: string,
  112317. /**
  112318. * Defines the location of the file to load
  112319. */
  112320. url: string);
  112321. /**
  112322. * Execute the current task
  112323. * @param scene defines the scene where you want your assets to be loaded
  112324. * @param onSuccess is a callback called when the task is successfully executed
  112325. * @param onError is a callback called if an error occurs
  112326. */
  112327. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112328. }
  112329. /**
  112330. * Define a task used by AssetsManager to load binary data
  112331. */
  112332. export class BinaryFileAssetTask extends AbstractAssetTask {
  112333. /**
  112334. * Defines the name of the task
  112335. */
  112336. name: string;
  112337. /**
  112338. * Defines the location of the file to load
  112339. */
  112340. url: string;
  112341. /**
  112342. * Gets the lodaded data (as an array buffer)
  112343. */
  112344. data: ArrayBuffer;
  112345. /**
  112346. * Callback called when the task is successful
  112347. */
  112348. onSuccess: (task: BinaryFileAssetTask) => void;
  112349. /**
  112350. * Callback called when the task is successful
  112351. */
  112352. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  112353. /**
  112354. * Creates a new BinaryFileAssetTask object
  112355. * @param name defines the name of the new task
  112356. * @param url defines the location of the file to load
  112357. */
  112358. constructor(
  112359. /**
  112360. * Defines the name of the task
  112361. */
  112362. name: string,
  112363. /**
  112364. * Defines the location of the file to load
  112365. */
  112366. url: string);
  112367. /**
  112368. * Execute the current task
  112369. * @param scene defines the scene where you want your assets to be loaded
  112370. * @param onSuccess is a callback called when the task is successfully executed
  112371. * @param onError is a callback called if an error occurs
  112372. */
  112373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112374. }
  112375. /**
  112376. * Define a task used by AssetsManager to load images
  112377. */
  112378. export class ImageAssetTask extends AbstractAssetTask {
  112379. /**
  112380. * Defines the name of the task
  112381. */
  112382. name: string;
  112383. /**
  112384. * Defines the location of the image to load
  112385. */
  112386. url: string;
  112387. /**
  112388. * Gets the loaded images
  112389. */
  112390. image: HTMLImageElement;
  112391. /**
  112392. * Callback called when the task is successful
  112393. */
  112394. onSuccess: (task: ImageAssetTask) => void;
  112395. /**
  112396. * Callback called when the task is successful
  112397. */
  112398. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  112399. /**
  112400. * Creates a new ImageAssetTask
  112401. * @param name defines the name of the task
  112402. * @param url defines the location of the image to load
  112403. */
  112404. constructor(
  112405. /**
  112406. * Defines the name of the task
  112407. */
  112408. name: string,
  112409. /**
  112410. * Defines the location of the image to load
  112411. */
  112412. url: string);
  112413. /**
  112414. * Execute the current task
  112415. * @param scene defines the scene where you want your assets to be loaded
  112416. * @param onSuccess is a callback called when the task is successfully executed
  112417. * @param onError is a callback called if an error occurs
  112418. */
  112419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112420. }
  112421. /**
  112422. * Defines the interface used by texture loading tasks
  112423. */
  112424. export interface ITextureAssetTask<TEX extends BaseTexture> {
  112425. /**
  112426. * Gets the loaded texture
  112427. */
  112428. texture: TEX;
  112429. }
  112430. /**
  112431. * Define a task used by AssetsManager to load 2D textures
  112432. */
  112433. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  112434. /**
  112435. * Defines the name of the task
  112436. */
  112437. name: string;
  112438. /**
  112439. * Defines the location of the file to load
  112440. */
  112441. url: string;
  112442. /**
  112443. * Defines if mipmap should not be generated (default is false)
  112444. */
  112445. noMipmap?: boolean | undefined;
  112446. /**
  112447. * Defines if texture must be inverted on Y axis (default is false)
  112448. */
  112449. invertY?: boolean | undefined;
  112450. /**
  112451. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112452. */
  112453. samplingMode: number;
  112454. /**
  112455. * Gets the loaded texture
  112456. */
  112457. texture: Texture;
  112458. /**
  112459. * Callback called when the task is successful
  112460. */
  112461. onSuccess: (task: TextureAssetTask) => void;
  112462. /**
  112463. * Callback called when the task is successful
  112464. */
  112465. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  112466. /**
  112467. * Creates a new TextureAssetTask object
  112468. * @param name defines the name of the task
  112469. * @param url defines the location of the file to load
  112470. * @param noMipmap defines if mipmap should not be generated (default is false)
  112471. * @param invertY defines if texture must be inverted on Y axis (default is false)
  112472. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112473. */
  112474. constructor(
  112475. /**
  112476. * Defines the name of the task
  112477. */
  112478. name: string,
  112479. /**
  112480. * Defines the location of the file to load
  112481. */
  112482. url: string,
  112483. /**
  112484. * Defines if mipmap should not be generated (default is false)
  112485. */
  112486. noMipmap?: boolean | undefined,
  112487. /**
  112488. * Defines if texture must be inverted on Y axis (default is false)
  112489. */
  112490. invertY?: boolean | undefined,
  112491. /**
  112492. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112493. */
  112494. samplingMode?: number);
  112495. /**
  112496. * Execute the current task
  112497. * @param scene defines the scene where you want your assets to be loaded
  112498. * @param onSuccess is a callback called when the task is successfully executed
  112499. * @param onError is a callback called if an error occurs
  112500. */
  112501. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112502. }
  112503. /**
  112504. * Define a task used by AssetsManager to load cube textures
  112505. */
  112506. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  112507. /**
  112508. * Defines the name of the task
  112509. */
  112510. name: string;
  112511. /**
  112512. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112513. */
  112514. url: string;
  112515. /**
  112516. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112517. */
  112518. extensions?: string[] | undefined;
  112519. /**
  112520. * Defines if mipmaps should not be generated (default is false)
  112521. */
  112522. noMipmap?: boolean | undefined;
  112523. /**
  112524. * Defines the explicit list of files (undefined by default)
  112525. */
  112526. files?: string[] | undefined;
  112527. /**
  112528. * Gets the loaded texture
  112529. */
  112530. texture: CubeTexture;
  112531. /**
  112532. * Callback called when the task is successful
  112533. */
  112534. onSuccess: (task: CubeTextureAssetTask) => void;
  112535. /**
  112536. * Callback called when the task is successful
  112537. */
  112538. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  112539. /**
  112540. * Creates a new CubeTextureAssetTask
  112541. * @param name defines the name of the task
  112542. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112543. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112544. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112545. * @param files defines the explicit list of files (undefined by default)
  112546. */
  112547. constructor(
  112548. /**
  112549. * Defines the name of the task
  112550. */
  112551. name: string,
  112552. /**
  112553. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112554. */
  112555. url: string,
  112556. /**
  112557. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112558. */
  112559. extensions?: string[] | undefined,
  112560. /**
  112561. * Defines if mipmaps should not be generated (default is false)
  112562. */
  112563. noMipmap?: boolean | undefined,
  112564. /**
  112565. * Defines the explicit list of files (undefined by default)
  112566. */
  112567. files?: string[] | undefined);
  112568. /**
  112569. * Execute the current task
  112570. * @param scene defines the scene where you want your assets to be loaded
  112571. * @param onSuccess is a callback called when the task is successfully executed
  112572. * @param onError is a callback called if an error occurs
  112573. */
  112574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112575. }
  112576. /**
  112577. * Define a task used by AssetsManager to load HDR cube textures
  112578. */
  112579. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  112580. /**
  112581. * Defines the name of the task
  112582. */
  112583. name: string;
  112584. /**
  112585. * Defines the location of the file to load
  112586. */
  112587. url: string;
  112588. /**
  112589. * Defines the desired size (the more it increases the longer the generation will be)
  112590. */
  112591. size: number;
  112592. /**
  112593. * Defines if mipmaps should not be generated (default is false)
  112594. */
  112595. noMipmap: boolean;
  112596. /**
  112597. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112598. */
  112599. generateHarmonics: boolean;
  112600. /**
  112601. * 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)
  112602. */
  112603. gammaSpace: boolean;
  112604. /**
  112605. * Internal Use Only
  112606. */
  112607. reserved: boolean;
  112608. /**
  112609. * Gets the loaded texture
  112610. */
  112611. texture: HDRCubeTexture;
  112612. /**
  112613. * Callback called when the task is successful
  112614. */
  112615. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  112616. /**
  112617. * Callback called when the task is successful
  112618. */
  112619. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  112620. /**
  112621. * Creates a new HDRCubeTextureAssetTask object
  112622. * @param name defines the name of the task
  112623. * @param url defines the location of the file to load
  112624. * @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.
  112625. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112626. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112627. * @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)
  112628. * @param reserved Internal use only
  112629. */
  112630. constructor(
  112631. /**
  112632. * Defines the name of the task
  112633. */
  112634. name: string,
  112635. /**
  112636. * Defines the location of the file to load
  112637. */
  112638. url: string,
  112639. /**
  112640. * Defines the desired size (the more it increases the longer the generation will be)
  112641. */
  112642. size: number,
  112643. /**
  112644. * Defines if mipmaps should not be generated (default is false)
  112645. */
  112646. noMipmap?: boolean,
  112647. /**
  112648. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112649. */
  112650. generateHarmonics?: boolean,
  112651. /**
  112652. * 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)
  112653. */
  112654. gammaSpace?: boolean,
  112655. /**
  112656. * Internal Use Only
  112657. */
  112658. reserved?: boolean);
  112659. /**
  112660. * Execute the current task
  112661. * @param scene defines the scene where you want your assets to be loaded
  112662. * @param onSuccess is a callback called when the task is successfully executed
  112663. * @param onError is a callback called if an error occurs
  112664. */
  112665. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112666. }
  112667. /**
  112668. * This class can be used to easily import assets into a scene
  112669. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  112670. */
  112671. export class AssetsManager {
  112672. private _scene;
  112673. private _isLoading;
  112674. protected _tasks: AbstractAssetTask[];
  112675. protected _waitingTasksCount: number;
  112676. protected _totalTasksCount: number;
  112677. /**
  112678. * Callback called when all tasks are processed
  112679. */
  112680. onFinish: (tasks: AbstractAssetTask[]) => void;
  112681. /**
  112682. * Callback called when a task is successful
  112683. */
  112684. onTaskSuccess: (task: AbstractAssetTask) => void;
  112685. /**
  112686. * Callback called when a task had an error
  112687. */
  112688. onTaskError: (task: AbstractAssetTask) => void;
  112689. /**
  112690. * Callback called when a task is done (whatever the result is)
  112691. */
  112692. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  112693. /**
  112694. * Observable called when all tasks are processed
  112695. */
  112696. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  112697. /**
  112698. * Observable called when a task had an error
  112699. */
  112700. onTaskErrorObservable: Observable<AbstractAssetTask>;
  112701. /**
  112702. * Observable called when all tasks were executed
  112703. */
  112704. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  112705. /**
  112706. * Observable called when a task is done (whatever the result is)
  112707. */
  112708. onProgressObservable: Observable<IAssetsProgressEvent>;
  112709. /**
  112710. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  112711. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112712. */
  112713. useDefaultLoadingScreen: boolean;
  112714. /**
  112715. * Creates a new AssetsManager
  112716. * @param scene defines the scene to work on
  112717. */
  112718. constructor(scene: Scene);
  112719. /**
  112720. * Add a MeshAssetTask to the list of active tasks
  112721. * @param taskName defines the name of the new task
  112722. * @param meshesNames defines the name of meshes to load
  112723. * @param rootUrl defines the root url to use to locate files
  112724. * @param sceneFilename defines the filename of the scene file
  112725. * @returns a new MeshAssetTask object
  112726. */
  112727. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  112728. /**
  112729. * Add a TextFileAssetTask to the list of active tasks
  112730. * @param taskName defines the name of the new task
  112731. * @param url defines the url of the file to load
  112732. * @returns a new TextFileAssetTask object
  112733. */
  112734. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  112735. /**
  112736. * Add a BinaryFileAssetTask to the list of active tasks
  112737. * @param taskName defines the name of the new task
  112738. * @param url defines the url of the file to load
  112739. * @returns a new BinaryFileAssetTask object
  112740. */
  112741. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  112742. /**
  112743. * Add a ImageAssetTask to the list of active tasks
  112744. * @param taskName defines the name of the new task
  112745. * @param url defines the url of the file to load
  112746. * @returns a new ImageAssetTask object
  112747. */
  112748. addImageTask(taskName: string, url: string): ImageAssetTask;
  112749. /**
  112750. * Add a TextureAssetTask to the list of active tasks
  112751. * @param taskName defines the name of the new task
  112752. * @param url defines the url of the file to load
  112753. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112754. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  112755. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112756. * @returns a new TextureAssetTask object
  112757. */
  112758. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  112759. /**
  112760. * Add a CubeTextureAssetTask to the list of active tasks
  112761. * @param taskName defines the name of the new task
  112762. * @param url defines the url of the file to load
  112763. * @param extensions defines the extension to use to load the cube map (can be null)
  112764. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112765. * @param files defines the list of files to load (can be null)
  112766. * @returns a new CubeTextureAssetTask object
  112767. */
  112768. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  112769. /**
  112770. *
  112771. * Add a HDRCubeTextureAssetTask to the list of active tasks
  112772. * @param taskName defines the name of the new task
  112773. * @param url defines the url of the file to load
  112774. * @param size defines the size you want for the cubemap (can be null)
  112775. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112776. * @param generateHarmonics defines if you want to automatically generate (true by default)
  112777. * @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)
  112778. * @param reserved Internal use only
  112779. * @returns a new HDRCubeTextureAssetTask object
  112780. */
  112781. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  112782. /**
  112783. * Remove a task from the assets manager.
  112784. * @param task the task to remove
  112785. */
  112786. removeTask(task: AbstractAssetTask): void;
  112787. private _decreaseWaitingTasksCount;
  112788. private _runTask;
  112789. /**
  112790. * Reset the AssetsManager and remove all tasks
  112791. * @return the current instance of the AssetsManager
  112792. */
  112793. reset(): AssetsManager;
  112794. /**
  112795. * Start the loading process
  112796. * @return the current instance of the AssetsManager
  112797. */
  112798. load(): AssetsManager;
  112799. /**
  112800. * Start the loading process as an async operation
  112801. * @return a promise returning the list of failed tasks
  112802. */
  112803. loadAsync(): Promise<void>;
  112804. }
  112805. }
  112806. declare module BABYLON {
  112807. /**
  112808. * Wrapper class for promise with external resolve and reject.
  112809. */
  112810. export class Deferred<T> {
  112811. /**
  112812. * The promise associated with this deferred object.
  112813. */
  112814. readonly promise: Promise<T>;
  112815. private _resolve;
  112816. private _reject;
  112817. /**
  112818. * The resolve method of the promise associated with this deferred object.
  112819. */
  112820. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  112821. /**
  112822. * The reject method of the promise associated with this deferred object.
  112823. */
  112824. readonly reject: (reason?: any) => void;
  112825. /**
  112826. * Constructor for this deferred object.
  112827. */
  112828. constructor();
  112829. }
  112830. }
  112831. declare module BABYLON {
  112832. /**
  112833. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  112834. */
  112835. export class MeshExploder {
  112836. private _centerMesh;
  112837. private _meshes;
  112838. private _meshesOrigins;
  112839. private _toCenterVectors;
  112840. private _scaledDirection;
  112841. private _newPosition;
  112842. private _centerPosition;
  112843. /**
  112844. * Explodes meshes from a center mesh.
  112845. * @param meshes The meshes to explode.
  112846. * @param centerMesh The mesh to be center of explosion.
  112847. */
  112848. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  112849. private _setCenterMesh;
  112850. /**
  112851. * Get class name
  112852. * @returns "MeshExploder"
  112853. */
  112854. getClassName(): string;
  112855. /**
  112856. * "Exploded meshes"
  112857. * @returns Array of meshes with the centerMesh at index 0.
  112858. */
  112859. getMeshes(): Array<Mesh>;
  112860. /**
  112861. * Explodes meshes giving a specific direction
  112862. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  112863. */
  112864. explode(direction?: number): void;
  112865. }
  112866. }
  112867. declare module BABYLON {
  112868. /**
  112869. * Class used to help managing file picking and drag'n'drop
  112870. */
  112871. export class FilesInput {
  112872. /**
  112873. * List of files ready to be loaded
  112874. */
  112875. static readonly FilesToLoad: {
  112876. [key: string]: File;
  112877. };
  112878. /**
  112879. * Callback called when a file is processed
  112880. */
  112881. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  112882. private _engine;
  112883. private _currentScene;
  112884. private _sceneLoadedCallback;
  112885. private _progressCallback;
  112886. private _additionalRenderLoopLogicCallback;
  112887. private _textureLoadingCallback;
  112888. private _startingProcessingFilesCallback;
  112889. private _onReloadCallback;
  112890. private _errorCallback;
  112891. private _elementToMonitor;
  112892. private _sceneFileToLoad;
  112893. private _filesToLoad;
  112894. /**
  112895. * Creates a new FilesInput
  112896. * @param engine defines the rendering engine
  112897. * @param scene defines the hosting scene
  112898. * @param sceneLoadedCallback callback called when scene is loaded
  112899. * @param progressCallback callback called to track progress
  112900. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  112901. * @param textureLoadingCallback callback called when a texture is loading
  112902. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  112903. * @param onReloadCallback callback called when a reload is requested
  112904. * @param errorCallback callback call if an error occurs
  112905. */
  112906. 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);
  112907. private _dragEnterHandler;
  112908. private _dragOverHandler;
  112909. private _dropHandler;
  112910. /**
  112911. * Calls this function to listen to drag'n'drop events on a specific DOM element
  112912. * @param elementToMonitor defines the DOM element to track
  112913. */
  112914. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  112915. /**
  112916. * Release all associated resources
  112917. */
  112918. dispose(): void;
  112919. private renderFunction;
  112920. private drag;
  112921. private drop;
  112922. private _traverseFolder;
  112923. private _processFiles;
  112924. /**
  112925. * Load files from a drop event
  112926. * @param event defines the drop event to use as source
  112927. */
  112928. loadFiles(event: any): void;
  112929. private _processReload;
  112930. /**
  112931. * Reload the current scene from the loaded files
  112932. */
  112933. reload(): void;
  112934. }
  112935. }
  112936. declare module BABYLON {
  112937. /**
  112938. * Defines the root class used to create scene optimization to use with SceneOptimizer
  112939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112940. */
  112941. export class SceneOptimization {
  112942. /**
  112943. * Defines the priority of this optimization (0 by default which means first in the list)
  112944. */
  112945. priority: number;
  112946. /**
  112947. * Gets a string describing the action executed by the current optimization
  112948. * @returns description string
  112949. */
  112950. getDescription(): string;
  112951. /**
  112952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112953. * @param scene defines the current scene where to apply this optimization
  112954. * @param optimizer defines the current optimizer
  112955. * @returns true if everything that can be done was applied
  112956. */
  112957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112958. /**
  112959. * Creates the SceneOptimization object
  112960. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112961. * @param desc defines the description associated with the optimization
  112962. */
  112963. constructor(
  112964. /**
  112965. * Defines the priority of this optimization (0 by default which means first in the list)
  112966. */
  112967. priority?: number);
  112968. }
  112969. /**
  112970. * Defines an optimization used to reduce the size of render target textures
  112971. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112972. */
  112973. export class TextureOptimization extends SceneOptimization {
  112974. /**
  112975. * Defines the priority of this optimization (0 by default which means first in the list)
  112976. */
  112977. priority: number;
  112978. /**
  112979. * 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
  112980. */
  112981. maximumSize: number;
  112982. /**
  112983. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  112984. */
  112985. step: number;
  112986. /**
  112987. * Gets a string describing the action executed by the current optimization
  112988. * @returns description string
  112989. */
  112990. getDescription(): string;
  112991. /**
  112992. * Creates the TextureOptimization object
  112993. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112994. * @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
  112995. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  112996. */
  112997. constructor(
  112998. /**
  112999. * Defines the priority of this optimization (0 by default which means first in the list)
  113000. */
  113001. priority?: number,
  113002. /**
  113003. * 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
  113004. */
  113005. maximumSize?: number,
  113006. /**
  113007. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113008. */
  113009. step?: number);
  113010. /**
  113011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113012. * @param scene defines the current scene where to apply this optimization
  113013. * @param optimizer defines the current optimizer
  113014. * @returns true if everything that can be done was applied
  113015. */
  113016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113017. }
  113018. /**
  113019. * Defines an optimization used to increase or decrease the rendering resolution
  113020. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113021. */
  113022. export class HardwareScalingOptimization extends SceneOptimization {
  113023. /**
  113024. * Defines the priority of this optimization (0 by default which means first in the list)
  113025. */
  113026. priority: number;
  113027. /**
  113028. * Defines the maximum scale to use (2 by default)
  113029. */
  113030. maximumScale: number;
  113031. /**
  113032. * Defines the step to use between two passes (0.5 by default)
  113033. */
  113034. step: number;
  113035. private _currentScale;
  113036. private _directionOffset;
  113037. /**
  113038. * Gets a string describing the action executed by the current optimization
  113039. * @return description string
  113040. */
  113041. getDescription(): string;
  113042. /**
  113043. * Creates the HardwareScalingOptimization object
  113044. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113045. * @param maximumScale defines the maximum scale to use (2 by default)
  113046. * @param step defines the step to use between two passes (0.5 by default)
  113047. */
  113048. constructor(
  113049. /**
  113050. * Defines the priority of this optimization (0 by default which means first in the list)
  113051. */
  113052. priority?: number,
  113053. /**
  113054. * Defines the maximum scale to use (2 by default)
  113055. */
  113056. maximumScale?: number,
  113057. /**
  113058. * Defines the step to use between two passes (0.5 by default)
  113059. */
  113060. step?: number);
  113061. /**
  113062. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113063. * @param scene defines the current scene where to apply this optimization
  113064. * @param optimizer defines the current optimizer
  113065. * @returns true if everything that can be done was applied
  113066. */
  113067. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113068. }
  113069. /**
  113070. * Defines an optimization used to remove shadows
  113071. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113072. */
  113073. export class ShadowsOptimization extends SceneOptimization {
  113074. /**
  113075. * Gets a string describing the action executed by the current optimization
  113076. * @return description string
  113077. */
  113078. getDescription(): string;
  113079. /**
  113080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113081. * @param scene defines the current scene where to apply this optimization
  113082. * @param optimizer defines the current optimizer
  113083. * @returns true if everything that can be done was applied
  113084. */
  113085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113086. }
  113087. /**
  113088. * Defines an optimization used to turn post-processes off
  113089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113090. */
  113091. export class PostProcessesOptimization extends SceneOptimization {
  113092. /**
  113093. * Gets a string describing the action executed by the current optimization
  113094. * @return description string
  113095. */
  113096. getDescription(): string;
  113097. /**
  113098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113099. * @param scene defines the current scene where to apply this optimization
  113100. * @param optimizer defines the current optimizer
  113101. * @returns true if everything that can be done was applied
  113102. */
  113103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113104. }
  113105. /**
  113106. * Defines an optimization used to turn lens flares off
  113107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113108. */
  113109. export class LensFlaresOptimization extends SceneOptimization {
  113110. /**
  113111. * Gets a string describing the action executed by the current optimization
  113112. * @return description string
  113113. */
  113114. getDescription(): string;
  113115. /**
  113116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113117. * @param scene defines the current scene where to apply this optimization
  113118. * @param optimizer defines the current optimizer
  113119. * @returns true if everything that can be done was applied
  113120. */
  113121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113122. }
  113123. /**
  113124. * Defines an optimization based on user defined callback.
  113125. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113126. */
  113127. export class CustomOptimization extends SceneOptimization {
  113128. /**
  113129. * Callback called to apply the custom optimization.
  113130. */
  113131. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  113132. /**
  113133. * Callback called to get custom description
  113134. */
  113135. onGetDescription: () => string;
  113136. /**
  113137. * Gets a string describing the action executed by the current optimization
  113138. * @returns description string
  113139. */
  113140. getDescription(): string;
  113141. /**
  113142. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113143. * @param scene defines the current scene where to apply this optimization
  113144. * @param optimizer defines the current optimizer
  113145. * @returns true if everything that can be done was applied
  113146. */
  113147. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113148. }
  113149. /**
  113150. * Defines an optimization used to turn particles off
  113151. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113152. */
  113153. export class ParticlesOptimization extends SceneOptimization {
  113154. /**
  113155. * Gets a string describing the action executed by the current optimization
  113156. * @return description string
  113157. */
  113158. getDescription(): string;
  113159. /**
  113160. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113161. * @param scene defines the current scene where to apply this optimization
  113162. * @param optimizer defines the current optimizer
  113163. * @returns true if everything that can be done was applied
  113164. */
  113165. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113166. }
  113167. /**
  113168. * Defines an optimization used to turn render targets off
  113169. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113170. */
  113171. export class RenderTargetsOptimization extends SceneOptimization {
  113172. /**
  113173. * Gets a string describing the action executed by the current optimization
  113174. * @return description string
  113175. */
  113176. getDescription(): string;
  113177. /**
  113178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113179. * @param scene defines the current scene where to apply this optimization
  113180. * @param optimizer defines the current optimizer
  113181. * @returns true if everything that can be done was applied
  113182. */
  113183. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113184. }
  113185. /**
  113186. * Defines an optimization used to merge meshes with compatible materials
  113187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113188. */
  113189. export class MergeMeshesOptimization extends SceneOptimization {
  113190. private static _UpdateSelectionTree;
  113191. /**
  113192. * Gets or sets a boolean which defines if optimization octree has to be updated
  113193. */
  113194. /**
  113195. * Gets or sets a boolean which defines if optimization octree has to be updated
  113196. */
  113197. static UpdateSelectionTree: boolean;
  113198. /**
  113199. * Gets a string describing the action executed by the current optimization
  113200. * @return description string
  113201. */
  113202. getDescription(): string;
  113203. private _canBeMerged;
  113204. /**
  113205. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113206. * @param scene defines the current scene where to apply this optimization
  113207. * @param optimizer defines the current optimizer
  113208. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  113209. * @returns true if everything that can be done was applied
  113210. */
  113211. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  113212. }
  113213. /**
  113214. * Defines a list of options used by SceneOptimizer
  113215. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113216. */
  113217. export class SceneOptimizerOptions {
  113218. /**
  113219. * Defines the target frame rate to reach (60 by default)
  113220. */
  113221. targetFrameRate: number;
  113222. /**
  113223. * Defines the interval between two checkes (2000ms by default)
  113224. */
  113225. trackerDuration: number;
  113226. /**
  113227. * Gets the list of optimizations to apply
  113228. */
  113229. optimizations: SceneOptimization[];
  113230. /**
  113231. * Creates a new list of options used by SceneOptimizer
  113232. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  113233. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  113234. */
  113235. constructor(
  113236. /**
  113237. * Defines the target frame rate to reach (60 by default)
  113238. */
  113239. targetFrameRate?: number,
  113240. /**
  113241. * Defines the interval between two checkes (2000ms by default)
  113242. */
  113243. trackerDuration?: number);
  113244. /**
  113245. * Add a new optimization
  113246. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  113247. * @returns the current SceneOptimizerOptions
  113248. */
  113249. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  113250. /**
  113251. * Add a new custom optimization
  113252. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  113253. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  113254. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113255. * @returns the current SceneOptimizerOptions
  113256. */
  113257. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  113258. /**
  113259. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  113260. * @param targetFrameRate defines the target frame rate (60 by default)
  113261. * @returns a SceneOptimizerOptions object
  113262. */
  113263. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113264. /**
  113265. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  113266. * @param targetFrameRate defines the target frame rate (60 by default)
  113267. * @returns a SceneOptimizerOptions object
  113268. */
  113269. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113270. /**
  113271. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  113272. * @param targetFrameRate defines the target frame rate (60 by default)
  113273. * @returns a SceneOptimizerOptions object
  113274. */
  113275. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113276. }
  113277. /**
  113278. * Class used to run optimizations in order to reach a target frame rate
  113279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113280. */
  113281. export class SceneOptimizer implements IDisposable {
  113282. private _isRunning;
  113283. private _options;
  113284. private _scene;
  113285. private _currentPriorityLevel;
  113286. private _targetFrameRate;
  113287. private _trackerDuration;
  113288. private _currentFrameRate;
  113289. private _sceneDisposeObserver;
  113290. private _improvementMode;
  113291. /**
  113292. * Defines an observable called when the optimizer reaches the target frame rate
  113293. */
  113294. onSuccessObservable: Observable<SceneOptimizer>;
  113295. /**
  113296. * Defines an observable called when the optimizer enables an optimization
  113297. */
  113298. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  113299. /**
  113300. * Defines an observable called when the optimizer is not able to reach the target frame rate
  113301. */
  113302. onFailureObservable: Observable<SceneOptimizer>;
  113303. /**
  113304. * Gets a boolean indicating if the optimizer is in improvement mode
  113305. */
  113306. readonly isInImprovementMode: boolean;
  113307. /**
  113308. * Gets the current priority level (0 at start)
  113309. */
  113310. readonly currentPriorityLevel: number;
  113311. /**
  113312. * Gets the current frame rate checked by the SceneOptimizer
  113313. */
  113314. readonly currentFrameRate: number;
  113315. /**
  113316. * Gets or sets the current target frame rate (60 by default)
  113317. */
  113318. /**
  113319. * Gets or sets the current target frame rate (60 by default)
  113320. */
  113321. targetFrameRate: number;
  113322. /**
  113323. * Gets or sets the current interval between two checks (every 2000ms by default)
  113324. */
  113325. /**
  113326. * Gets or sets the current interval between two checks (every 2000ms by default)
  113327. */
  113328. trackerDuration: number;
  113329. /**
  113330. * Gets the list of active optimizations
  113331. */
  113332. readonly optimizations: SceneOptimization[];
  113333. /**
  113334. * Creates a new SceneOptimizer
  113335. * @param scene defines the scene to work on
  113336. * @param options defines the options to use with the SceneOptimizer
  113337. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  113338. * @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)
  113339. */
  113340. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  113341. /**
  113342. * Stops the current optimizer
  113343. */
  113344. stop(): void;
  113345. /**
  113346. * Reset the optimizer to initial step (current priority level = 0)
  113347. */
  113348. reset(): void;
  113349. /**
  113350. * Start the optimizer. By default it will try to reach a specific framerate
  113351. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  113352. */
  113353. start(): void;
  113354. private _checkCurrentState;
  113355. /**
  113356. * Release all resources
  113357. */
  113358. dispose(): void;
  113359. /**
  113360. * Helper function to create a SceneOptimizer with one single line of code
  113361. * @param scene defines the scene to work on
  113362. * @param options defines the options to use with the SceneOptimizer
  113363. * @param onSuccess defines a callback to call on success
  113364. * @param onFailure defines a callback to call on failure
  113365. * @returns the new SceneOptimizer object
  113366. */
  113367. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  113368. }
  113369. }
  113370. declare module BABYLON {
  113371. /**
  113372. * Class used to serialize a scene into a string
  113373. */
  113374. export class SceneSerializer {
  113375. /**
  113376. * Clear cache used by a previous serialization
  113377. */
  113378. static ClearCache(): void;
  113379. /**
  113380. * Serialize a scene into a JSON compatible object
  113381. * @param scene defines the scene to serialize
  113382. * @returns a JSON compatible object
  113383. */
  113384. static Serialize(scene: Scene): any;
  113385. /**
  113386. * Serialize a mesh into a JSON compatible object
  113387. * @param toSerialize defines the mesh to serialize
  113388. * @param withParents defines if parents must be serialized as well
  113389. * @param withChildren defines if children must be serialized as well
  113390. * @returns a JSON compatible object
  113391. */
  113392. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  113393. }
  113394. }
  113395. declare module BABYLON {
  113396. /**
  113397. * This represents the different options avilable for the video capture.
  113398. */
  113399. export interface VideoRecorderOptions {
  113400. /** Defines the mime type of the video */
  113401. mimeType: string;
  113402. /** Defines the video the video should be recorded at */
  113403. fps: number;
  113404. /** Defines the chunk size for the recording data */
  113405. recordChunckSize: number;
  113406. /** The audio tracks to attach to the record */
  113407. audioTracks?: MediaStreamTrack[];
  113408. }
  113409. /**
  113410. * This can helps recording videos from BabylonJS.
  113411. * This is based on the available WebRTC functionalities of the browser.
  113412. *
  113413. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  113414. */
  113415. export class VideoRecorder {
  113416. private static readonly _defaultOptions;
  113417. /**
  113418. * Returns wehther or not the VideoRecorder is available in your browser.
  113419. * @param engine Defines the Babylon Engine to check the support for
  113420. * @returns true if supported otherwise false
  113421. */
  113422. static IsSupported(engine: Engine): boolean;
  113423. private readonly _options;
  113424. private _canvas;
  113425. private _mediaRecorder;
  113426. private _recordedChunks;
  113427. private _fileName;
  113428. private _resolve;
  113429. private _reject;
  113430. /**
  113431. * True wether a recording is already in progress.
  113432. */
  113433. readonly isRecording: boolean;
  113434. /**
  113435. * Create a new VideoCapture object which can help converting what you see in Babylon to
  113436. * a video file.
  113437. * @param engine Defines the BabylonJS Engine you wish to record
  113438. * @param options Defines options that can be used to customized the capture
  113439. */
  113440. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  113441. /**
  113442. * Stops the current recording before the default capture timeout passed in the startRecording
  113443. * functions.
  113444. */
  113445. stopRecording(): void;
  113446. /**
  113447. * Starts recording the canvas for a max duration specified in parameters.
  113448. * @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.
  113449. * @param maxDuration Defines the maximum recording time in seconds.
  113450. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  113451. * @return a promise callback at the end of the recording with the video data in Blob.
  113452. */
  113453. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  113454. /**
  113455. * Releases internal resources used during the recording.
  113456. */
  113457. dispose(): void;
  113458. private _handleDataAvailable;
  113459. private _handleError;
  113460. private _handleStop;
  113461. }
  113462. }
  113463. declare module BABYLON {
  113464. /**
  113465. * Helper class to push actions to a pool of workers.
  113466. */
  113467. export class WorkerPool implements IDisposable {
  113468. private _workerInfos;
  113469. private _pendingActions;
  113470. /**
  113471. * Constructor
  113472. * @param workers Array of workers to use for actions
  113473. */
  113474. constructor(workers: Array<Worker>);
  113475. /**
  113476. * Terminates all workers and clears any pending actions.
  113477. */
  113478. dispose(): void;
  113479. /**
  113480. * Pushes an action to the worker pool. If all the workers are active, the action will be
  113481. * pended until a worker has completed its action.
  113482. * @param action The action to perform. Call onComplete when the action is complete.
  113483. */
  113484. push(action: (worker: Worker, onComplete: () => void) => void): void;
  113485. private _execute;
  113486. }
  113487. }
  113488. declare module BABYLON {
  113489. /**
  113490. * Class containing a set of static utilities functions for screenshots
  113491. */
  113492. export class ScreenshotTools {
  113493. /**
  113494. * Captures a screenshot of the current rendering
  113495. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113496. * @param engine defines the rendering engine
  113497. * @param camera defines the source camera
  113498. * @param size This parameter can be set to a single number or to an object with the
  113499. * following (optional) properties: precision, width, height. If a single number is passed,
  113500. * it will be used for both width and height. If an object is passed, the screenshot size
  113501. * will be derived from the parameters. The precision property is a multiplier allowing
  113502. * rendering at a higher or lower resolution
  113503. * @param successCallback defines the callback receives a single parameter which contains the
  113504. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113505. * src parameter of an <img> to display it
  113506. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  113507. * Check your browser for supported MIME types
  113508. */
  113509. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  113510. /**
  113511. * Generates an image screenshot from the specified camera.
  113512. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113513. * @param engine The engine to use for rendering
  113514. * @param camera The camera to use for rendering
  113515. * @param size This parameter can be set to a single number or to an object with the
  113516. * following (optional) properties: precision, width, height. If a single number is passed,
  113517. * it will be used for both width and height. If an object is passed, the screenshot size
  113518. * will be derived from the parameters. The precision property is a multiplier allowing
  113519. * rendering at a higher or lower resolution
  113520. * @param successCallback The callback receives a single parameter which contains the
  113521. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113522. * src parameter of an <img> to display it
  113523. * @param mimeType The MIME type of the screenshot image (default: image/png).
  113524. * Check your browser for supported MIME types
  113525. * @param samples Texture samples (default: 1)
  113526. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  113527. * @param fileName A name for for the downloaded file.
  113528. */
  113529. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  113530. }
  113531. }
  113532. declare module BABYLON {
  113533. /**
  113534. * A cursor which tracks a point on a path
  113535. */
  113536. export class PathCursor {
  113537. private path;
  113538. /**
  113539. * Stores path cursor callbacks for when an onchange event is triggered
  113540. */
  113541. private _onchange;
  113542. /**
  113543. * The value of the path cursor
  113544. */
  113545. value: number;
  113546. /**
  113547. * The animation array of the path cursor
  113548. */
  113549. animations: Animation[];
  113550. /**
  113551. * Initializes the path cursor
  113552. * @param path The path to track
  113553. */
  113554. constructor(path: Path2);
  113555. /**
  113556. * Gets the cursor point on the path
  113557. * @returns A point on the path cursor at the cursor location
  113558. */
  113559. getPoint(): Vector3;
  113560. /**
  113561. * Moves the cursor ahead by the step amount
  113562. * @param step The amount to move the cursor forward
  113563. * @returns This path cursor
  113564. */
  113565. moveAhead(step?: number): PathCursor;
  113566. /**
  113567. * Moves the cursor behind by the step amount
  113568. * @param step The amount to move the cursor back
  113569. * @returns This path cursor
  113570. */
  113571. moveBack(step?: number): PathCursor;
  113572. /**
  113573. * Moves the cursor by the step amount
  113574. * If the step amount is greater than one, an exception is thrown
  113575. * @param step The amount to move the cursor
  113576. * @returns This path cursor
  113577. */
  113578. move(step: number): PathCursor;
  113579. /**
  113580. * Ensures that the value is limited between zero and one
  113581. * @returns This path cursor
  113582. */
  113583. private ensureLimits;
  113584. /**
  113585. * Runs onchange callbacks on change (used by the animation engine)
  113586. * @returns This path cursor
  113587. */
  113588. private raiseOnChange;
  113589. /**
  113590. * Executes a function on change
  113591. * @param f A path cursor onchange callback
  113592. * @returns This path cursor
  113593. */
  113594. onchange(f: (cursor: PathCursor) => void): PathCursor;
  113595. }
  113596. }
  113597. declare module BABYLON {
  113598. /** @hidden */
  113599. export var blurPixelShader: {
  113600. name: string;
  113601. shader: string;
  113602. };
  113603. }
  113604. declare module BABYLON {
  113605. /** @hidden */
  113606. export var bones300Declaration: {
  113607. name: string;
  113608. shader: string;
  113609. };
  113610. }
  113611. declare module BABYLON {
  113612. /** @hidden */
  113613. export var instances300Declaration: {
  113614. name: string;
  113615. shader: string;
  113616. };
  113617. }
  113618. declare module BABYLON {
  113619. /** @hidden */
  113620. export var pointCloudVertexDeclaration: {
  113621. name: string;
  113622. shader: string;
  113623. };
  113624. }
  113625. // Mixins
  113626. interface Window {
  113627. mozIndexedDB: IDBFactory;
  113628. webkitIndexedDB: IDBFactory;
  113629. msIndexedDB: IDBFactory;
  113630. webkitURL: typeof URL;
  113631. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  113632. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  113633. WebGLRenderingContext: WebGLRenderingContext;
  113634. MSGesture: MSGesture;
  113635. CANNON: any;
  113636. AudioContext: AudioContext;
  113637. webkitAudioContext: AudioContext;
  113638. PointerEvent: any;
  113639. Math: Math;
  113640. Uint8Array: Uint8ArrayConstructor;
  113641. Float32Array: Float32ArrayConstructor;
  113642. mozURL: typeof URL;
  113643. msURL: typeof URL;
  113644. VRFrameData: any; // WebVR, from specs 1.1
  113645. DracoDecoderModule: any;
  113646. setImmediate(handler: (...args: any[]) => void): number;
  113647. }
  113648. interface HTMLCanvasElement {
  113649. requestPointerLock(): void;
  113650. msRequestPointerLock?(): void;
  113651. mozRequestPointerLock?(): void;
  113652. webkitRequestPointerLock?(): void;
  113653. /** Track wether a record is in progress */
  113654. isRecording: boolean;
  113655. /** Capture Stream method defined by some browsers */
  113656. captureStream(fps?: number): MediaStream;
  113657. }
  113658. interface CanvasRenderingContext2D {
  113659. msImageSmoothingEnabled: boolean;
  113660. }
  113661. interface MouseEvent {
  113662. mozMovementX: number;
  113663. mozMovementY: number;
  113664. webkitMovementX: number;
  113665. webkitMovementY: number;
  113666. msMovementX: number;
  113667. msMovementY: number;
  113668. }
  113669. interface Navigator {
  113670. mozGetVRDevices: (any: any) => any;
  113671. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113672. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113673. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113674. webkitGetGamepads(): Gamepad[];
  113675. msGetGamepads(): Gamepad[];
  113676. webkitGamepads(): Gamepad[];
  113677. }
  113678. interface HTMLVideoElement {
  113679. mozSrcObject: any;
  113680. }
  113681. interface Math {
  113682. fround(x: number): number;
  113683. imul(a: number, b: number): number;
  113684. }
  113685. interface WebGLProgram {
  113686. context?: WebGLRenderingContext;
  113687. vertexShader?: WebGLShader;
  113688. fragmentShader?: WebGLShader;
  113689. isParallelCompiled: boolean;
  113690. onCompiled?: () => void;
  113691. }
  113692. interface WebGLRenderingContext {
  113693. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  113694. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  113695. vertexAttribDivisor(index: number, divisor: number): void;
  113696. createVertexArray(): any;
  113697. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  113698. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  113699. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  113700. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  113701. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  113702. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  113703. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  113704. // Queries
  113705. createQuery(): WebGLQuery;
  113706. deleteQuery(query: WebGLQuery): void;
  113707. beginQuery(target: number, query: WebGLQuery): void;
  113708. endQuery(target: number): void;
  113709. getQueryParameter(query: WebGLQuery, pname: number): any;
  113710. getQuery(target: number, pname: number): any;
  113711. MAX_SAMPLES: number;
  113712. RGBA8: number;
  113713. READ_FRAMEBUFFER: number;
  113714. DRAW_FRAMEBUFFER: number;
  113715. UNIFORM_BUFFER: number;
  113716. HALF_FLOAT_OES: number;
  113717. RGBA16F: number;
  113718. RGBA32F: number;
  113719. R32F: number;
  113720. RG32F: number;
  113721. RGB32F: number;
  113722. R16F: number;
  113723. RG16F: number;
  113724. RGB16F: number;
  113725. RED: number;
  113726. RG: number;
  113727. R8: number;
  113728. RG8: number;
  113729. UNSIGNED_INT_24_8: number;
  113730. DEPTH24_STENCIL8: number;
  113731. /* Multiple Render Targets */
  113732. drawBuffers(buffers: number[]): void;
  113733. readBuffer(src: number): void;
  113734. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  113735. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  113736. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  113737. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  113738. // Occlusion Query
  113739. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  113740. ANY_SAMPLES_PASSED: number;
  113741. QUERY_RESULT_AVAILABLE: number;
  113742. QUERY_RESULT: number;
  113743. }
  113744. interface WebGLBuffer {
  113745. references: number;
  113746. capacity: number;
  113747. is32Bits: boolean;
  113748. }
  113749. interface WebGLProgram {
  113750. transformFeedback?: WebGLTransformFeedback | null;
  113751. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  113752. }
  113753. interface EXT_disjoint_timer_query {
  113754. QUERY_COUNTER_BITS_EXT: number;
  113755. TIME_ELAPSED_EXT: number;
  113756. TIMESTAMP_EXT: number;
  113757. GPU_DISJOINT_EXT: number;
  113758. QUERY_RESULT_EXT: number;
  113759. QUERY_RESULT_AVAILABLE_EXT: number;
  113760. queryCounterEXT(query: WebGLQuery, target: number): void;
  113761. createQueryEXT(): WebGLQuery;
  113762. beginQueryEXT(target: number, query: WebGLQuery): void;
  113763. endQueryEXT(target: number): void;
  113764. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  113765. deleteQueryEXT(query: WebGLQuery): void;
  113766. }
  113767. interface WebGLUniformLocation {
  113768. _currentState: any;
  113769. }
  113770. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  113771. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  113772. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  113773. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  113774. interface WebGLRenderingContext {
  113775. readonly RASTERIZER_DISCARD: number;
  113776. readonly DEPTH_COMPONENT24: number;
  113777. readonly TEXTURE_3D: number;
  113778. readonly TEXTURE_2D_ARRAY: number;
  113779. readonly TEXTURE_COMPARE_FUNC: number;
  113780. readonly TEXTURE_COMPARE_MODE: number;
  113781. readonly COMPARE_REF_TO_TEXTURE: number;
  113782. readonly TEXTURE_WRAP_R: number;
  113783. readonly HALF_FLOAT: number;
  113784. readonly RGB8: number;
  113785. readonly RED_INTEGER: number;
  113786. readonly RG_INTEGER: number;
  113787. readonly RGB_INTEGER: number;
  113788. readonly RGBA_INTEGER: number;
  113789. readonly R8_SNORM: number;
  113790. readonly RG8_SNORM: number;
  113791. readonly RGB8_SNORM: number;
  113792. readonly RGBA8_SNORM: number;
  113793. readonly R8I: number;
  113794. readonly RG8I: number;
  113795. readonly RGB8I: number;
  113796. readonly RGBA8I: number;
  113797. readonly R8UI: number;
  113798. readonly RG8UI: number;
  113799. readonly RGB8UI: number;
  113800. readonly RGBA8UI: number;
  113801. readonly R16I: number;
  113802. readonly RG16I: number;
  113803. readonly RGB16I: number;
  113804. readonly RGBA16I: number;
  113805. readonly R16UI: number;
  113806. readonly RG16UI: number;
  113807. readonly RGB16UI: number;
  113808. readonly RGBA16UI: number;
  113809. readonly R32I: number;
  113810. readonly RG32I: number;
  113811. readonly RGB32I: number;
  113812. readonly RGBA32I: number;
  113813. readonly R32UI: number;
  113814. readonly RG32UI: number;
  113815. readonly RGB32UI: number;
  113816. readonly RGBA32UI: number;
  113817. readonly RGB10_A2UI: number;
  113818. readonly R11F_G11F_B10F: number;
  113819. readonly RGB9_E5: number;
  113820. readonly RGB10_A2: number;
  113821. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  113822. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  113823. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  113824. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113825. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  113826. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  113827. 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;
  113828. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  113829. readonly TRANSFORM_FEEDBACK: number;
  113830. readonly INTERLEAVED_ATTRIBS: number;
  113831. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  113832. createTransformFeedback(): WebGLTransformFeedback;
  113833. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  113834. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  113835. beginTransformFeedback(primitiveMode: number): void;
  113836. endTransformFeedback(): void;
  113837. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  113838. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113839. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113840. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113841. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  113842. }
  113843. interface ImageBitmap {
  113844. readonly width: number;
  113845. readonly height: number;
  113846. close(): void;
  113847. }
  113848. interface WebGLQuery extends WebGLObject {
  113849. }
  113850. declare var WebGLQuery: {
  113851. prototype: WebGLQuery;
  113852. new(): WebGLQuery;
  113853. };
  113854. interface WebGLSampler extends WebGLObject {
  113855. }
  113856. declare var WebGLSampler: {
  113857. prototype: WebGLSampler;
  113858. new(): WebGLSampler;
  113859. };
  113860. interface WebGLSync extends WebGLObject {
  113861. }
  113862. declare var WebGLSync: {
  113863. prototype: WebGLSync;
  113864. new(): WebGLSync;
  113865. };
  113866. interface WebGLTransformFeedback extends WebGLObject {
  113867. }
  113868. declare var WebGLTransformFeedback: {
  113869. prototype: WebGLTransformFeedback;
  113870. new(): WebGLTransformFeedback;
  113871. };
  113872. interface WebGLVertexArrayObject extends WebGLObject {
  113873. }
  113874. declare var WebGLVertexArrayObject: {
  113875. prototype: WebGLVertexArrayObject;
  113876. new(): WebGLVertexArrayObject;
  113877. };
  113878. // Type definitions for WebVR API
  113879. // Project: https://w3c.github.io/webvr/
  113880. // Definitions by: six a <https://github.com/lostfictions>
  113881. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  113882. interface VRDisplay extends EventTarget {
  113883. /**
  113884. * Dictionary of capabilities describing the VRDisplay.
  113885. */
  113886. readonly capabilities: VRDisplayCapabilities;
  113887. /**
  113888. * z-depth defining the far plane of the eye view frustum
  113889. * enables mapping of values in the render target depth
  113890. * attachment to scene coordinates. Initially set to 10000.0.
  113891. */
  113892. depthFar: number;
  113893. /**
  113894. * z-depth defining the near plane of the eye view frustum
  113895. * enables mapping of values in the render target depth
  113896. * attachment to scene coordinates. Initially set to 0.01.
  113897. */
  113898. depthNear: number;
  113899. /**
  113900. * An identifier for this distinct VRDisplay. Used as an
  113901. * association point in the Gamepad API.
  113902. */
  113903. readonly displayId: number;
  113904. /**
  113905. * A display name, a user-readable name identifying it.
  113906. */
  113907. readonly displayName: string;
  113908. readonly isConnected: boolean;
  113909. readonly isPresenting: boolean;
  113910. /**
  113911. * If this VRDisplay supports room-scale experiences, the optional
  113912. * stage attribute contains details on the room-scale parameters.
  113913. */
  113914. readonly stageParameters: VRStageParameters | null;
  113915. /**
  113916. * Passing the value returned by `requestAnimationFrame` to
  113917. * `cancelAnimationFrame` will unregister the callback.
  113918. * @param handle Define the hanle of the request to cancel
  113919. */
  113920. cancelAnimationFrame(handle: number): void;
  113921. /**
  113922. * Stops presenting to the VRDisplay.
  113923. * @returns a promise to know when it stopped
  113924. */
  113925. exitPresent(): Promise<void>;
  113926. /**
  113927. * Return the current VREyeParameters for the given eye.
  113928. * @param whichEye Define the eye we want the parameter for
  113929. * @returns the eye parameters
  113930. */
  113931. getEyeParameters(whichEye: string): VREyeParameters;
  113932. /**
  113933. * Populates the passed VRFrameData with the information required to render
  113934. * the current frame.
  113935. * @param frameData Define the data structure to populate
  113936. * @returns true if ok otherwise false
  113937. */
  113938. getFrameData(frameData: VRFrameData): boolean;
  113939. /**
  113940. * Get the layers currently being presented.
  113941. * @returns the list of VR layers
  113942. */
  113943. getLayers(): VRLayer[];
  113944. /**
  113945. * Return a VRPose containing the future predicted pose of the VRDisplay
  113946. * when the current frame will be presented. The value returned will not
  113947. * change until JavaScript has returned control to the browser.
  113948. *
  113949. * The VRPose will contain the position, orientation, velocity,
  113950. * and acceleration of each of these properties.
  113951. * @returns the pose object
  113952. */
  113953. getPose(): VRPose;
  113954. /**
  113955. * Return the current instantaneous pose of the VRDisplay, with no
  113956. * prediction applied.
  113957. * @returns the current instantaneous pose
  113958. */
  113959. getImmediatePose(): VRPose;
  113960. /**
  113961. * The callback passed to `requestAnimationFrame` will be called
  113962. * any time a new frame should be rendered. When the VRDisplay is
  113963. * presenting the callback will be called at the native refresh
  113964. * rate of the HMD. When not presenting this function acts
  113965. * identically to how window.requestAnimationFrame acts. Content should
  113966. * make no assumptions of frame rate or vsync behavior as the HMD runs
  113967. * asynchronously from other displays and at differing refresh rates.
  113968. * @param callback Define the eaction to run next frame
  113969. * @returns the request handle it
  113970. */
  113971. requestAnimationFrame(callback: FrameRequestCallback): number;
  113972. /**
  113973. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  113974. * Repeat calls while already presenting will update the VRLayers being displayed.
  113975. * @param layers Define the list of layer to present
  113976. * @returns a promise to know when the request has been fulfilled
  113977. */
  113978. requestPresent(layers: VRLayer[]): Promise<void>;
  113979. /**
  113980. * Reset the pose for this display, treating its current position and
  113981. * orientation as the "origin/zero" values. VRPose.position,
  113982. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  113983. * updated when calling resetPose(). This should be called in only
  113984. * sitting-space experiences.
  113985. */
  113986. resetPose(): void;
  113987. /**
  113988. * The VRLayer provided to the VRDisplay will be captured and presented
  113989. * in the HMD. Calling this function has the same effect on the source
  113990. * canvas as any other operation that uses its source image, and canvases
  113991. * created without preserveDrawingBuffer set to true will be cleared.
  113992. * @param pose Define the pose to submit
  113993. */
  113994. submitFrame(pose?: VRPose): void;
  113995. }
  113996. declare var VRDisplay: {
  113997. prototype: VRDisplay;
  113998. new(): VRDisplay;
  113999. };
  114000. interface VRLayer {
  114001. leftBounds?: number[] | Float32Array | null;
  114002. rightBounds?: number[] | Float32Array | null;
  114003. source?: HTMLCanvasElement | null;
  114004. }
  114005. interface VRDisplayCapabilities {
  114006. readonly canPresent: boolean;
  114007. readonly hasExternalDisplay: boolean;
  114008. readonly hasOrientation: boolean;
  114009. readonly hasPosition: boolean;
  114010. readonly maxLayers: number;
  114011. }
  114012. interface VREyeParameters {
  114013. /** @deprecated */
  114014. readonly fieldOfView: VRFieldOfView;
  114015. readonly offset: Float32Array;
  114016. readonly renderHeight: number;
  114017. readonly renderWidth: number;
  114018. }
  114019. interface VRFieldOfView {
  114020. readonly downDegrees: number;
  114021. readonly leftDegrees: number;
  114022. readonly rightDegrees: number;
  114023. readonly upDegrees: number;
  114024. }
  114025. interface VRFrameData {
  114026. readonly leftProjectionMatrix: Float32Array;
  114027. readonly leftViewMatrix: Float32Array;
  114028. readonly pose: VRPose;
  114029. readonly rightProjectionMatrix: Float32Array;
  114030. readonly rightViewMatrix: Float32Array;
  114031. readonly timestamp: number;
  114032. }
  114033. interface VRPose {
  114034. readonly angularAcceleration: Float32Array | null;
  114035. readonly angularVelocity: Float32Array | null;
  114036. readonly linearAcceleration: Float32Array | null;
  114037. readonly linearVelocity: Float32Array | null;
  114038. readonly orientation: Float32Array | null;
  114039. readonly position: Float32Array | null;
  114040. readonly timestamp: number;
  114041. }
  114042. interface VRStageParameters {
  114043. sittingToStandingTransform?: Float32Array;
  114044. sizeX?: number;
  114045. sizeY?: number;
  114046. }
  114047. interface Navigator {
  114048. getVRDisplays(): Promise<VRDisplay[]>;
  114049. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  114050. }
  114051. interface Window {
  114052. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  114053. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  114054. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  114055. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114056. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114057. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  114058. }
  114059. interface Gamepad {
  114060. readonly displayId: number;
  114061. }
  114062. interface XRDevice {
  114063. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  114064. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  114065. }
  114066. interface XRSession {
  114067. getInputSources(): Array<any>;
  114068. baseLayer: XRWebGLLayer;
  114069. requestFrameOfReference(type: string): Promise<void>;
  114070. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  114071. end(): Promise<void>;
  114072. requestAnimationFrame: Function;
  114073. addEventListener: Function;
  114074. }
  114075. interface XRSessionCreationOptions {
  114076. outputContext?: WebGLRenderingContext | null;
  114077. immersive?: boolean;
  114078. environmentIntegration?: boolean;
  114079. }
  114080. interface XRLayer {
  114081. getViewport: Function;
  114082. framebufferWidth: number;
  114083. framebufferHeight: number;
  114084. }
  114085. interface XRView {
  114086. projectionMatrix: Float32Array;
  114087. }
  114088. interface XRFrame {
  114089. getDevicePose: Function;
  114090. getInputPose: Function;
  114091. views: Array<XRView>;
  114092. baseLayer: XRLayer;
  114093. }
  114094. interface XRFrameOfReference {
  114095. }
  114096. interface XRWebGLLayer extends XRLayer {
  114097. framebuffer: WebGLFramebuffer;
  114098. }
  114099. declare var XRWebGLLayer: {
  114100. prototype: XRWebGLLayer;
  114101. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  114102. };